public Reproduce(string children = null, double densityRadius = 10, int densityMax = 5, Cooldown coolDown = new Cooldown())
 {
     this.children = children == null ? null : (ushort?)BehaviorDb.InitGameData.IdToObjectType[children];
     this.densityRadius = densityRadius;
     this.densityMax = densityMax;
     this.coolDown = coolDown.Normalize(60000);
 }
Exemple #2
0
 internal Color(byte red, byte green, byte blue)
 {
     Red = red;
     Green = green;
     Blue = blue;
     Id = null;
 }
Exemple #3
0
 public PPacket(Packet packet, long packetNumber, TimeSpan relativeTime)
 {
     _packet = packet;
     _packetNumber = packetNumber;
     _relativeTime = relativeTime;
     EthernetDatagram ethernet = packet.Ethernet;
     if (ethernet != null)
     {
         _ethernetType = ethernet.EtherType;
         _ethernetTypeCode = GetEthernetTypeCode(ethernet.EtherType);
         //_ipv4 = packet.Ethernet.IpV4;
         //if (_ipv4 != null)
         if (ethernet.EtherType == PcapDotNet.Packets.Ethernet.EthernetType.IpV4)
         {
             _ipv4 = packet.Ethernet.IpV4;
             _source = _ipv4.Source;
             _destination = _ipv4.Destination;
             _ipProtocol = _ipv4.Protocol;
             _ipProtocolCode = GetIPProtocolCode(_ipv4.Protocol);
             //_tcp = _ipv4.Tcp;
             //if (_tcp != null)
             if (_ipv4.Protocol == IpV4Protocol.Tcp)
             {
                 _tcp = _ipv4.Tcp;
                 _sourcePort = _tcp.SourcePort;
                 _destinationPort = _tcp.DestinationPort;
             }
         }
     }
 }
Exemple #4
0
 public Battery()
 {
     this.model = null;
     this.hoursIdle = null;
     this.hoursTalk = null;
     this.type = null;
 }
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     teamIdField = packet.TeamScoreList[e.RowIndex].TeamId;
     playerNameField = textBox1.Text;
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemple #6
0
        //        private const ushort DEFAULT_LINE_COLOUR_INDEX = 8;
        internal XF(XlsDocument doc)
        {
            _doc = doc;

            _id = null;

            SetDefaults();
        }
 public static void CheckUnaryDecrementNullableUShortTest(bool useInterpreter)
 {
     ushort?[] values = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyDecrementNullableUShort(values[i], useInterpreter);
     }
 }
 public static void CheckUnaryIncrementNullableUShortTest()
 {
     ushort?[] values = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         VerifyIncrementNullableUShort(values[i]);
     }
 }
Exemple #9
0
 public ushort GetValue()
 {
     if (!_value.HasValue)
     {
         _value = Source.GetValue();
     }
     return _value.Value;
 }
Exemple #10
0
    public override void Clear() {
      this.Index_    = null;
      this.Text_     = null;
#if IncludeUnknownFields
      this.Unknown1_ = null;
      this.Unknown2_ = null;
      this.Unknown3_ = null;
#endif
    }
Exemple #11
0
        public GSM(string model, string manufacturer)
        {
            this.Model = model;
            this.Manufacturer = manufacturer;

            this.price = null;
            this.owner = null;
            this.batteryCharacteristics = new Battery();
            this.displayCharacteristics = new Display();
        }
 private void Clear()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity = null;
     m_targetCube = Vector3I.Zero;
     m_targetPosition = Vector3D.Zero;
     m_targetInVoxelCoord = Vector3I.Zero;
     m_compoundId = null;
     m_targetTreeId = 0;
 }
 public Orbit(double speed, double radius, double acquireRange = 10,
     string target = null, double? speedVariance = null, double? radiusVariance = null)
 {
     this.speed = (float) speed;
     this.radius = (float) radius;
     this.acquireRange = (float) acquireRange;
     this.target = target == null ? null : (ushort?) BehaviorDb.InitGameData.IdToObjectType[target];
     this.speedVariance = (float) (speedVariance ?? speed*0.1);
     this.radiusVariance = (float) (radiusVariance ?? speed*0.1);
 }
Exemple #14
0
        public ushort GetSignalValue()
        {
            // We have to cache the value otherwise it is unbelievably slow
            if (_inputSignalValue == null)
            {
                _inputSignalValue = _input.GetSignalValue();
            }

            return _inputSignalValue.Value;
        }
Exemple #15
0
        internal Font(XlsDocument doc)
        {
            _isInitializing = true;

            _doc = doc;
            _id = null;

            SetDefaults();

            _isInitializing = false;
        }
 public static void CheckNullableUShortAndTest(bool useInterpreter)
 {
     ushort?[] array = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < array.Length; i++)
     {
         for (int j = 0; j < array.Length; j++)
         {
             VerifyNullableUShortAnd(array[i], array[j], useInterpreter);
         }
     }
 }
