public static void Draw(GameTime Time)
 {
     PrivateDrawFramesPerSecond++;
     SecondTimer += (float) Time.ElapsedGameTime.TotalSeconds;
     if (SecondTimer >= 1)
     {
         SecondTimer--;
         DrawFramesPerSecond = PrivateDrawFramesPerSecond;
         PrivateDrawFramesPerSecond = 0;
         if (DrawFramesPerSecondBuffer != null)
         {
             DrawFramesPerSecondBuffer[(DrawFramesPerSecondBufferIndex ?? (DrawFramesPerSecondBuffer.Length - 1))
                 ] = DrawFramesPerSecond;
             if (DrawFramesPerSecondBufferIndex == null) DrawFramesPerSecondBufferIndex = 0;
             else
             {
                 if (DrawFramesPerSecondBufferIndex >= (DrawFramesPerSecondBuffer.Length - 1))
                     DrawFramesPerSecondBufferIndex = null;
                 else DrawFramesPerSecondBufferIndex++;
             }
             if (DrawFramesPerSecondBufferRecorded < DrawFramesPerSecondBuffer.Length)
                 DrawFramesPerSecondBufferRecorded++;
         }
     }
 }
        public void Setup()
        {
            //Instance Fields Setup
            BooleanField = null;
            ByteField = null;
            SByteField = null;
            IntField = null;
            LongField = null;
            Int16Field = null;
            UInt16Field = null;
            Int32Field = null;
            UInt32Field = null;
            Int64Field = null;
            UInt64Field = null;
            CharField = null;
            DoubleField = null;
            FloatField = null;

            //Static Fields Setup
            BooleanFieldStatic = null;
            ByteFieldStatic = null;
            SByteFieldStatic = null;
            IntFieldStatic = null;
            LongFieldStatic = null;
            Int16FieldStatic = null;
            UInt16FieldStatic = null;
            Int32FieldStatic = null;
            UInt32FieldStatic = null;
            Int64FieldStatic = null;
            UInt64FieldStatic = null;
            CharFieldStatic = null;
            DoubleFieldStatic = null;
            FloatFieldStatic = null;
        }
Beispiel #3
0
        public ID3v1Tag(byte[] bytes)
        {
            if (bytes.Length < TagLength || Encoding.ASCII.GetString(bytes, bytes.Length - TagLength, 3) != "TAG")
                throw new InvalidDataException("No ID3 tag found");

            ArraySegment<byte> tag = new ArraySegment<byte>(bytes, bytes.Length - TagLength, TagLength);

            _title = Encoding.ASCII.GetString(tag.Array, tag.Offset + TitleOffset, MaxFieldLength).TrimEnd('\0');
            _artist = Encoding.ASCII.GetString(tag.Array, tag.Offset + ArtistOffset, MaxFieldLength).TrimEnd('\0');
            _album = Encoding.ASCII.GetString(tag.Array, tag.Offset + AlbumOffset, MaxFieldLength).TrimEnd('\0');

            short year;
            if (short.TryParse(Encoding.ASCII.GetString(tag.Array, tag.Offset + YearOffset, 4), out year))
                _year = year;

            if (tag.Array[tag.Offset + TrackOffset - 1] == 0)
            {
                _comment = Encoding.ASCII.GetString(tag.Array, tag.Offset + CommentOffset, MaxFieldLength - 2).TrimEnd('\0');
                _track = tag.Array[tag.Offset + TrackOffset];
            }
            else
            {
                _comment = Encoding.ASCII.GetString(tag.Array, tag.Offset + CommentOffset, MaxFieldLength).TrimEnd('\0');
            }

            Genre = (Genre)tag.Array[tag.Offset + GenreOffset];
        }
Beispiel #4
0
 public HslPixel(float hue, float saturation, float luminance)
 {
     this.hue = hue;
     this.saturation = saturation;
     this.luminance = luminance;
     this.normalizedValue = null;
 }
