System.Array.Reverse(System.Array)

Here are the examples of the csharp api System.Array.Reverse(System.Array) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1645 Examples 7

19 Source : SequentialGuidGenerator.cs
with MIT License
from 17MKH

public Guid Create(SequentialGuidType guidType)
    {
        lock (_lock)
        {
            var randomBytes = new byte[10];
            _rng.GetBytes(randomBytes);

            var timestamp = DateTime.UtcNow.Ticks / 10000L;
            var timestampBytes = BitConverter.GetBytes(timestamp);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(timestampBytes);
            }

            var guidBytes = new byte[16];

            switch (guidType)
            {
                case SequentialGuidType.Sequentialreplacedtring:
                case SequentialGuidType.SequentialAsBinary:
                    Buffer.BlockCopy(timestampBytes, 2, guidBytes, 0, 6);
                    Buffer.BlockCopy(randomBytes, 0, guidBytes, 6, 10);

                    // If formatting as a string, we have to reverse the order
                    // of the Data1 and Data2 blocks on little-endian systems.
                    if (guidType == SequentialGuidType.Sequentialreplacedtring && BitConverter.IsLittleEndian)
                    {
                        Array.Reverse(guidBytes, 0, 4);
                        Array.Reverse(guidBytes, 4, 2);
                    }
                    break;

                case SequentialGuidType.SequentialAtEnd:
                    Buffer.BlockCopy(randomBytes, 0, guidBytes, 0, 10);
                    Buffer.BlockCopy(timestampBytes, 2, guidBytes, 10, 6);
                    break;
            }

            return new Guid(guidBytes);
        }
    }

19 Source : RdpPacket.cs
with BSD 3-Clause "New" or "Revised" License
from 3gstudent

private byte[] Reverse(byte[] data)
        {
            Array.Reverse(data);
            return data;
        }

19 Source : StringHandlingPackets.cs
with MIT License
from 499116344

public void Add(DateTime datetime)
        {
            var value = (uint) (datetime - DateTime.Parse("1970-1-1").ToLocalTime()).TotalSeconds;
            var bytes = BitConverter.GetBytes(value);
            Array.Reverse(bytes);
            _stream.Write(bytes, 0, bytes.Length);
        }

19 Source : Mesh.cs
with MIT License
from 91Act