Exemple #17
0
 public override void Clear()
 {
     this.ID_           = null;
       this.Type_         = null;
       this.ListIconID_   = null;
       this.MPCost_       = null;
       this.Unknown1_     = null;
       this.ValidTargets_ = null;
       this.Name_         = null;
       this.Description_  = null;
 }
 public static void CheckNullableUShortPowerTest()
 {
     ushort?[] array = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < array.Length; i++)
     {
         for (int j = 0; j < array.Length; j++)
         {
             VerifyNullableUShortPower(array[i], array[j]);
         }
     }
 }
Exemple #19
0
 public override void Clear()
 {
     this.ID_            = null;
       this.Type_          = null;
       this.ListIconID_    = null;
       this.MPCost_        = null;
       this.SharedTimerID_ = null;
       this.ValidTargets_  = null;
       this.TPCost_        = null;
       this.CategoryID_    = null;
       this.Unknown1_      = null;
 }
        private void btnJoin_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                int index = dataGridView1.SelectedRows[0].Index;

                teamIdField = packet.TeamScoreList[index].TeamId;
                playerNameField = textBox1.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #21
0
 public override void Clear()
 {
     if (this.Icon_ != null)
     {
         this.Icon_.Clear();
     }
     this.ID_ = null;
     this.Description_ = null;
     this.Unknown1_ = null;
     this.Unknown2_ = null;
     this.Unknown3_ = null;
     this.Unknown4_ = null;
     this.Unknown5_ = null;
 }
Exemple #22
0
		public ModuleOptions(ModuleDef module) {
			Mvid = module.Mvid;
			EncId = module.EncId;
			EncBaseId = module.EncBaseId;
			Name = module.Name;
			Kind = module.Kind;
			Characteristics = module.Characteristics;
			DllCharacteristics = module.DllCharacteristics;
			RuntimeVersion = module.RuntimeVersion;
			Machine = module.Machine;
			Cor20HeaderFlags = module.Cor20HeaderFlags;
			Cor20HeaderRuntimeVersion = module.Cor20HeaderRuntimeVersion;
			TablesHeaderVersion = module.TablesHeaderVersion;
			ManagedEntryPoint = module.ManagedEntryPoint;
			NativeEntryPoint = module.NativeEntryPoint;
			CustomAttributes.AddRange(module.CustomAttributes);
		}
Exemple #23
0
 public override void Clear()
 {
     this.Index_               = null;
       this.MagicType_           = null;
       this.Element_             = null;
       this.ValidTargets_        = null;
       this.Skill_               = null;
       this.MPCost_              = null;
       this.CastingTime_         = null;
       this.RecastDelay_         = null;
       this.LevelRequired_       = null;
       this.ID_                  = null;
       this.ListIconID_          = null;
       this.JapaneseName_        = null;
       this.EnglishName_         = null;
       this.JapaneseDescription_ = null;
       this.EnglishDescription_  = null;
 }
Exemple #24
0
 public override sealed void Clear()
 {
     Index_ = null;
     MagicType_ = null;
     Element_ = null;
     ValidTargets_ = null;
     Skill_ = null;
     MPCost_ = null;
     CastingTime_ = null;
     RecastDelay_ = null;
     LevelRequired_ = null;
     ID_ = null;
     ListIconID_ = null;
     Unknown1_ = null;
     Unknown2_ = null;
     Unknown3_ = null;
     Unknown4_ = null;
 }
Exemple #25
0
 public override void Clear()
 {
     this.Index_ = null;
     this.MagicType_ = null;
     this.Element_ = null;
     this.ValidTargets_ = null;
     this.Skill_ = null;
     this.MPCost_ = null;
     this.CastingTime_ = null;
     this.RecastDelay_ = null;
     this.LevelRequired_ = null;
     this.ID_ = null;
     this.ListIconID_ = null;
     this.Unknown1_ = null;
     this.Unknown2_ = null;
     //            this.Unknown3_ = null;
     //            this.Unknown4_ = null;
 }