Beispiel #5
0
        public byte ReadBits(int count)
        {
            Guard.ArgumentBetweenInclusive("count", count, 0, 8);

            if (_streamPositionAfterBitReading != this.BaseStream.Position) // there was byte reading operation
                ClearBuffer();

            if (_buffer == null || BitsInBuffer == 0)
            {
                _buffer = ReadByte();
                _bufferPosition = 0;
                _streamPositionAfterBitReading = this.BaseStream.Position;
            }

            byte result;
            if (BitsInBuffer >= count)
            {
                result = GetValueFromBuffer(count);
            }
            else
            {
                byte nextByteBitsCount = (byte) (count - BitsInBuffer);
                byte value = GetValueFromBuffer(BitsInBuffer);

                byte lowBits = ReadBits(nextByteBitsCount);
                result = (byte)((value << nextByteBitsCount) + lowBits);
            }
            return result;
        }
 public override void Refresh(bool volatileOnly)
 {
     base.Refresh(volatileOnly);
     if (!volatileOnly)
         cachedFanData = null;
     ((ControllerBase)Controller).Refresh(this);
 }
        private DateTimePropertyConfiguration(DateTimePropertyConfiguration source)
            : base(source)
        {
            Contract.Requires(source != null);

            Precision = source.Precision;
        }
        private DateTimePropertyConfiguration(DateTimePropertyConfiguration source)
            : base(source)
        {
            DebugCheck.NotNull(source);

            Precision = source.Precision;
        }
Beispiel #9
0
 public Rgb(String Raw)
 {
     string[] val = Raw.Split(';');
     this.redByte = Convert.ToByte(val[0]);
     this.greenByte = Convert.ToByte(val[1]);
     this.blueByte = Convert.ToByte(val[2]);
 }
Beispiel #10
0
 public TileFrame(string tf)
 {
     TileFrame TF;
     TryParse(tf, out TF);
     _tile  = TF.Tile;
     _frame = TF.Frame;
 }
Beispiel #11
0
 public void FlushBits()
 {
     if (_buffer != null)
         Write(_buffer.Value);
     _buffer = null;
     _bufferPosition = 0;
 }
Beispiel #12
0
        public int GetMetadataLength()
        {
            if (this._streamId <= byte.MaxValue)
                this._slen = 0x00;
            else if (this._streamId <= ushort.MaxValue)
                this._slen = 0x01;
            else if (this._streamId <= 16777215)
                this._slen = 0x02;
            else
                this._slen = 0x03;

            if (this._offset == 0)
                this._olen = 0x00;
            else if (this._offset < 65536) // 16 bits
                this._olen = 0x01;
            else if (this._offset < 16777216) // 24 bits
                this._olen = 0x02;
            else if (this._offset < 4294967296) // 32 bits
                this._olen = 0x03;
            else if (this._offset < 1099511627776) // 40 bits
                this._olen = 0x04;
            else if (this._offset < 281474976710656) // 48 bits
                this._olen = 0x05;
            else if (this._offset < 72057594037927936) // 56 bits
                this._olen = 0x06;
            else // 64 bits
                this._olen = 0x07;

            // INFO: We're going to just always send data length (+2)
            this._metadataLength = 1 + (this._slen.Value + 1) * 8 + (this._olen.Value == 0 ? 0 : (this._olen.Value + 1) * 8) + 2;
            return this._metadataLength.Value;
        }
 public SerialPacketManager(SerialPort port, SerialConfig config) : this(port)
 {
     receiverStart = PACKET_SIZED_START_BYTE;
     if (config.RxPacketType == PacketType.SimpleCRC || config.RxPacketType == PacketType.SizedCRC || config.RxPacketType == PacketType.SizedCRC_old)
     {
         receiverCRCValue = config.ReceiverCRC;
     }
     if (config.TxPacketType == PacketType.SimpleCRC || config.TxPacketType == PacketType.SizedCRC || config.TxPacketType == PacketType.SizedCRC_old)
     {
         transmitterCRCValue = config.TransmitterCRC;
     }
     if (config.RxPacketType == PacketType.SizedOld || config.RxPacketType == PacketType.SizedCRC_old)
     {
         receiverEnd = PACKET_END_TRANSMIT;
     }
     if (config.TxPacketType == PacketType.SizedOld || config.TxPacketType == PacketType.SizedCRC_old)
     {
         transmitterEnd = PACKET_END_TRANSMIT;
     }
     if (config.RxPacketType == PacketType.Simple || config.RxPacketType == PacketType.SimpleCoded || config.RxPacketType == PacketType.SimpleCRC)
     {
         receiverStart = PACKET_UNSIZED_START_BYTE;
         receiverEnd = PACKET_END_TEXT;
     }
     if (config.TxPacketType == PacketType.Simple || config.TxPacketType == PacketType.SimpleCoded || config.TxPacketType == PacketType.SimpleCRC)
     {
         transmitterStart = PACKET_UNSIZED_START_BYTE;
         transmitterEnd = PACKET_END_TEXT;
     }
 }
