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 View Source File : Visualization.cs
License : MIT License
Project Creator : AmigoCap

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianReader.cs
License : MIT License
Project Creator : 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 View Source File : I360Render.cs
License : Apache License 2.0
Project Creator : allenai

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

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

		return result;
	}

19 View Source File : LavalinkUtil.cs
License : MIT License
Project Creator : 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 View Source File : utils.cs
License : GNU General Public License v3.0
Project Creator : Aeroblast

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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()
                };
            }
        }

19 View Source File : EndianBitConverter.cs
License : Microsoft Public License
Project Creator : 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 View Source File : Connection.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Utils.cs
License : Apache License 2.0
Project Creator : 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 View Source File : utils.cs
License : GNU General Public License v3.0
Project Creator : Aeroblast

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

19 View Source File : ArrayExtension.cs
License : MIT License
Project Creator : AlphaYu

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

19 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : Visualization.cs
License : MIT License
Project Creator : AmigoCap

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

19 View Source File : EndianReader.cs
License : MIT License
Project Creator : 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 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : ROMManager.cs
License : GNU General Public License v3.0
Project Creator : aglab2

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

19 View Source File : ROMManager.cs
License : GNU General Public License v3.0
Project Creator : aglab2

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

19 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : GuidHelper.cs
License : MIT License
Project Creator : 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 View Source File : EndianBitConverter.cs
License : Microsoft Public License
Project Creator : 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 View Source File : LonLatToGeoCoordinateConverter.cs
License : MIT License
Project Creator : 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 View Source File : Utils.cs
License : Apache License 2.0
Project Creator : 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 View Source File : EndianUtility.cs
License : MIT License
Project Creator : adrenak

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

19 View Source File : reversestring.cs
License : MIT License
Project Creator : AllAlgorithms

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

19 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : StringExtension.cs
License : MIT License
Project Creator : 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 View Source File : utils.cs
License : GNU General Public License v3.0
Project Creator : Aeroblast

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

19 View Source File : Visualization.cs
License : MIT License
Project Creator : AmigoCap

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

19 View Source File : Mesh.cs
License : MIT License
Project Creator : 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 View Source File : Visualization.cs
License : MIT License
Project Creator : AmigoCap

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

19 View Source File : utils.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianReader.cs
License : MIT License
Project Creator : 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 View Source File : IdentityGenerator.cs
License : MIT License
Project Creator : 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 View Source File : RdpPacket.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 3gstudent

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

19 View Source File : Indicators.cs
License : MIT License
Project Creator : 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 View Source File : EndianReader.cs
License : MIT License
Project Creator : 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 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : SequentialGuidGenerator.cs
License : MIT License
Project Creator : 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 View Source File : StringHandlingPackets.cs
License : MIT License
Project Creator : 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 View Source File : EndianBinaryReader.cs
License : MIT License
Project Creator : 91Act

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

19 View Source File : BinaryReaderExtensions.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

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

19 View Source File : EmulatorClientSocket.cs
License : MIT License
Project Creator : alanplotko

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

      return array;
    }

See More Examples