Exemple #26
0
		public TypeDefOptions(TypeDef type) {
			this.Attributes = type.Attributes;
			this.Namespace = type.Namespace;
			this.Name = type.Name;
			if (type.ClassLayout == null) {
				PackingSize = null;
				ClassSize = null;
			}
			else {
				PackingSize = type.ClassLayout.PackingSize;
				ClassSize = type.ClassLayout.ClassSize;
			}
			this.BaseType = type.BaseType;
			this.CustomAttributes.AddRange(type.CustomAttributes);
			this.DeclSecurities.AddRange(type.DeclSecurities);
			this.GenericParameters.AddRange(type.GenericParameters);
			this.Interfaces.AddRange(type.Interfaces);
		}
 public static void Update(GameTime Time)
 {
     UpdateFramesPerSecond = (1/(float) Time.ElapsedGameTime.TotalSeconds);
     if (UpdateFramesPerSecondBuffer != null)
     {
         UpdateFramesPerSecondBuffer[
             (UpdateFramesPerSecondBufferIndex ?? (UpdateFramesPerSecondBuffer.Length - 1))] =
             UpdateFramesPerSecond;
         if (UpdateFramesPerSecondBufferIndex == null) UpdateFramesPerSecondBufferIndex = 0;
         else
         {
             if (UpdateFramesPerSecondBufferIndex >= (UpdateFramesPerSecondBuffer.Length - 1))
                 UpdateFramesPerSecondBufferIndex = null;
             else UpdateFramesPerSecondBufferIndex++;
         }
         if (UpdateFramesPerSecondBufferRecorded < UpdateFramesPerSecondBuffer.Length)
             UpdateFramesPerSecondBufferRecorded++;
     }
 }
Exemple #28
0
 /// <summary>
 ///
 /// Set GarminProduct subfield</summary>
 /// <param name="garminProduct">Subfield value to be set</param>
 public void SetGarminProduct(ushort?garminProduct)
 {
     SetFieldValue(1, 0, garminProduct, ProductSubfield.GarminProduct);
 }
Exemple #29
0
        public static IFieldPredicate LessThanOrEqual <T>(Expression <Func <T, ushort?> > expression, ushort?value) where T : class
        {
            PropertyInfo propertyInfo = ReflectionHelper.GetProperty(expression) as PropertyInfo;

            return(Field <T>(propertyInfo.Name, Operator.LessThanOrEqual, value));
        }
Exemple #30
0
 /// <summary>
 /// Set UserProfileIndex field
 /// Comment: Associates this weight scale message to a user.  This corresponds to the index of the user profile message in the weight scale file.</summary>
 /// <param name="userProfileIndex_">Nullable field value to be set</param>
 public void SetUserProfileIndex(ushort?userProfileIndex_)
 {
     SetFieldValue(12, 0, userProfileIndex_, Fit.SubfieldIndexMainField);
 }
Exemple #31
0
 static void FromUInt16()
 {
     Console.WriteLine("--- FromUInt16");
     ushort?[] a = new ushort?[] { new ushort?(), new ushort?(20), new ushort?(30) };
     TestCore(a);
 }
 public static void CheckNonLiftedComparisonEqualNullableUShortTest(bool useInterpreter)
 {
     ushort?[] values = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyComparisonEqualNullableUShort(values[i], values[j], useInterpreter);
         }
     }
 }
Exemple #33
0
        public void UInt16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort?value, bool expected)
        {
            IValitResult result = ValitRules <Model>
                                  .Create()
                                  .Ensure(m => m.Value, _ => _
                                          .IsEqualTo(value))
                                  .For(_model)
                                  .Validate();

            result.Succeeded.ShouldBe(expected);
        }
Exemple #34
0
 /// <summary>
 /// Set Number field
 /// Comment: Only set for files that are not created/erased.</summary>
 /// <param name="number_">Nullable field value to be set</param>
 public void SetNumber(ushort?number_)
 {
     SetFieldValue(5, 0, number_, Fit.SubfieldIndexMainField);
 }
Exemple #35
0
 /// <summary>
 /// Set MessageIndex field</summary>
 /// <param name="messageIndex_">Nullable field value to be set</param>
 public void SetMessageIndex(ushort?messageIndex_)
 {
     SetFieldValue(254, 0, messageIndex_, Fit.SubfieldIndexMainField);
 }