Beispiel #14
0
        internal static State Simulate(this State s, int transitionToUse = 0, params byte?[] inputChars)
        {
            if (inputChars == null)
                inputChars = new byte?[] {null};

            State currentState = s;
            int pos = 0;

            foreach (var inputChar in inputChars)
            {
                var ic = inputChar == null ? InputChar.Epsilon() : InputChar.For((byte) inputChar);
                List<State> transitions;
                if (!currentState.Transitions.TryGetValue(ic, out transitions))
                    ThrowSimulationException(inputChar, pos);

                if (transitions.Count > transitionToUse)
                {
                    currentState = transitions[transitionToUse];
                }
                else if (transitions.Count > 0)
                {
                    currentState = transitions[0];
                }
                else
                {
                    ThrowSimulationException(inputChar, pos);
                }
                pos++;
            }

            return currentState;
        }
 public static void CheckUnaryArithmeticNegateNullableByteTest(bool useInterpreter)
 {
     byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyArithmeticNegateNullableByte(values[i], useInterpreter);
     }
 }
 public static void CheckUnaryBitwiseNotNullableByteTest()
 {
     byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyBitwiseNotNullableByte(values[i]);
     }
 }
        private DecimalPropertyConfiguration(DecimalPropertyConfiguration source)
            : base(source)
        {
            Contract.Requires(source != null);

            Precision = source.Precision;
            Scale = source.Scale;
        }
        private DecimalPropertyConfiguration(DecimalPropertyConfiguration source)
            : base(source)
        {
            DebugCheck.NotNull(source);

            Precision = source.Precision;
            Scale = source.Scale;
        }
 public static void CheckUnaryArithmeticNegateCheckedNullableByteTest()
 {
     byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyArithmeticNegateCheckedNullableByte(values[i]);
     }
 }
    public static void Main()
    {
        // First variant
        // Console.WriteLine(Convert.ToString(number, 2));

        // Second variant
        byte?[] N = new byte?[32];                  // the number is type int, so the length is 32bits
        for (byte i = 0; i < N.Length; i++)         // fills the array with 0s
        {
            N[i] = 0;
        }
        Console.Write("Please, enter some integer number: ");
        Console.ForegroundColor = ConsoleColor.Yellow;
        int num = int.Parse(Console.ReadLine());
        Console.ResetColor();
        int temp = num;
        if (num < 0)                                // if the number is negative
        {
            num = int.MaxValue + num + 1;
            N[N.Length - 1] = 1;                    // sets 1 on the leftmost bit
        }
        while (num > 0)                             // checks where are the 1s
        {
            for (int i = 0; i < int.MaxValue; i++)
            {
                if (Math.Pow(2, i + 1) > num)       // this finds where has to be 1
                {
                    N[i] = 1;                       // sets 1 for this bit
                    num -= (int)Math.Pow(2, i);     // decrease the number by this bit
                    break;
                }
            }
        }
        Array.Reverse(N);                           // reverses the array
        for (int i = 0; i < N.Length; i++)          // removes the first 0s from positive numbers
        {
            if (N[i] == 0) N[i] = null;
            else break;
        }

        // Prints the result
        Console.Write("Binary representation of this number is: ");
        if (temp != 0)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            foreach (var item in N)
            {
                Console.Write(item);
            }
        }
        else
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(0);
        }
        Console.ResetColor();
        Console.WriteLine();
    }
Beispiel #21
0
 /// <summary>
 /// Copies this object's properties from another
 /// </summary>
 /// <param name="other">The object to copy from</param>
 public override void CopyFrom(object other)
 {
     var di = other as DeviceInfo;
     if(di != null)
     {
         base.CopyFrom(di);
         this.DatabaseRevision = di.DatabaseRevision;
     }
 }
Beispiel #22
0
        public PeekStream(Stream inner)
        {
            if (inner == null) {
                throw new ArgumentNullException("inner");
            }

            this.inner = inner;
            this.peek = null;
        }
 internal override void CopyFrom(PrimitivePropertyConfiguration other)
 {
     base.CopyFrom(other);
     var strConfigRhs = other as DateTimePropertyConfiguration;
     if (strConfigRhs != null)
     {
         Precision = strConfigRhs.Precision;
     }
 }
Beispiel #24
0
 public BasicMidiChordDef(BasicMidiChordDef original, int msDuration)
 {
     _msDuration = msDuration; // read-only!
     BankIndex = original.BankIndex;
     PatchIndex = original.PatchIndex;
     HasChordOff = original.HasChordOff;
     Pitches = new List<byte>(original.Pitches);
     Velocities = new List<byte>(original.Velocities);
 }
 internal override void FillFrom(PrimitivePropertyConfiguration other, bool inCSpace)
 {
     base.FillFrom(other, inCSpace);
     var strConfigRhs = other as DateTimePropertyConfiguration;
     if (strConfigRhs != null
         && Precision == null)
     {
         Precision = strConfigRhs.Precision;
     }
 }
 internal override void CopyFrom(PrimitivePropertyConfiguration other)
 {
     base.CopyFrom(other);
     var lenConfigRhs = other as DecimalPropertyConfiguration;
     if (lenConfigRhs != null)
     {
         Precision = lenConfigRhs.Precision;
         Scale = lenConfigRhs.Scale;
     }
 }