public float bytesToFloat (byte[] inputBytes)
		{
			float result = 0;
			if (a_Stream.endian == EndianType.BigEndian) { Array.Reverse(inputBytes); }

			switch (inputBytes.Length)
			{
				case 1:
					result = inputBytes[0] / 255.0f;
					break;
				case 2:
					result = Half.ToHalf(inputBytes, 0);
					break;
				case 4:
					result = BitConverter.ToSingle(inputBytes, 0);
					break;
			}

			return result;
		}

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override short ReadInt16()
        {
            if (endian == EndianType.BigEndian)
            {
                a16 = ReadBytes(2);
                Array.Reverse(a16);
                return BitConverter.ToInt16(a16, 0);
            }
            return base.ReadInt16();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override int ReadInt32()
        {
            if (endian == EndianType.BigEndian)
            {
                a32 = ReadBytes(4);
                Array.Reverse(a32);
                return BitConverter.ToInt32(a32, 0);
            }
            return base.ReadInt32();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override long ReadInt64()
        {
            if (endian == EndianType.BigEndian)
            {
                a64 = ReadBytes(8);
                Array.Reverse(a64);
                return BitConverter.ToInt64(a64, 0);
            }
            return base.ReadInt64();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override ushort ReadUInt16()
        {
            if (endian == EndianType.BigEndian)
            {
                a16 = ReadBytes(2);
                Array.Reverse(a16);
                return BitConverter.ToUInt16(a16, 0);
            }
            return base.ReadUInt16();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override uint ReadUInt32()
        {
            if (endian == EndianType.BigEndian)
            {
                a32 = ReadBytes(4);
                Array.Reverse(a32);
                return BitConverter.ToUInt32(a32, 0);
            }
            return base.ReadUInt32();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override ulong ReadUInt64()
        {
            if (endian == EndianType.BigEndian)
            {
                a64 = ReadBytes(8);
                Array.Reverse(a64);
                return BitConverter.ToUInt64(a64, 0);
            }
            return base.ReadUInt64();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override float ReadSingle()
        {
            if (endian == EndianType.BigEndian)
            {
                a32 = ReadBytes(4);
                Array.Reverse(a32);
                return BitConverter.ToSingle(a32, 0);
            }
            return base.ReadSingle();
        }

19 Source : EndianBinaryReader.cs
with MIT License
from 91Act

public override double ReadDouble()
        {
            if (endian == EndianType.BigEndian)
            {
                a64 = ReadBytes(8);
                Array.Reverse(a64);
                return BitConverter.ToUInt64(a64, 0);
            }
            return base.ReadDouble();
        }

19 Source : EndianBitConverter.cs
with Microsoft Public License
from abfo

public static int ToInt32(byte[] value, int startIndex, ProvidedOrder order)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if ((startIndex + sizeof(int)) > value.Length)
            {
                throw new ArgumentException("startIndex invalid (not enough space in value to extract an integer", "startIndex");
            }

            if (BitConverter.IsLittleEndian && (order == ProvidedOrder.Big))
            {
                byte[] toConvert = new byte[sizeof(int)];
                Array.Copy(value, startIndex, toConvert, 0, sizeof(int));
                Array.Reverse(toConvert);
                return BitConverter.ToInt32(toConvert, 0);
            }
            else
            {
                return BitConverter.ToInt32(value, startIndex);
            }
        }

19 Source : EndianBitConverter.cs
with Microsoft Public License
from abfo

public static double ToDouble(byte[] value, int startIndex, ProvidedOrder order)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if ((startIndex + sizeof(double)) > value.Length)
            {
                throw new ArgumentException("startIndex invalid (not enough space in value to extract a double", "startIndex");
            }

            if (BitConverter.IsLittleEndian && (order == ProvidedOrder.Big))
            {
                byte[] toConvert = new byte[sizeof(double)];
                Array.Copy(value, startIndex, toConvert, 0, sizeof(double));
                Array.Reverse(toConvert);
                return BitConverter.ToDouble(toConvert, 0);
            }
            else
            {
                return BitConverter.ToDouble(value, startIndex);
            }
        }

19 Source : BinaryReaderExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string Reverse(this string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

19 Source : EndianUtility.cs
with MIT License
from adrenak

public static void EndianCorrection(byte[] bytes) {
			if (RequiresEndianCorrection)
				Array.Reverse(bytes);
		}

19 Source : utils.cs
with GNU General Public License v3.0
from Aeroblast

public static UInt64 GetUInt64(byte[] src, ulong start)
        {
            byte[] t = SubArray(src, start, 8);
            Array.Reverse(t);
            return BitConverter.ToUInt64(t);
        }

19 Source : utils.cs
with GNU General Public License v3.0
from Aeroblast

public static UInt32 GetUInt32(byte[] src, ulong start)
        {
            byte[] t = SubArray(src, start, 4);
            Array.Reverse(t);
            return BitConverter.ToUInt32(t);
        }

19 Source : utils.cs
with GNU General Public License v3.0
from Aeroblast

public static UInt16 GetUInt16(byte[] src, ulong start)
        {
            byte[] t = SubArray(src, start, 2);
            Array.Reverse(t);
            return BitConverter.ToUInt16(t);
        }

19 Source : utils.cs
with GNU General Public License v3.0
from Aeroblast

public static T GetStructBE<T>(byte[] data, int offset)
        {
            int size = Marshal.SizeOf(typeof(T));
            Byte[] data_trimed = SubArray(data, offset, size);
            Array.Reverse(data_trimed);
            IntPtr structPtr = Marshal.AllocHGlobal(size);
            Marshal.Copy(data_trimed, 0, structPtr, size);
            T r = (T)Marshal.PtrToStructure(structPtr, typeof(T));
            Marshal.FreeHGlobal(structPtr);
            return r;
        }

19 Source : EndianReader.cs
with MIT License
from aerosoul94

public override short ReadInt16()
        {
            var temp = new byte[2];
            Read(temp, 2);
            if (byteOrder == ByteOrder.Big)
            {
                Array.Reverse(temp);
            }
            return BitConverter.ToInt16(temp, 0);
        }

19 Source : EndianReader.cs
with MIT License
from aerosoul94

public override ushort ReadUInt16()
        {
            var temp = new byte[2];
            Read(temp, 2);
            if (byteOrder == ByteOrder.Big)
            {
                Array.Reverse(temp);
            }
            return BitConverter.ToUInt16(temp, 0);
        }

19 Source : EndianReader.cs
with MIT License
from aerosoul94

public override int ReadInt32()
        {
            var temp = new byte[4];
            Read(temp, 4);
            if (byteOrder == ByteOrder.Big)
            {
                Array.Reverse(temp);
            }
            return BitConverter.ToInt32(temp, 0);
        }

19 Source : EndianReader.cs
with MIT License
from aerosoul94

public override uint ReadUInt32()
        {
            var temp = new byte[4];
            Read(temp, 4);
            if (byteOrder == ByteOrder.Big)
            {
                Array.Reverse(temp);
            }
            return BitConverter.ToUInt32(temp, 0);
        }

19 Source : ROMManager.cs
with GNU General Public License v3.0
from aglab2

private int ReadInt32()
        {
            byte[] a32 = reader.ReadBytes(4);
            Array.Reverse(a32);
            return BitConverter.ToInt32(a32, 0);
        }

19 Source : ROMManager.cs
with GNU General Public License v3.0
from aglab2

private int ReadInt32(int offset)
        {
            reader.BaseStream.Position = offset;
            byte[] a32 = reader.ReadBytes(4);
            Array.Reverse(a32);
            return BitConverter.ToInt32(a32, 0);
        }

19 Source : LavalinkUtil.cs
with MIT License
from Aiko-IT-Systems

private byte[] GetNextBytesNativeEndian(int count)
        {
            //Contract.Requires(count >= 0);
            //Contract.Ensures(Contract.Result<Byte[]>() != null);
            //Contract.Ensures(Contract.Result<Byte[]>().Length == count);

            var bytes = this.GetNextBytes(count);
            if (BitConverter.IsLittleEndian)
                Array.Reverse(bytes);
            return bytes;
        }

19 Source : GuidHelper.cs
with MIT License
from aishang2015

public Guid Next()
        {
            var guidBytes = Guid.NewGuid().ToByteArray();
            var counterBytes = BitConverter.GetBytes(Interlocked.Increment(ref _counter));

            if (!BitConverter.IsLittleEndian)
            {
                Array.Reverse(counterBytes);
            }

            guidBytes[08] = counterBytes[1];
            guidBytes[09] = counterBytes[0];
            guidBytes[10] = counterBytes[7];
            guidBytes[11] = counterBytes[6];
            guidBytes[12] = counterBytes[5];
            guidBytes[13] = counterBytes[4];
            guidBytes[14] = counterBytes[3];
            guidBytes[15] = counterBytes[2];

            return new Guid(guidBytes);
        }

19 Source : Utils.cs
with Apache License 2.0
from ajuna-network

public static object Bytes2Value(byte[] value, bool littleEndian = true)
        {
            if (!littleEndian) Array.Reverse(value);

            switch (value.Length)
            {
                case 2:
                    return BitConverter.ToUInt16(value, 0);
                case 4:
                    return BitConverter.ToUInt32(value, 0);
                case 8:
                    return BitConverter.ToUInt64(value, 0);
                default:
                    throw new Exception($"Unhandled byte size {value.Length} for this method!");
            }
        }

19 Source : Utils.cs
with Apache License 2.0
from ajuna-network

public static byte[] Value2Bytes(object value, bool littleEndian = true)
        {
            byte[] result;

            switch (value)
            {
                case ushort s:
                    result = BitConverter.GetBytes(s);
                    break;
                case uint s:
                    result = BitConverter.GetBytes(s);
                    break;
                case ulong s:
                    result = BitConverter.GetBytes(s);
                    break;
                default:
                    throw new Exception("Unhandled byte size for this method!");
            }

            if (!littleEndian) Array.Reverse(result);

            return result;
        }

19 Source : EmulatorClientSocket.cs
with MIT License
from alanplotko

static private byte[] correctEndianness(byte[] array) {
      if (BitConverter.IsLittleEndian)
        Array.Reverse(array);

      return array;
    }

19 Source : LonLatToGeoCoordinateConverter.cs
with MIT License
from alen-smajic

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			var val = (Vector2d)value;

			Array valAsArray = val.ToArray();

			// By default, Vector2d outputs an array with [lat, lon] order, but we want the reverse.
			Array.Reverse(valAsArray);

			serializer.Serialize(writer, valAsArray);
		}

19 Source : Connection.cs
with GNU General Public License v3.0
from alexgracianoarj

private void RerouteFromBendPoints()
		{
			routeCache.Clear();

			FlowDirection direction = AddStartSegment();

			LinkedListNode<BendPoint> current = bendPoints.First;
			while (current != bendPoints.Last)
			{
				direction = AddInnerSegment(current, direction);
				current = current.Next;
			}

			AddEndSegment();

			routeCacheArray = routeCache.ToArray();
			Array.Reverse(routeCacheArray);
		}

19 Source : reversestring.cs
with MIT License
from AllAlgorithms

static string ReverseString(string inputString){
      char[] charArray = inputString.ToCharArray();
      Array.Reverse( charArray );
      return new string( charArray );
   }

19 Source : I360Render.cs
with Apache License 2.0
from allenai

private static byte[] CalculateCRCBytes_PNG( uint crc )
	{
		var result = BitConverter.GetBytes( crc );

		if( BitConverter.IsLittleEndian )
			Array.Reverse( result );

		return result;
	}

19 Source : StringExtension.cs
with MIT License
from AlphaYu

public static string Reverse([NotNull] this string @this)
        {
            if (@this.Length <= 1)
            {
                return @this;
            }

            var chars = @this.ToCharArray();
            Array.Reverse(chars);
            return new string(chars);
        }

19 Source : ArrayExtension.cs
with MIT License
from AlphaYu

public static void Reverse([NotNull] this Array array)
        {
            Array.Reverse(array);
        }

19 Source : Visualization.cs
with MIT License
from AmigoCap

public override int ReadInt32() {
                var data = base.ReadBytes(4);
                Array.Reverse(data);
                return BitConverter.ToInt32(data, 0);
            }

19 Source : Visualization.cs
with MIT License
from AmigoCap

public override long ReadInt64() {
                var data = base.ReadBytes(8);
                Array.Reverse(data);
                return BitConverter.ToInt64(data, 0);
            }

19 Source : Visualization.cs
with MIT License
from AmigoCap

public override float ReadSingle() {
                var data = base.ReadBytes(4);
                Array.Reverse(data);
                return BitConverter.ToSingle(data, 0);
            }

19 Source : Visualization.cs
with MIT License
from AmigoCap

public override double ReadDouble() {
                var data = base.ReadBytes(8);
                Array.Reverse(data);
                return BitConverter.ToDouble(data, 0);
            }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static AroonResult Aroon(decimal[] inputHigh,
            decimal[] inputLow,            
            int period,
            Func<decimal[], decimal[], IndicatorSignal> aroonSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] outputUp = new double[inputHigh.Length];
                double[] outputDown = new double[inputHigh.Length];

                var result = Core.Aroon(0,
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),                    
                    period,
                    out int outBeginIndex,
                    out int outElementsCount,
                    outputDown,
                    outputUp);

                if (result == Core.RetCode.Success)
                {
                    var outputUpDecimal = new decimal[outElementsCount];
                    var outputDownDecimal = new decimal[outElementsCount];

                    Array.Reverse(outputUpDecimal);
                    Array.ConstrainedCopy(Array.ConvertAll(outputUp, item => (decimal)item), outBeginIndex, outputUpDecimal, 0, outElementsCount);
                    Array.Reverse(outputUpDecimal);

                    Array.Reverse(outputDownDecimal);
                    Array.ConstrainedCopy(Array.ConvertAll(outputDown, item => (decimal)item), outBeginIndex, outputDownDecimal, 0, outElementsCount);
                    Array.Reverse(outputDownDecimal);

                    indicatorSignal = aroonSignalLogic != null ?
                            aroonSignalLogic.Invoke(outputUpDecimal, outputDownDecimal) :
                            aroonDefaultSignalLogic.Invoke(outputUpDecimal, outputDownDecimal);

                    return new AroonResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        AroonUp = outputUpDecimal,
                        AroonDown = outputDownDecimal
                    };
                }
                else
                {
                    return new AroonResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new AroonResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static BollingerBandsResult BollingerBands(decimal[] input,
            int period,
            double stdDevUp,
            double stdDevDown,
            MovingAverageType maType,            
            Func<decimal[], decimal[], decimal[], decimal[], IndicatorSignal> bBandsSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] outputUp = new double[input.Length];
                double[] outputMiddle = new double[input.Length];
                double[] outputDown = new double[input.Length];

                var result = Core.Bbands(0,
                    input.Length - 1,
                    Array.ConvertAll(input, item => (float)item),
                    period,
                    stdDevUp,
                    stdDevDown,
                    MovingAverageTypes.ToTaLib(maType),                                        
                    out int outBeginIndex,
                    out int outElementsCount,
                    outputUp,
                    outputMiddle,
                    outputDown);

                if (result == Core.RetCode.Success)
                {
                    var outputUpDecimal = new decimal[outElementsCount];
                    var outputMiddleDecimal = new decimal[outElementsCount];
                    var outputDownDecimal = new decimal[outElementsCount];

                    Array.Reverse(outputUp);
                    Array.ConstrainedCopy(Array.ConvertAll(outputUp, item => (decimal)item), outBeginIndex, outputUpDecimal, 0, outElementsCount);
                    Array.Reverse(outputUpDecimal);

                    Array.Reverse(outputMiddle);
                    Array.ConstrainedCopy(Array.ConvertAll(outputMiddle, item => (decimal)item), outBeginIndex, outputMiddleDecimal, 0, outElementsCount);
                    Array.Reverse(outputMiddleDecimal);

                    Array.Reverse(outputDown);
                    Array.ConstrainedCopy(Array.ConvertAll(outputDown, item => (decimal)item), outBeginIndex, outputDownDecimal, 0, outElementsCount);
                    Array.Reverse(outputDownDecimal);

                    indicatorSignal = bBandsSignalLogic != null ?
                            bBandsSignalLogic.Invoke(input, outputUpDecimal, outputMiddleDecimal, outputDownDecimal) :
                            IndicatorSignal.Stay;

                    return new BollingerBandsResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        UpperBand = outputUpDecimal,
                        MiddleBand = outputMiddleDecimal,
                        LowerBand = outputDownDecimal
                    };
                }
                else
                {
                    return new BollingerBandsResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new BollingerBandsResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static MacdResult MacdExt(decimal[] input, 
            MovingAverageType fastMaType, 
            int fastPeriod, 
            MovingAverageType slowMaType, 
            int slowPeriod, 
            MovingAverageType signalMaType, 
            int signalPeriod, 
            Func<decimal[], decimal[], decimal[], IndicatorSignal> macdExtSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] outputMacd = new double[input.Length];
                double[] outputSignal = new double[input.Length];
                double[] outputHistogram = new double[input.Length];
                var result = Core.MacdExt(0,
                    input.Length - 1,
                    Array.ConvertAll(input, item => (float)item),
                    fastPeriod, 
                    MovingAverageTypes.ToTaLib(fastMaType),
                    slowPeriod, 
                    MovingAverageTypes.ToTaLib(slowMaType),
                    signalPeriod, 
                    MovingAverageTypes.ToTaLib(signalMaType),
                    out int outBeginIndex, 
                    out int outElementsCount,
                    outputMacd, 
                    outputSignal, 
                    outputHistogram);

                if (result == Core.RetCode.Success)
                {
                    var outputMacdDecimal = new decimal[outElementsCount];
                    var outputSignalDecimal = new decimal[outElementsCount];
                    var outputHistogramDecimal = new decimal[outElementsCount];

                    Array.Reverse(outputMacd);
                    Array.Reverse(outputSignal);
                    Array.Reverse(outputHistogram);

                    Array.ConstrainedCopy(Array.ConvertAll(outputMacd, item => (decimal)item), outBeginIndex, outputMacdDecimal, 0, outElementsCount);
                    Array.ConstrainedCopy(Array.ConvertAll(outputSignal, item => (decimal)item), outBeginIndex, outputSignalDecimal, 0, outElementsCount);
                    Array.ConstrainedCopy(Array.ConvertAll(outputHistogram, item => (decimal)item), outBeginIndex, outputHistogramDecimal, 0, outElementsCount);

                    Array.Reverse(outputMacdDecimal);
                    Array.Reverse(outputSignalDecimal);
                    Array.Reverse(outputHistogramDecimal);

                    indicatorSignal = macdExtSignalLogic != null ?
                            macdExtSignalLogic.Invoke(outputMacdDecimal, outputSignalDecimal, outputHistogramDecimal) : 
                            macdDefaultSignalLogic.Invoke(outputMacdDecimal, outputSignalDecimal, outputHistogramDecimal);

                    return new MacdResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        Macd = outputMacdDecimal,
                        Signal = outputSignalDecimal,
                        Histogram = outputHistogramDecimal
                    };
                }
                else
                {
                    return new MacdResult
                    {
                        Success = false,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new MacdResult
                {
                    Success = false,
                    Message = ex.ToString()
                };
            }
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static MfiResult Mfi(decimal[] inputHigh,
            decimal[] inputLow,
            decimal[] inputClose,
            decimal[] inputVolume,
            int period,
            Func<decimal[], IndicatorSignal> mfiSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] output = new double[inputHigh.Length];

                var result = Core.Mfi(0,
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),
                    Array.ConvertAll(inputClose, item => (double)item),
                    Array.ConvertAll(inputVolume, item => (double)item),
                    period,
                    out int outBeginIndex,
                    out int outElementsCount,
                    output);

                if (result == Core.RetCode.Success)
                {
                    var outputDecimal = new decimal[outElementsCount];

                    Array.Reverse(outputDecimal);
                    Array.ConstrainedCopy(Array.ConvertAll(output, item => (decimal)item), outBeginIndex, outputDecimal, 0, outElementsCount);
                    Array.Reverse(outputDecimal);

                    indicatorSignal = mfiSignalLogic != null ?
                            mfiSignalLogic.Invoke(outputDecimal) : 
                            mfiDefaultSignalLogic.Invoke(outputDecimal);

                    return new MfiResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        Mfi = outputDecimal
                    };
                }
                else
                {
                    return new MfiResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new MfiResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

19 Source : IdentityGenerator.cs
with MIT License
from amolines

public static Guid NewSequentialGuid(IdenreplacedyGeneratorType guidType)
        {
            var randomBytes = new byte[10];
            Rng.GetBytes(randomBytes);

            var timestamp = DateTime.UtcNow.Ticks / 10000L;
            var timestampBytes = BitConverter.GetBytes(timestamp);

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(timestampBytes);
            }

            var guidBytes = new byte[16];

            switch (guidType)
            {
                case IdenreplacedyGeneratorType.Sequentialreplacedtring:
                case IdenreplacedyGeneratorType.SequentialAsBinary:
                    Buffer.BlockCopy(timestampBytes, 2, guidBytes, 0, 6);
                    Buffer.BlockCopy(randomBytes, 0, guidBytes, 6, 10);

                    if (guidType == IdenreplacedyGeneratorType.Sequentialreplacedtring && BitConverter.IsLittleEndian)
                    {
                        Array.Reverse(guidBytes, 0, 4);
                        Array.Reverse(guidBytes, 4, 2);
                    }
                    break;

                case IdenreplacedyGeneratorType.SequentialAtEnd:
                    Buffer.BlockCopy(randomBytes, 0, guidBytes, 0, 10);
                    Buffer.BlockCopy(timestampBytes, 2, guidBytes, 10, 6);
                    break;
            }

            return new Guid(guidBytes);
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static AroonOscillatorResult AroonOscillator(decimal[] inputHigh,
            decimal[] inputLow,
            int period,
            Func<decimal[], IndicatorSignal> aroonOscSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] output = new double[inputHigh.Length];  

                var result = Core.AroonOsc(0,
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),
                    period,
                    out int outBeginIndex,
                    out int outElementsCount,
                    output);

                if (result == Core.RetCode.Success)
                {
                    var outputDecimal = new decimal[outElementsCount];                    

                    Array.Reverse(outputDecimal);
                    Array.ConstrainedCopy(Array.ConvertAll(output, item => (decimal)item), outBeginIndex, outputDecimal, 0, outElementsCount);
                    Array.Reverse(outputDecimal);          

                    indicatorSignal = aroonOscSignalLogic != null ?
                            aroonOscSignalLogic.Invoke(outputDecimal) :
                            aroonOscDefaultSignalLogic.Invoke(outputDecimal);

                    return new AroonOscillatorResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        AroonOscillator = outputDecimal
                    };
                }
                else
                {
                    return new AroonOscillatorResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new AroonOscillatorResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static StochasticResult Stochastic(decimal[] inputHigh, 
            decimal[] inputLow, 
            decimal[] inputClose, 
            int fastKPeriod, 
            MovingAverageType slowKMaType, 
            int slowKPeriod, 
            MovingAverageType slowDMaType, 
            int slowDPeriod, 
            Func<decimal[], decimal[], IndicatorSignal> stochSignalLogic = null)
        {            
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] outputSlowK = new double[inputHigh.Length];
                double[] outputSlowD = new double[inputHigh.Length];

                var result = Core.Stoch(0, 
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),
                    Array.ConvertAll(inputClose, item => (double)item), 
                    fastKPeriod, 
                    slowKPeriod,
                    MovingAverageTypes.ToTaLib(slowKMaType), 
                    slowDPeriod,
                    MovingAverageTypes.ToTaLib(slowDMaType), 
                    out int outBeginIndex,
                    out int outElementsCount, 
                    outputSlowK, 
                    outputSlowD);

                if (result == Core.RetCode.Success)
                {
                    var outputSlowKDecimal = new decimal[outElementsCount];
                    var outputSlowDDecimal = new decimal[outElementsCount];                    

                    Array.Reverse(outputSlowKDecimal);
                    Array.Reverse(outputSlowDDecimal);                    

                    Array.ConstrainedCopy(Array.ConvertAll(outputSlowK, item => (decimal)item), outBeginIndex, outputSlowKDecimal, 0, outElementsCount);
                    Array.ConstrainedCopy(Array.ConvertAll(outputSlowD, item => (decimal)item), outBeginIndex, outputSlowDDecimal, 0, outElementsCount);                    

                    Array.Reverse(outputSlowKDecimal);
                    Array.Reverse(outputSlowDDecimal);

                    indicatorSignal = stochSignalLogic != null ?
                            stochSignalLogic.Invoke(outputSlowKDecimal, outputSlowDDecimal) :
                            stochDefaultSignalLogic.Invoke(outputSlowKDecimal, outputSlowDDecimal);

                    return new StochasticResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        SlowK = outputSlowKDecimal,
                        SlowD = outputSlowDDecimal
                    };
                }
                else
                {
                    return new StochasticResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new StochasticResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static AtrResult Atr(decimal[] inputHigh,
            decimal[] inputLow,
            decimal[] inputClose, 
            int period,
            Func<decimal[], IndicatorSignal> atrSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] output = new double[inputHigh.Length];                

                var result = Core.Atr(0, 
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),
                    Array.ConvertAll(inputClose, item => (double)item),
                    period, 
                    out int outBeginIndex,
                    out int outElementsCount, 
                    output);

                if (result == Core.RetCode.Success)
                {
                    var outputDecimal = new decimal[outElementsCount];                    

                    Array.Reverse(outputDecimal);                    
                    Array.ConstrainedCopy(Array.ConvertAll(output, item => (decimal)item), outBeginIndex, outputDecimal, 0, outElementsCount);                    
                    Array.Reverse(outputDecimal);

                    indicatorSignal = atrSignalLogic != null ?
                            atrSignalLogic.Invoke(outputDecimal) : IndicatorSignal.Stay;

                    return new AtrResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        Atr = outputDecimal
                    };
                }
                else
                {
                    return new AtrResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new AtrResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }            
        }