Exemple #36
0
 public void UpdateRP(short nRouteTag, int nRP, int?nTripNo = null, ushort?nServiceStart = null, bool bSignalPriority = false)
 {
     UpdateRP(new TripStatus(nRouteTag, nRP, nTripNo, nServiceStart, bSignalPriority));
 }
        private void UpdateHitEntity()
        {
            m_closestHitDistSq    = float.MaxValue;
            m_hitPos              = new Vector3(0.0f, 0.0f, 0.0f);
            m_hitNormal           = new Vector3(1.0f, 0.0f, 0.0f);
            m_hitEntity           = null;
            m_addPos              = Vector3I.Zero;
            RemoveBlock           = null;
            BlockIdInCompound     = null;
            m_dynamicBuildAllowed = false;

            if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static.Battle)
            {
                m_visible = false;
                return;
            }

            if (MyCubeBuilder.Static.DynamicMode)
            {
                m_visible = true;
                return;
            }

            MatrixD pasteMatrix = GetPasteMatrix();

            Vector3? addPosSmallOnLarge;
            Vector3I addDir;
            Vector3I removePos;

            if (MyCubeBuilder.Static.CurrentGrid == null && MyCubeBuilder.Static.CurrentVoxelMap == null)
            {
                MyCubeBuilder.Static.ChoosePlacementObject();
            }

            if (MyCubeBuilder.Static.HitInfo.HasValue)
            {
                float      gridSize = MyDefinitionManager.Static.GetCubeSize(CopiedGrids[0].GridSizeEnum);
                MyCubeGrid hitGrid  = MyCubeBuilder.Static.HitInfo.Value.HkHitInfo.GetHitEntity() as MyCubeGrid;
                bool       placingSmallGridOnLargeStatic = hitGrid != null && hitGrid.IsStatic && hitGrid.GridSizeEnum == MyCubeSize.Large && CopiedGrids[0].GridSizeEnum == MyCubeSize.Small && MyFakes.ENABLE_STATIC_SMALL_GRID_ON_LARGE;

                bool add = MyCubeBuilder.Static.GetAddAndRemovePositions(gridSize, placingSmallGridOnLargeStatic, out m_addPos, out addPosSmallOnLarge, out addDir, out removePos, out RemoveBlock, out BlockIdInCompound);
                if (add)
                {
                    if (RemoveBlock != null)
                    {
                        m_hitPos           = MyCubeBuilder.Static.HitInfo.Value.Position;
                        m_closestHitDistSq = (float)(m_hitPos - pasteMatrix.Translation).LengthSquared();
                        m_hitNormal        = addDir;
                        m_hitEntity        = RemoveBlock.CubeGrid;

                        double cubeSizeTarget = MyDefinitionManager.Static.GetCubeSize(RemoveBlock.CubeGrid.GridSizeEnum);
                        double cubeSizeCopied = MyDefinitionManager.Static.GetCubeSize(CopiedGrids[0].GridSizeEnum);
                        if ((cubeSizeTarget / cubeSizeCopied) < 1)
                        {
                            RemoveBlock = null;
                        }

                        m_visible = RemoveBlock != null;
                    }
                    else if (MyFakes.ENABLE_BLOCK_PLACEMENT_ON_VOXEL && MyCubeBuilder.Static.HitInfo.Value.HkHitInfo.GetHitEntity() is MyVoxelMap)
                    {
                        m_hitPos           = MyCubeBuilder.Static.HitInfo.Value.Position;
                        m_closestHitDistSq = (float)(m_hitPos - pasteMatrix.Translation).LengthSquared();
                        m_hitNormal        = addDir;
                        m_hitEntity        = MyCubeBuilder.Static.HitInfo.Value.HkHitInfo.GetHitEntity() as MyVoxelMap;

                        m_visible = true;
                    }
                    else
                    {
                        m_visible = false;
                    }
                }
                else
                {
                    m_visible = false;
                }
            }
            else
            {
                m_visible = false;
            }
        }
Exemple #38
0
 /// <summary>
 /// Set Manufacturer field</summary>
 /// <param name="manufacturer_">Nullable field value to be set</param>
 public void SetManufacturer(ushort?manufacturer_)
 {
     SetFieldValue(0, 0, manufacturer_, Fit.SubfieldIndexMainField);
 }
Exemple #39
0
 public static NullableNumericAssertions <ushort> Should(this ushort?actualValue)
 {
     return(new NullableNumericAssertions <ushort>(actualValue));
 }
Exemple #40
0
 /// <summary>
 /// Set NumValidSteps field
 /// Comment: number of valid steps</summary>
 /// <param name="numValidSteps_">Nullable field value to be set</param>
 public void SetNumValidSteps(ushort?numValidSteps_)
 {
     SetFieldValue(6, 0, numValidSteps_, Fit.SubfieldIndexMainField);
 }
Exemple #41
0
 public static Entity GetNearestEntity(this Entity entity, double dist, ushort?objType)    //Null for player
 {
     return(entity.GetNearestEntities(dist, objType).FirstOrDefault());
 }
Exemple #42
0
        public virtual void Can_query_with_null_parameters_using_any_nullable_data_type()
        {
            using (var context = CreateContext())
            {
                context.Set <BuiltInNullableDataTypes>().Add(
                    new BuiltInNullableDataTypes
                {
                    Id = 711,
                });

                Assert.Equal(1, context.SaveChanges());
            }

            using (var context = CreateContext())
            {
                var entity = context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711);

                short?param1 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableInt16 == param1));
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && ((long?)((int?)(e.TestNullableInt16))) == param1));

                int?param2 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableInt32 == param2));

                long?param3 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableInt64 == param3));

                double?param4 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableDouble == param4));

                decimal?param5 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableDecimal == param5));

                DateTime?param6 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableDateTime == param6));

                DateTimeOffset?param7 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableDateTimeOffset == param7));

                TimeSpan?param8 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableTimeSpan == param8));

                float?param9 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableSingle == param9));

                bool?param10 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableBoolean == param10));

                byte?param11 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableByte == param11));

                Enum64?param12 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.Enum64 == param12));

                Enum32?param13 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.Enum32 == param13));

                Enum16?param14 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.Enum16 == param14));

                Enum8?param15 = null;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.Enum8 == param15));

                var entityType = context.Model.GetEntityType(typeof(BuiltInNullableDataTypes));
                if (entityType.FindProperty("TestUnsignedInt16") != null)
                {
                    ushort?param16 = null;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableUnsignedInt16 == param16));
                }

                if (entityType.FindProperty("TestUnsignedInt32") != null)
                {
                    uint?param17 = null;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableUnsignedInt32 == param17));
                }

                if (entityType.FindProperty("TestUnsignedInt64") != null)
                {
                    ulong?param18 = null;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableUnsignedInt64 == param18));
                }

                if (entityType.FindProperty("TestCharacter") != null)
                {
                    char?param19 = null;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableCharacter == param19));
                }

                if (entityType.FindProperty("TestSignedByte") != null)
                {
                    sbyte?param20 = null;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 711 && e.TestNullableSignedByte == param20));
                }
            }
        }