Beispiel #27
0
 public ID3v1Tag()
 {
     _title = String.Empty;
     _artist = String.Empty;
     _album = String.Empty;
     _year = null;
     _comment = String.Empty;
     _track = null;
     Genre = Genre.None;
 }
 public static void CheckNonLiftedComparisonEqualNullableByteTest(bool useInterpreter)
 {
     byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyComparisonEqualNullableByte(values[i], values[j], useInterpreter);
         }
     }
 }
 public static void CheckLiftedAddNullableByteTest()
 {
     byte?[] values = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyAddNullableByte(values[i], values[j]);
         }
     }
 }
 public static void CheckNullableBytePowerTest()
 {
     byte?[] array = new byte?[] { null, 0, 1, byte.MaxValue };
     for (int i = 0; i < array.Length; i++)
     {
         for (int j = 0; j < array.Length; j++)
         {
             VerifyNullableBytePower(array[i], array[j]);
         }
     }
 }
 /// <summary>
 /// Set ConceptField field</summary>
 /// <param name="conceptField_">Nullable field value to be set</param>
 public void SetConceptField(byte?conceptField_)
 {
     SetFieldValue(1, 0, conceptField_, Fit.SubfieldIndexMainField);
 }
Beispiel #32
0
 internal static object NullCheck(byte?value)
 {
     return(value ?? (object)DBNull.Value);
 }
 /// <summary>
 /// Set ScreenIndex field</summary>
 /// <param name="screenIndex_">Nullable field value to be set</param>
 public void SetScreenIndex(byte?screenIndex_)
 {
     SetFieldValue(0, 0, screenIndex_, Fit.SubfieldIndexMainField);
 }
Beispiel #34
0
 /// <summary>
 /// Set DeviceType field</summary>
 /// <param name="deviceType_">Nullable field value to be set</param>
 public void SetDeviceType(byte?deviceType_)
 {
     SetFieldValue(1, 0, deviceType_, Fit.SubfieldIndexMainField);
 }
Beispiel #35
0
        public static byte[] Percent_Decode(ReadOnlyMemory <byte> input)
        {/* Docs: https://url.spec.whatwg.org/#percent-decode */
            DataConsumer <byte> Stream = new DataConsumer <byte>(input, byte.MinValue);
            /* Create a list of memory chunks that make up the final string */
            ulong newLength  = 0;
            ulong?chunkStart = null;
            ulong chunkCount = 0;
            var   chunks     = new LinkedList <Tuple <ReadOnlyMemory <byte>, byte?> >();

            while (!Stream.atEnd)
            {
                EFilterResult filterResult = EFilterResult.FILTER_ACCEPT;
                byte?         bytePoint    = null;

                if (Stream.Next == CHAR_PERCENT && Is_Ascii_Hex_Digit((char)Stream.NextNext) && Is_Ascii_Hex_Digit((char)Stream.NextNextNext))
                {
                    filterResult = EFilterResult.FILTER_SKIP;
                    uint low  = (uint)Ascii_Hex_To_Value((char)Stream.NextNext);
                    uint high = (uint)Ascii_Hex_To_Value((char)Stream.NextNextNext);
                    bytePoint = (byte)(low | (high >> 4));
                    Stream.Consume(2);
                    break;
                }

                /* When filter result:
                 * ACCEPT: Char should be included in chunk
                 * SKIP: Char should not be included in chunk, if at chunk-start shift chunk-start past char, otherwise end chunk
                 * REJECT: Char should not be included in chunk, current chunk ends
                 */
                bool end_chunk = false;
                switch (filterResult)
                {
                case EFilterResult.FILTER_ACCEPT:    // Char should be included in the chunk
                {
                    if (!chunkStart.HasValue)
                    {
                        chunkStart = Stream.LongPosition;                              /* Start new chunk (if one isnt started yet) */
                    }
                }
                break;

                case EFilterResult.FILTER_REJECT:    // Char should not be included in chunk, current chunk ends
                {
                    end_chunk = true;
                }
                break;

                case EFilterResult.FILTER_SKIP:    // Char should not be included in chunk, if at chunk-start shift chunk-start past char, otherwise end chunk
                {
                    if (!chunkStart.HasValue)
                    {
                        chunkStart = Stream.LongPosition + 1;        /* At chunk-start */
                    }
                    else
                    {
                        end_chunk = true;
                    }
                }
                break;
                }

                if (end_chunk || Stream.Remaining <= 1)
                {
                    if (!chunkStart.HasValue)
                    {
                        chunkStart = Stream.LongPosition;
                    }

                    /* Push new chunk to our list */
                    var chunkSize = Stream.LongPosition - chunkStart.Value;
                    var Mem       = Stream.AsMemory().Slice((int)chunkStart.Value, (int)chunkSize);
                    var chunk     = new Tuple <ReadOnlyMemory <byte>, byte?>(Mem, bytePoint);
                    chunks.AddLast(chunk);

                    chunkCount++;
                    chunkStart = null;
                    newLength += chunkSize;
                    /* If we actually decoded a byte then account for it in the newLength */
                    if (filterResult != EFilterResult.FILTER_ACCEPT)
                    {
                        newLength++;
                    }
                }

                Stream.Consume();
            }

            /* Compile the string */
            var           dataPtr = new byte[newLength];
            Memory <byte> data    = new Memory <byte>(dataPtr);

            ulong index = 0;

            foreach (var tpl in chunks)
            {
                var chunk = tpl.Item1;
                /* Copy chunk data */
                chunk.CopyTo(data.Slice((int)index));
                index += (ulong)chunk.Length;

                if (tpl.Item2.HasValue)
                {
                    data.Span[(int)index] = tpl.Item2.Value;
                    index++;
                }
            }

            return(dataPtr);
        }