19 Source : Indicators.cs
with MIT License
from AminSaqi

public static CciResult Cci(decimal[] inputHigh,
            decimal[] inputLow,
            decimal[] inputClose,            
            int period,
            Func<decimal[], IndicatorSignal> cciSignalLogic = null)
        {
            try
            {
                var indicatorSignal = IndicatorSignal.Stay;

                double[] output = new double[inputHigh.Length];

                var result = Core.Cci(0,
                    inputHigh.Length - 1,
                    Array.ConvertAll(inputHigh, item => (double)item),
                    Array.ConvertAll(inputLow, item => (double)item),
                    Array.ConvertAll(inputClose, item => (double)item),                    
                    period,
                    out int outBeginIndex,
                    out int outElementsCount,
                    output);

                if (result == Core.RetCode.Success)
                {
                    var outputDecimal = new decimal[outElementsCount];

                    Array.Reverse(outputDecimal);
                    Array.ConstrainedCopy(Array.ConvertAll(output, item => (decimal)item), outBeginIndex, outputDecimal, 0, outElementsCount);
                    Array.Reverse(outputDecimal);

                    indicatorSignal = cciSignalLogic != null ?
                            cciSignalLogic.Invoke(outputDecimal) :
                            cciDefaultSignalLogic.Invoke(outputDecimal);

                    return new CciResult
                    {
                        Success = true,
                        IndicatorSignal = indicatorSignal,
                        Cci = outputDecimal
                    };
                }
                else
                {
                    return new CciResult
                    {
                        Success = false,
                        IndicatorSignal = IndicatorSignal.Stay,
                        Message = result.ToString()
                    };
                }
            }
            catch (Exception ex)
            {
                return new CciResult
                {
                    Success = false,
                    IndicatorSignal = IndicatorSignal.Stay,
                    Message = ex.ToString()
                };
            }
        }

See More Examples