Exemple #43
0
 /// <summary>
 /// Set Product field</summary>
 /// <param name="product_">Nullable field value to be set</param>
 public void SetProduct(ushort?product_)
 {
     SetFieldValue(1, 0, product_, Fit.SubfieldIndexMainField);
 }
Exemple #44
0
        public virtual void Can_query_using_any_nullable_data_type()
        {
            using (var context = CreateContext())
            {
                context.Set <BuiltInNullableDataTypes>().Add(
                    new BuiltInNullableDataTypes
                {
                    Id                         = 11,
                    PartitionId                = 1,
                    TestNullableInt16          = -1234,
                    TestNullableInt32          = -123456789,
                    TestNullableInt64          = -1234567890123456789L,
                    TestNullableDouble         = -1.23456789,
                    TestNullableDecimal        = -1234567890.01M,
                    TestNullableDateTime       = Fixture.DefaultDateTime,
                    TestNullableDateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)),
                    TestNullableTimeSpan       = new TimeSpan(0, 10, 9, 8, 7),
                    TestNullableSingle         = -1.234F,
                    TestNullableBoolean        = true,
                    TestNullableByte           = 255,
                    TestNullableUnsignedInt16  = 1234,
                    TestNullableUnsignedInt32  = 1234565789U,
                    TestNullableUnsignedInt64  = 1234567890123456789UL,
                    TestNullableCharacter      = 'a',
                    TestNullableSignedByte     = -128,
                    Enum64                     = Enum64.SomeValue,
                    Enum32                     = Enum32.SomeValue,
                    Enum16                     = Enum16.SomeValue,
                    Enum8                      = Enum8.SomeValue
                });

                Assert.Equal(1, context.SaveChanges());
            }

            using (var context = CreateContext())
            {
                var entity     = context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11);
                var entityType = context.Model.GetEntityType(typeof(BuiltInNullableDataTypes));

                short?param1 = -1234;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableInt16 == param1));

                int?param2 = -123456789;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableInt32 == param2));

                long?param3 = -1234567890123456789L;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableInt64 == param3));

                double?param4 = -1.23456789;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableDouble == param4));

                decimal?param5 = -1234567890.01M;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableDecimal == param5));

                DateTime?param6 = Fixture.DefaultDateTime;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableDateTime == param6));

                if (entityType.FindProperty("TestNullableDateTimeOffset") != null)
                {
                    DateTimeOffset?param7 = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0));
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableDateTimeOffset == param7));
                }

                if (entityType.FindProperty("TestNullableTimeSpan") != null)
                {
                    TimeSpan?param8 = new TimeSpan(0, 10, 9, 8, 7);
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableTimeSpan == param8));
                }

                float?param9 = -1.234F;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableSingle == param9));

                bool?param10 = true;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableBoolean == param10));

                if (entityType.FindProperty("TestNullableByte") != null)
                {
                    byte?param11 = 255;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableByte == param11));
                }

                Enum64?param12 = Enum64.SomeValue;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.Enum64 == param12));

                Enum32?param13 = Enum32.SomeValue;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.Enum32 == param13));

                Enum16?param14 = Enum16.SomeValue;
                Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.Enum16 == param14));

                if (entityType.FindProperty("Enum8") != null)
                {
                    Enum8?param15 = Enum8.SomeValue;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.Enum8 == param15));
                }

                if (entityType.FindProperty("TestUnsignedInt16") != null)
                {
                    ushort?param16 = 1234;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableUnsignedInt16 == param16));
                }

                if (entityType.FindProperty("TestUnsignedInt32") != null)
                {
                    uint?param17 = 1234565789U;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableUnsignedInt32 == param17));
                }

                if (entityType.FindProperty("TestUnsignedInt64") != null)
                {
                    ulong?param18 = 1234567890123456789UL;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableUnsignedInt64 == param18));
                }

                if (entityType.FindProperty("TestCharacter") != null)
                {
                    char?param19 = 'a';
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableCharacter == param19));
                }

                if (entityType.FindProperty("TestSignedByte") != null)
                {
                    sbyte?param20 = -128;
                    Assert.Same(entity, context.Set <BuiltInNullableDataTypes>().Single(e => e.Id == 11 && e.TestNullableSignedByte == param20));
                }
            }
        }