Beispiel #36
0
 public Terminal(ITrayProcessCommunicationService trayProcessCommunicationService, byte?terminalId = null)
 {
     _trayProcessCommunicationService = trayProcessCommunicationService;
     _trayProcessCommunicationService.TerminalExited += OnTerminalExited;
     Id = terminalId ?? trayProcessCommunicationService.GetNextTerminalId();
     _requireShellProcessStart = !terminalId.HasValue;
 }
 public void Delete(byte?id)
 {
     _unitOfWork.ApplicationRepository.IsDeleteTrue(id);
     _unitOfWork.Save();
 }
Beispiel #38
0
 public override void WriteValue(byte?value)
 {
     _textWriter.WriteValue(value);
     _innerWriter.WriteValue(value);
     base.WriteValue(value);
 }
Beispiel #39
0
 static void FromUInt8()
 {
     Console.WriteLine("--- FromUInt8");
     byte?[] a = new byte?[] { new byte?(), new byte?(20), new byte?(30) };
     TestCore(a);
 }
Beispiel #40
0
 public void SetState(byte?value)
 {
     this.state_ = value;
 }
Beispiel #41
0
 public void SetCurrentStepState(byte?value)
 {
     this.currentStepState_ = value;
 }
Beispiel #42
0
 internal byte?NumberProperty(string propertyName, ref byte?output) => output       = this.NullableProperty <JsonNumber>(propertyName)?.ToByte() ?? null;
        private void WriteParameters(IEnumerable <IParameterDefinition> parameters, ITypeReference containingType, byte?methodNullableContextValue, bool property = false, bool extensionMethod = false, bool acceptsExtraArguments = false)
        {
            string start = property ? "[" : "(";
            string end   = property ? "]" : ")";

            WriteSymbol(start);
            _writer.WriteList(parameters, p =>
            {
                WriteParameter(p, containingType, extensionMethod, methodNullableContextValue);
                extensionMethod = false;
            });

            if (acceptsExtraArguments)
            {
                if (parameters.Any())
                {
                    _writer.WriteSymbol(",");
                }
                _writer.WriteSpace();
                _writer.Write("__arglist");
            }

            WriteSymbol(end);
        }
 public JsonResult GetApplication(byte?id)
 {
     return(new JsonResult {
         Data = _unitOfWork.ApplicationRepository.GetByID(id).ToApplicationView()
     });
 }
Beispiel #45
0
 /// <summary>
 ///
 /// Set AntDeviceType subfield</summary>
 /// <param name="antDeviceType">Subfield value to be set</param>
 public void SetAntDeviceType(byte?antDeviceType)
 {
     SetFieldValue(1, 0, antDeviceType, DeviceTypeSubfield.AntDeviceType);
 }
Beispiel #46
0
 /// <summary>
 /// Получает класс цвета для грида по коду типа транзакции.
 /// </summary>
 /// <param name="transactionKindID">Код транзакции.</param>
 /// <returns>Название класса.</returns>
 public static string GetTransactionKindRowClass(byte?transactionKindID)
 {
     return(transactionKindID == TransactionKindSet.Revenue.TransactionKindID ? GridRowColors.Success : GridRowColors.Warning);
 }
Beispiel #47
0
 /// <summary>
 /// Set DeviceIndex field</summary>
 /// <param name="deviceIndex_">Nullable field value to be set</param>
 public void SetDeviceIndex(byte?deviceIndex_)
 {
     SetFieldValue(0, 0, deviceIndex_, Fit.SubfieldIndexMainField);
 }
Beispiel #48
0
 private static object CovertFromJTokePrimitiveType(JToken keyValue, Type propertyInfoPropertyType)
 {
     if (propertyInfoPropertyType == typeof(string))
     {
         string value = (string)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(int) || propertyInfoPropertyType.IsEnum)
     {
         int value = (int)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(bool))
     {
         bool value = (bool)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(DateTimeOffset))
     {
         DateTimeOffset value = (DateTimeOffset)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(bool?))
     {
         bool?value = (bool?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(long))
     {
         long value = (long)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(DateTime))
     {
         DateTime value = (DateTime)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(DateTimeOffset?))
     {
         DateTimeOffset?value = (DateTimeOffset?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(DateTime?))
     {
         DateTime?value = (DateTime?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(decimal?))
     {
         decimal?value = (decimal?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(double?))
     {
         double?value = (double?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(char?))
     {
         char?value = (char?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(short))
     {
         short value = (short)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(ushort))
     {
         ushort value = (ushort)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(char))
     {
         char value = (char)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(byte))
     {
         byte value = (byte)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(int?))
     {
         int?value = (int?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(short?))
     {
         short?value = (short?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(ushort?))
     {
         ushort?value = (ushort?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(byte?))
     {
         byte?value = (byte?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(long?))
     {
         long?value = (long?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(float?))
     {
         float?value = (float?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(decimal))
     {
         decimal value = (decimal)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(uint?))
     {
         uint?value = (uint?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(ulong?))
     {
         ulong?value = (ulong?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(double))
     {
         double value = (double)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(float))
     {
         float value = (float)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(uint))
     {
         uint value = (uint)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(ulong))
     {
         ulong value = (ulong)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(byte[]))
     {
         byte[] value = (byte[])keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(Guid))
     {
         Guid value = (Guid)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(Guid?))
     {
         Guid?value = (Guid?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(TimeSpan?))
     {
         TimeSpan?value = (TimeSpan?)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(TimeSpan))
     {
         TimeSpan value = (TimeSpan)keyValue;
         return(value);
     }
     if (propertyInfoPropertyType == typeof(Uri))
     {
         Uri value = (Uri)keyValue;
         return(value);
     }
     return(null);
 }
        public void WriteTypeDeclaration(ITypeDefinition type)
        {
            INamedTypeDefinition namedType = (INamedTypeDefinition)type;

            WriteAttributes(type.Attributes);
            WriteAttributes(type.SecurityAttributes);

            //TODO: We should likely add support for the SerializableAttribute something like:
            // if (type.IsSerializable) WriteFakeAttribute("System.Serializable");
            // But we need also consider if this attribute is filtered out or not but I guess
            // we have the same problem with all the fake attributes at this point.

            if ((type.IsStruct || type.IsClass) && type.Layout != LayoutKind.Auto)
            {
                FakeCustomAttribute structLayout = new FakeCustomAttribute("System.Runtime.InteropServices", "StructLayoutAttribute");
                string layoutKind = string.Format("System.Runtime.InteropServices.LayoutKind.{0}", type.Layout.ToString());

                if (_forCompilationIncludeGlobalprefix)
                {
                    layoutKind = "global::" + layoutKind;
                }

                var args = new List <string>();
                args.Add(layoutKind);

                if (type.SizeOf != 0)
                {
                    string sizeOf = string.Format("Size={0}", type.SizeOf);
                    args.Add(sizeOf);
                }

                if (type.Alignment != 0)
                {
                    string pack = string.Format("Pack={0}", type.Alignment);
                    args.Add(pack);
                }

                if (type.StringFormat != StringFormatKind.Ansi)
                {
                    string charset = string.Format("CharSet={0}System.Runtime.InteropServices.CharSet.{1}", _forCompilationIncludeGlobalprefix ? "global::" : "", type.StringFormat);
                    args.Add(charset);
                }

                if (IncludeAttribute(structLayout))
                {
                    WriteFakeAttribute(structLayout.FullTypeName, args.ToArray());
                }
            }

            WriteVisibility(TypeHelper.TypeVisibilityAsTypeMemberVisibility(type));

            IMethodDefinition invoke = type.GetInvokeMethod();

            if (invoke != null)
            {
                Contract.Assert(type.IsDelegate);

                byte?nullableContextValue = invoke.Attributes.GetCustomAttributeArgumentValue <byte?>(CSharpCciExtensions.NullableContextAttributeFullName);
                if (invoke.IsMethodUnsafe())
                {
                    WriteKeyword("unsafe");
                }
                WriteKeyword("delegate");
                WriteTypeName(invoke.Type, invoke.ReturnValueAttributes, methodNullableContextValue: nullableContextValue);
                WriteIdentifier(namedType.Name);
                if (type.IsGeneric)
                {
                    WriteGenericParameters(type.GenericParameters);
                }
                WriteParameters(invoke.Parameters, invoke.ContainingType, nullableContextValue);
                if (type.IsGeneric)
                {
                    WriteGenericContraints(type.GenericParameters, TypeNullableContextValue);                 // Delegates are special, and the NullableContextValue we should fallback to is the delegate type one, not the invoke method one.
                }
                WriteSymbol(";");
            }
            else
            {
                WriteTypeModifiers(type);
                WriteIdentifier(namedType.Name);
                Contract.Assert(!(type is IGenericTypeInstance), "Currently don't support generic type instances if we hit this then add support");
                if (type.IsGeneric)
                {
                    WriteGenericParameters(type.GenericParameters);
                }
                WriteBaseTypes(type);
                if (type.IsGeneric)
                {
                    WriteGenericContraints(type.GenericParameters);
                }

                if (type.IsEnum)
                {
                    WriteEnumType(type);
                }
            }
        }
 /// <summary>
 /// Set HrmAntIdTransType field</summary>
 /// <param name="hrmAntIdTransType_">Nullable field value to be set</param>
 public void SetHrmAntIdTransType(byte?hrmAntIdTransType_)
 {
     SetFieldValue(3, 0, hrmAntIdTransType_, Fit.SubfieldIndexMainField);
 }
Beispiel #51
0
        private byte TCPIP_DNS_Q()
        {
            var flags = cpu.Registers.B;

            if (flags.GetBit(2) == 1 && dnsQueryInProgress)
            {
                return(ERR_QUERY_EXISTS);
            }
            if (flags.GetBit(0) == 1)
            {
                dnsQueryInProgress = false;
                lastDnsError       = 0;
                return(ERR_OK);
            }

            if (NoNetworkAvailable())
            {
                return(ERR_NO_NETWORK);
            }

            if (!dnsServersAvailable)
            {
                return(ERR_NO_DNS);
            }

            var namePointer = cpu.Registers.HL;
            var nameBytes   = new List <byte>();

            while (slots[namePointer] != 0)
            {
                nameBytes.Add(slots[namePointer++]);
            }
            var name = Encoding.ASCII.GetString(nameBytes.ToArray());

            var wasIp = IPAddress.TryParse(name, out IPAddress parsedIp) &&
                        IsIPv4(parsedIp);

            if (wasIp)
            {
                lastIpResolved            = parsedIp.GetAddressBytes();
                lastIpResolvedWasDirectIp = true;
                cpu.Registers.B           = 1;
                cpu.Registers.L           = lastIpResolved[0];
                cpu.Registers.H           = lastIpResolved[1];
                cpu.Registers.E           = lastIpResolved[2];
                cpu.Registers.D           = lastIpResolved[3];

                return(ERR_OK);
            }

            if (flags.GetBit(1) == 1)
            {
                return(ERR_INV_IP);
            }

            dnsQueryInProgress = true;
            Dns.BeginGetHostAddresses(name,
                                      ar =>
            {
                dnsQueryInProgress = false;
                IPAddress[] addresses;
                try
                {
                    addresses = Dns.EndGetHostAddresses(ar);
                }
                catch (Exception ex)
                {
                    if (ex is SocketException sockEx)
                    {
                        lastDnsError = UnapiDnsErrorFromSocketError(sockEx.SocketErrorCode);
                    }
                    else
                    {
                        lastDnsError = 0;
                    }

                    return;
                }
                var address               = addresses.FirstOrDefault(IsIPv4);
                lastIpResolved            = address?.GetAddressBytes();
                lastIpResolvedWasDirectIp = false;
                lastDnsError              = null;
            }
                                      , null);

            cpu.Registers.B = 0;
            return(ERR_OK);
        }
Beispiel #52
0
        private void SendDeviceCommand(DeviceCommand aDeviceCommand, bool aSecondPS2Port, byte?aByte = null)
        {
            mDebugger.SendInternal("(PS/2 Controller) Sending device command:");
            mDebugger.SendInternal("Device command:");
            mDebugger.SendInternal((byte)aDeviceCommand);

            if (aSecondPS2Port)
            {
                SendCommand(Command.WriteNextByteToSecondPS2PortInputBuffer);
            }

            WaitToWrite();
            IO.Data.Byte = (byte)aDeviceCommand;

            WaitForAck();

            mDebugger.SendInternal("Device command sent.");

            if (aByte.HasValue)
            {
                mDebugger.SendInternal("(PS/2 Controller) Sending byte after device command:");
                mDebugger.SendInternal("Byte value:");
                mDebugger.SendInternal(aByte.Value);

                if (aSecondPS2Port)
                {
                    SendCommand(Command.WriteNextByteToSecondPS2PortInputBuffer);
                }

                WaitToWrite();
                IO.Data.Byte = aByte.Value;

                WaitForAck();
            }
        }
 /// <summary>
 /// Set ConceptCount field</summary>
 /// <param name="conceptCount_">Nullable field value to be set</param>
 public void SetConceptCount(byte?conceptCount_)
 {
     SetFieldValue(3, 0, conceptCount_, Fit.SubfieldIndexMainField);
 }
Beispiel #54
0
 /// <summary>
 /// Set AntTransmissionType field</summary>
 /// <param name="antTransmissionType_">Nullable field value to be set</param>
 public void SetAntTransmissionType(byte?antTransmissionType_)
 {
     SetFieldValue(20, 0, antTransmissionType_, Fit.SubfieldIndexMainField);
 }
 /// <summary>
 /// Set FieldId field</summary>
 /// <param name="fieldId_">Nullable field value to be set</param>
 public void SetFieldId(byte?fieldId_)
 {
     SetFieldValue(2, 0, fieldId_, Fit.SubfieldIndexMainField);
 }
Beispiel #56
0
 /// <summary>
 /// Set BatteryStatus field</summary>
 /// <param name="batteryStatus_">Nullable field value to be set</param>
 public void SetBatteryStatus(byte?batteryStatus_)
 {
     SetFieldValue(11, 0, batteryStatus_, Fit.SubfieldIndexMainField);
 }
Beispiel #57
0
 public void SetControl(int index, byte?value)
 {
 }
Beispiel #58
0
 /// <summary>
 /// Set HardwareVersion field</summary>
 /// <param name="hardwareVersion_">Nullable field value to be set</param>
 public void SetHardwareVersion(byte?hardwareVersion_)
 {
     SetFieldValue(6, 0, hardwareVersion_, Fit.SubfieldIndexMainField);
 }
        private void WriteParameter(IParameterDefinition parameter, ITypeReference containingType, bool extensionMethod, byte?methodNullableContextValue)
        {
            WriteAttributes(parameter.Attributes, true);

            if (extensionMethod)
            {
                WriteKeyword("this");
            }

            if (parameter.IsParameterArray)
            {
                WriteKeyword("params");
            }

            if (parameter.IsOut && !parameter.IsIn && parameter.IsByReference)
            {
                WriteKeyword("out");
            }
            else
            {
                // For In/Out we should not emit them until we find a scenario that is needs them.
                //if (parameter.IsIn)
                //   WriteFakeAttribute("System.Runtime.InteropServices.In", writeInline: true);
                //if (parameter.IsOut)
                //    WriteFakeAttribute("System.Runtime.InteropServices.Out", writeInline: true);
                if (parameter.IsByReference)
                {
                    if (parameter.Attributes.HasIsReadOnlyAttribute())
                    {
                        WriteKeyword("in");
                    }
                    else
                    {
                        WriteKeyword("ref");
                    }
                }
            }

            WriteTypeName(parameter.Type, containingType, parameter.Attributes, methodNullableContextValue);
            WriteIdentifier(parameter.Name);
            if (parameter.IsOptional && parameter.HasDefaultValue)
            {
                WriteSymbol(" = ");
                WriteMetadataConstant(parameter.DefaultValue, parameter.Type);
            }
        }
Beispiel #60
0
 /// <summary>
 /// 获取byte?参数,默认defaultValue
 /// </summary>
 /// <param name="name">参数名</param>
 /// <param name="defaultValue">默认值</param>
 /// <returns>参数值</returns>
 public static byte?GetByteNull(string name, byte?defaultValue)
 {
     return(XCLNetTools.Common.DataTypeConvert.ToByteNull(FormHelper.GetString(name), defaultValue));
 }