Exemple #45
0
        private void OnChange()
        {
            if (_isInitializing)
                return;

            _id = null;
            _id = ID;
            _target.OnFontChange(this);
        }
        public async Task Run(
            bool noMiner = false,
            [Option("app-protocol-version", new[] { 'V' }, Description = "App protocol version token")]
            string appProtocolVersionToken = null,
            [Option('G')]
            string genesisBlockPath = null,
            [Option('H')]
            string host = null,
            [Option('P')]
            ushort?port = null,
            [Option('D')]
            int minimumDifficulty = 5000000,
            [Option("private-key")]
            string privateKeyString = null,
            string storeType        = null,
            string storePath        = null,
            [Option("ice-server", new [] { 'I', })]
            string[] iceServerStrings = null,
            [Option("peer")]
            string[] peerStrings = null,
            [Option("trusted-app-protocol-version-signer", new[] { 'T' },
                    Description = "Trustworthy signers who claim new app protocol versions")]
            string[] trustedAppProtocolVersionSigners = null,
            bool rpcServer       = false,
            string rpcListenHost = "0.0.0.0",
            int?rpcListenPort    = null,
            [Option("graphql-server")]
            bool graphQLServer = false,
            [Option("graphql-host")]
            string graphQLHost = "0.0.0.0",
            [Option("graphql-port")]
            int?graphQLPort = null,
            [Option("libplanet-node")]
            bool libplanetNode = false,
            [Option("workers", Description = "Number of workers to use in Swarm")]
            int workers = 5,
            [Option(
                 "confirmations",
                 Description =
                     "The number of required confirmations to recognize a block.  0 by default."
                 )]
            int confirmations = 0,
            [Option(
                 "max-transactions",
                 Description =
                     "The number of maximum transactions can be included in a single block. " +
                     "Unlimited if the value is less then or equal to 0.  100 by default."
                 )]
            int maximumTransactions = 100,
            [Option("strict-rendering", Description = "Flag to turn on validating action renderer.")]
            bool strictRendering = false,
            [Option("dev", Description = "Flag to turn on the dev mode.  false by default.")]
            bool isDev = false,
            [Option(
                 "dev.block-interval",
                 Description =
                     "The time interval between blocks. It's unit is milliseconds. Works only when dev mode is on.  10000 (ms) by default.")]
            int blockInterval = 10000,
            [Option(
                 "dev.reorg-interval",
                 Description =
                     "The size of reorg interval. Works only when dev mode is on.  0 by default.")]
            int reorgInterval = 0,
            [Option(Description = "The log minimum level during headless execution.  debug by default.")]
            string logMinimumLevel = "debug",
            [Option(Description = "The Cognito identity for AWS CloudWatch logging.")]
            string awsCognitoIdentity = null,
            [Option(Description = "The access key for AWS CloudWatch logging.")]
            string awsAccessKey = null,
            [Option(Description = "The secret key for AWS CloudWatch logging.")]
            string awsSecretKey = null,
            [Option(Description = "The AWS region for AWS CloudWatch (e.g., us-east-1, ap-northeast-2).")]
            string awsRegion = null
            )
        {
#if SENTRY || !DEBUG
            try
            {
#endif

            // Setup logger.
            var loggerConf = new LoggerConfiguration()
                             .WriteTo.Console(outputTemplate: LogTemplate)
                             .ConfigureMinimumLevel(logMinimumLevel);
#if SENTRY || !DEBUG
            loggerConf = loggerConf
                         .WriteTo.Sentry(o =>
            {
                o.InitializeSdk = false;
            });
#endif
            bool useBasicAwsCredentials = !(awsAccessKey is null) && !(awsSecretKey is null);
            bool useCognitoCredentials  = !(awsCognitoIdentity is null);
            if (useBasicAwsCredentials && useCognitoCredentials)
            {
                const string message =
                    "You must choose to use only one credential between basic credential " +
                    "(i.e., --aws-access-key, --aws-secret-key) and " +
                    "Cognito credential (i.e., --aws-cognito-identity).";
                throw new CommandExitedException(message, -1);
            }

            if (useBasicAwsCredentials ^ useCognitoCredentials && !(awsRegion is null))
            {
                var            regionEndpoint = RegionEndpoint.GetBySystemName(awsRegion);
                AWSCredentials credentials    = useCognitoCredentials
                    ? (AWSCredentials) new CognitoAWSCredentials(awsCognitoIdentity, regionEndpoint)
                    : (AWSCredentials) new BasicAWSCredentials(awsAccessKey, awsSecretKey);

                var guid = LoadAWSSinkGuid() ?? Guid.NewGuid();
                StoreAWSSinkGuid(guid);

                var awsSink = new AWSSink(
                    credentials,
                    regionEndpoint,
                    "9c-standalone-logs",
                    guid.ToString());
                loggerConf.WriteTo.Sink(awsSink);
            }

            Log.Logger = loggerConf.CreateLogger();

            if (!graphQLServer && !libplanetNode)
            {
                throw new CommandExitedException(
                          "Either --graphql-server or --libplanet-node must be present.",
                          -1
                          );
            }

            var tasks = new List <Task>();
            try
            {
                IHostBuilder graphQLHostBuilder = Host.CreateDefaultBuilder();

                var standaloneContext = new StandaloneContext
                {
                    KeyStore = Web3KeyStore.DefaultKeyStore,
                };

                if (graphQLServer)
                {
                    var graphQLNodeServiceProperties = new GraphQLNodeServiceProperties
                    {
                        GraphQLServer     = graphQLServer,
                        GraphQLListenHost = graphQLHost,
                        GraphQLListenPort = graphQLPort,
                    };


                    var graphQLService = new GraphQLService(graphQLNodeServiceProperties);
                    graphQLHostBuilder =
                        graphQLService.Configure(graphQLHostBuilder, standaloneContext);
                    tasks.Add(graphQLHostBuilder.RunConsoleAsync(Context.CancellationToken));

                    await WaitForGraphQLService(graphQLNodeServiceProperties,
                                                Context.CancellationToken);
                }

                if (appProtocolVersionToken is null)
                {
                    throw new CommandExitedException(
                              "--app-protocol-version must be present.",
                              -1
                              );
                }

                if (genesisBlockPath is null)
                {
                    throw new CommandExitedException(
                              "--genesis-block-path must be present.",
                              -1
                              );
                }

                RpcNodeServiceProperties?rpcProperties = null;
                var properties = NineChroniclesNodeServiceProperties
                                 .GenerateLibplanetNodeServiceProperties(
                    appProtocolVersionToken,
                    genesisBlockPath,
                    host,
                    port,
                    minimumDifficulty,
                    privateKeyString,
                    storeType,
                    storePath,
                    100,
                    iceServerStrings,
                    peerStrings,
                    trustedAppProtocolVersionSigners,
                    noMiner,
                    workers: workers,
                    confirmations: confirmations,
                    maximumTransactions: maximumTransactions);


                if (rpcServer)
                {
                    rpcProperties = NineChroniclesNodeServiceProperties
                                    .GenerateRpcNodeServiceProperties(rpcListenHost, rpcListenPort);
                    properties.Render = true;
                }

                var nineChroniclesProperties = new NineChroniclesNodeServiceProperties()
                {
                    Rpc       = rpcProperties,
                    Libplanet = properties
                };

                NineChroniclesNodeService nineChroniclesNodeService =
                    StandaloneServices.CreateHeadless(
                        nineChroniclesProperties,
                        standaloneContext,
                        strictRendering: strictRendering,
                        isDev: isDev,
                        blockInterval: blockInterval,
                        reorgInterval: reorgInterval);
                standaloneContext.NineChroniclesNodeService = nineChroniclesNodeService;

                if (libplanetNode)
                {
                    if (!properties.NoMiner)
                    {
                        nineChroniclesNodeService.PrivateKey = properties.PrivateKey;
                        nineChroniclesNodeService.StartMining();
                    }

                    IHostBuilder nineChroniclesNodeHostBuilder = Host.CreateDefaultBuilder();
                    nineChroniclesNodeHostBuilder =
                        nineChroniclesNodeService.Configure(nineChroniclesNodeHostBuilder);
                    tasks.Add(
                        nineChroniclesNodeHostBuilder.RunConsoleAsync(Context.CancellationToken));
                }

                await Task.WhenAll(tasks);
            }
            catch (TaskCanceledException)
            {
                Log.Information("Terminated by the cancellation.");
            }
            catch (Exception e)
            {
                Log.Error(e, "Unexpected exception occurred during Run. {e}", e);
            }

#if SENTRY || !DEBUG
        }

        catch (CommandExitedException)
        {
            throw;
        }
        catch (Exception exceptionToCapture)
        {
            SentrySdk.CaptureException(exceptionToCapture);
            throw;
        }
#endif
        }
Exemple #47
0
        /// <summary>
        /// Records fixup information
        /// </summary>
        /// <param name="opLine">The operation line</param>
        /// <param name="type">Fixup type</param>
        /// <param name="expression">Fixup expression</param>
        /// <param name="label">Optional EQU label</param>
        /// <param name="structeBytes">Optional structure bytes</param>
        /// <param name="offset">Fixup offset, if not the current position</param>
        private void RecordFixup(SourceLineBase opLine, FixupType type, ExpressionNode expression,
                                 string label = null, Dictionary <ushort, byte> structeBytes = null, ushort?offset = null)
        {
            var fixupOffset = CurrentSegment.CurrentOffset;

            // --- Translate field invocation fixups so that field-related fixups will be
            // --- processed only after other fixups.
            if (IsInStructInvocation)
            {
                fixupOffset = _currentStructStartOffset + _currentStructOffset;
                if (type == FixupType.Bit8)
                {
                    type = FixupType.FieldBit8;
                }
                else if (type == FixupType.Bit16)
                {
                    type = FixupType.FieldBit16;
                }
            }

            // --- Create to fixup entry to resolve
            var fixup = new FixupEntry(this, CurrentModule, opLine, type, Output.Segments.Count - 1,
                                       offset ?? fixupOffset,
                                       expression, label, structeBytes);

            // --- Record fixups in every local scope up to the root
            foreach (var scope in CurrentModule.LocalScopes)
            {
                scope.Fixups.Add(fixup);
            }

            // --- Record fixup in every module up to the root
            var currentModule = CurrentModule;

            while (currentModule != null)
            {
                currentModule.Fixups.Add(fixup);
                currentModule = currentModule.ParentModule;
            }
        }
 internal static object NullCheck(ushort?value)
 {
     return(value ?? (object)DBNull.Value);
 }
 public virtual void MethodWithOptionalNonDefaultNullableUnsignedShortParameter(
     ushort?s = 3
     )
 {
 }
 public static void CheckLiftedAddNullableUShortTest()
 {
     ushort?[] values = new ushort?[] { null, 0, 1, ushort.MaxValue };
     for (int i = 0; i < values.Length; i++)
     {
         for (int j = 0; j < values.Length; j++)
         {
             VerifyAddNullableUShort(values[i], values[j]);
         }
     }
 }
 public virtual void MethodWithOptionalNullableUnsignedShortParameter(ushort?s = null)
 {
 }
Exemple #52
0
 public static IEnumerable <Entity> GetNearestEntities(this Entity entity, double dist, ushort?objType)   //Null for player
 {
     if (entity.Owner == null)
     {
         yield break;
     }
     if (objType == null)
     {
         foreach (var i in entity.Owner.PlayersCollision.HitTest(entity.X, entity.Y, dist))
         {
             if (!(i as IPlayer).IsVisibleToEnemy())
             {
                 continue;
             }
             var d = i.Dist(entity);
             if (d < dist)
             {
                 yield return(i);
             }
         }
     }
     else
     {
         foreach (var i in entity.Owner.EnemiesCollision.HitTest(entity.X, entity.Y, dist))
         {
             if (i.ObjectType != objType.Value)
             {
                 continue;
             }
             var d = i.Dist(entity);
             if (d < dist)
             {
                 yield return(i);
             }
         }
     }
 }
Exemple #53
0
 internal Symbol(string Name, ushort?Value, string Comment = null)
     : base(GetText(Name, Value), Comment)
 {
     this.Name  = Name;
     this.Value = Value;
 }
Exemple #54
0
 /// <summary>
 ///
 /// Set FaveroProduct subfield</summary>
 /// <param name="faveroProduct">Subfield value to be set</param>
 public void SetFaveroProduct(ushort?faveroProduct)
 {
     SetFieldValue(1, 0, faveroProduct, ProductSubfield.FaveroProduct);
 }
 public virtual Operation SignChangeAccountInfo(uint account_target, uint account_signer, string new_enc_pubkey, string new_b58_pubkey, string new_name, ushort?new_type, uint last_n_operation, decimal fee, byte[] payload = null, PayloadEncryptionMethod?payloadMethod = null, string pwd = null, string signer_b58_pubkey = null, string signer_enc_pubkey = null, string rawoperations = null)
 {
     return(Invoke <Operation>(ApiMethodName.signchangeaccountinfo.ToString(), new Dictionary <string, object>()
     {
         ["account_target"] = account_target,
         ["account_signer"] = account_signer,
         ["new_enc_pubkey"] = new_enc_pubkey,
         ["new_enc_pubkey"] = new_enc_pubkey,
         ["new_name"] = new_name,
         ["new_type"] = new_type,
         ["last_n_operation"] = last_n_operation,
         ["fee"] = fee,
         ["payload"] = payload?.ToHexString(),
         ["payloadMethod"] = ToPayloadMethodString(payloadMethod),
         ["pwd"] = pwd,
         ["signer_b58_pubkey"] = signer_b58_pubkey,
         ["signer_enc_pubkey"] = signer_enc_pubkey,
         ["rawoperations"] = rawoperations,
     }));
 }