상속: MonoBehaviour
 public Entity ReplaceCustomObject(CustomObject newCustomObject) {
     var componentPool = GetComponentPool(ComponentIds.CustomObject);
     var component = (CustomObjectComponent)(componentPool.Count > 0 ? componentPool.Pop() : new CustomObjectComponent());
     component.customObject = newCustomObject;
     ReplaceComponent(ComponentIds.CustomObject, component);
     return this;
 }
            public void CorrectlyReturnsDynamicMemberNames_WhenSetViaSetValueMethod()
            {
                var     observableObject        = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via SetValue method.
                DateTime dt = DateTime.ParseExact("2016-01-01 01:01:01", "yyyy-MM-dd HH:mm:ss", null);

                observableObject.SetValue("Property1", "test");
                observableObject.SetValue("Property2", 100);
                observableObject.SetValue("Property3", 3.14F);
                observableObject.SetValue("Property4", 1.2M);
                observableObject.SetValue("Property5", dt);

                // Get dynamic member names and sort (we get keys from dictionary where order is unspecified, so it's better to sort by names).
                var memberNames = observableObject.GetMetaObject(Expression.Constant(observableObject)).GetDynamicMemberNames().ToList();

                memberNames.Sort();
                Assert.AreEqual(5, memberNames.Count);
                Assert.AreEqual("Property1", memberNames[0]);
                Assert.AreEqual("Property2", memberNames[1]);
                Assert.AreEqual("Property3", memberNames[2]);
                Assert.AreEqual("Property4", memberNames[3]);
                Assert.AreEqual("Property5", memberNames[4]);
            }
예제 #3
0
        private CustomObject GetMainFormulaObject(DP_DataRepository mainDataItem)
        {
            CustomObject formulaObject = new CustomObject();

            if (!mainDataItem.IsNewItem && MyDataHelper.DataItemPrimaryKeysHaveValue(mainDataItem) && !MyDataHelper.DataItemNonPrimaryKeysHaveValues(mainDataItem))
            {
                SearchRequestManager searchProcessor = new SearchRequestManager();
                DP_SearchRepository  searchDataItem  = new DP_SearchRepository(mainDataItem.TargetEntityID);
                foreach (var property in mainDataItem.GetProperties())
                {
                    searchDataItem.Phrases.Add(new SearchProperty()
                    {
                        ColumnID = property.ColumnID, Value = property.Value
                    });
                }

                //سکوریتی داده اعمال میشود
                //یعنی ممکن است به خود داده دسترسی نداشته باشد و یا حتی به بعضی از فیلدها و روابط
                DR_SearchFullDataRequest request = new DR_SearchFullDataRequest(Requester, searchDataItem);
                var result = searchProcessor.Process(request);
                if (result.Result == Enum_DR_ResultType.SeccessfullyDone)
                {
                    formulaObject.DataItem = result.ResultDataItems.FirstOrDefault(); // searchProcessor.GetDataItemsByListOFSearchProperties(Requester, searchDataItem).FirstOrDefault();
                }
                else if (result.Result == Enum_DR_ResultType.ExceptionThrown)
                {
                    throw (new Exception(result.Message));
                }
            }
            else
            {
                formulaObject.DataItem = mainDataItem;
            }
            return(formulaObject);
        }
예제 #4
0
        public void CreateCustomObjectTest()
        {
            var customObject = new CustomObject
            {
                id     = -10001,
                name   = "sample",
                fields = new List <CustomObjectField>
                {
                    new CustomObjectField
                    {
                        name     = "sample text field",
                        dataType = Enum.GetName(typeof(DataType), DataType.text),
                        type     = "CustomObjectField"
                    },
                    new CustomObjectField
                    {
                        name     = "sample numeric field",
                        dataType = Enum.GetName(typeof(DataType), DataType.numeric),
                        type     = "CustomObjectField"
                    },
                    new CustomObjectField
                    {
                        name     = "sample date field",
                        dataType = Enum.GetName(typeof(DataType), DataType.date),
                        type     = "CustomObjectField"
                    }
                }
            };

            var response = _helper.CreateCustomObject(customObject);

            Assert.AreEqual(customObject.name, response.name);
        }
예제 #5
0
        protected void Page_Init(object sender, EventArgs e)
        {
            var o = new CustomObject();

            o.Properties.Add(new CustomPropertyDescriptor(
                                 "SomeString",
                                 typeof(string),
                                 null,
                                 "Hello"));

            o.Properties.Add(new CustomPropertyDescriptor(
                                 "SomeInt",
                                 typeof(int),
                                 new Attribute[] {
                new RangeAttribute(0, 100)
            },
                                 34));

            o.Properties.Add(new CustomPropertyDescriptor(
                                 "SomeDate",
                                 typeof(DateTime),
                                 new Attribute[] {
                new DataTypeAttribute(DataType.Date)
            },
                                 DateTime.Now));

            DataSource1.SetDataObject(o, DetailsView1);
            DataSource1.Complete += new EventHandler <SimpleDynamicDataSourceCompleteEventArgs>(LinqDataSource1_Complete);
        }
예제 #6
0
        public void OverLoad_Minus_Object()
        {
            //Arrange
            CustomObject object1 = new CustomObject();
            CustomObject object2 = new CustomObject();
            CustomObject object3 = new CustomObject();
            CustomObject object4 = new CustomObject();
            CustomList <CustomObject> firstList = new CustomList <CustomObject>()
            {
                object1, object3, object2
            };
            CustomList <CustomObject> secondList = new CustomList <CustomObject>()
            {
                object2, object4
            };
            CustomList <CustomObject> expected = new CustomList <CustomObject>()
            {
                object1, object3
            };
            //Act
            CustomList <CustomObject> result = firstList - secondList;

            //Assert
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }
예제 #7
0
        public Entity AddCustomObject(CustomObject newCustomObject)
        {
            var component = _customObjectComponentPool.Count > 0 ? _customObjectComponentPool.Pop() : new CustomObjectComponent();

            component.customObject = newCustomObject;
            return(AddComponent(ComponentIds.CustomObject, component));
        }
            public void CorrectlyReturnsTheRightValue_WhenSetViaSetValueMethod()
            {
                var     observableObject        = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via SetValue method, getting via dynamic property and via GetValue<T> method.
                DateTime dt = DateTime.ParseExact("2016-01-01 01:01:01", "yyyy-MM-dd HH:mm:ss", null);

                observableObject.SetValue("Property1", "test");
                observableObject.SetValue("Property2", 100);
                observableObject.SetValue("Property3", 3.14F);
                observableObject.SetValue("Property4", 1.2M);
                observableObject.SetValue("Property5", dt);

                Assert.AreEqual("test", dynamicObservableObject.Property1);
                Assert.AreEqual(100, dynamicObservableObject.Property2);
                Assert.AreEqual(3.14F, dynamicObservableObject.Property3);
                Assert.AreEqual(1.2M, dynamicObservableObject.Property4);
                Assert.AreEqual(dt, dynamicObservableObject.Property5);

                Assert.AreEqual("test", observableObject.GetValue <string>("Property1"));
                Assert.AreEqual(100, observableObject.GetValue <int>("Property2"));
                Assert.AreEqual(3.14F, observableObject.GetValue <float>("Property3"));
                Assert.AreEqual(1.2M, observableObject.GetValue <decimal>("Property4"));
                Assert.AreEqual(dt, observableObject.GetValue <DateTime>("Property5"));
            }
예제 #9
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public Tjs()
        {
            // create script cache object
            mCache    = new ScriptCache(this);
            mPPValues = new Dictionary <string, int>();
            SetPpValue("version", VERSION_HEX);
            SetPpValue("environment", ENV_JAVA_APPLICATION);
            // TODO 适切な值を入れる
            SetPpValue("compatibleSystem", 1);
            // 互换システム true
            mGlobal       = new CustomObject(GLOBAL_HASH_BITS);
            mScriptBlocks = new AList <WeakReference <ScriptBlock> >();

            LoadClass(mArrayClass);
            LoadClass(mDictionaryClass);
            NativeClass math = LoadClass(new MathClass());

            LoadClass(new RandomGeneratorClass(), math);
            LoadClass(new ExceptionClass());
            LoadClass(new RegExpClass());
            //TODO: add date back
            //LoadClass(new DateClass());

            // Extended API
            LoadClass(new DebugClass());
            LoadClass(new MathExClass());
        }
예제 #10
0
        /***************************************************/
        /****           Public Methods                  ****/
        /***************************************************/

        public static HealthProductDeclaration ToHealthProductDeclarationData(this CustomObject obj)
        {
            HealthProductDeclaration epd = new HealthProductDeclaration
            {
                //Cpid = obj.PropertyValue("cpid")?.ToString() ?? "",
                //Version = obj.PropertyValue("version")?.ToString() ?? "",
                Name         = obj.PropertyValue("name")?.ToString() ?? "",
                MasterFormat = obj.PropertyValue("Masterformat")?.ToString() ?? "",
                Uniformats   = obj.PropertyValue("Uniformats")?.ToString() ?? "",
                CancerOrange = obj.PropertyValue("CancerOrange") != null?System.Convert.ToDouble(obj.PropertyValue("CancerOrange")) : double.NaN,
                                   DevelopmentalOrange = obj.PropertyValue("DevelopmentalOrange") != null?System.Convert.ToDouble(obj.PropertyValue("DevelopmentalOrange")) : double.NaN,
                                                             EndocrineOrange = obj.PropertyValue("EndocrineOrange") != null?System.Convert.ToDouble(obj.PropertyValue("EndocrineOrange")) : double.NaN,
                                                                                   EyeIrritationOrange = obj.PropertyValue("EyeIrritationOrange") != null?System.Convert.ToDouble(obj.PropertyValue("EyeIrritationOrange")) : double.NaN,
                                                                                                             MammalianOrange = obj.PropertyValue("MammalianOrange") != null?System.Convert.ToDouble(obj.PropertyValue("MammalianOrange")) : double.NaN,
                                                                                                                                   MutagenicityOrange = obj.PropertyValue("MutagenicityOrange") != null?System.Convert.ToDouble(obj.PropertyValue("MutagenicityOrange")) : double.NaN,
                                                                                                                                                            NeurotoxicityOrange = obj.PropertyValue("NeurotoxicityOrange") != null?System.Convert.ToDouble(obj.PropertyValue("NeurotoxicityOrange")) : double.NaN,
                                                                                                                                                                                      OrganToxicantOrange = obj.PropertyValue("OrganToxicantOrange") != null?System.Convert.ToDouble(obj.PropertyValue("OrganToxicantOrange")) : double.NaN,
                                                                                                                                                                                                                ReproductiveOrange = obj.PropertyValue("ReproductiveOrange") != null?System.Convert.ToDouble(obj.PropertyValue("ReproductiveOrange")) : double.NaN,
                                                                                                                                                                                                                                         RespiratoryOrange = obj.PropertyValue("RespiratoryOrange") != null?System.Convert.ToDouble(obj.PropertyValue("RespiratoryOrange")) : double.NaN,
                                                                                                                                                                                                                                                                 RespiratoryOccupationalOnlyOrange = obj.PropertyValue("RespiratoryOccupationalOnlyOrange") != null?System.Convert.ToDouble(obj.PropertyValue("RespiratoryOccupationalOnlyOrange")) : double.NaN,
                                                                                                                                                                                                                                                                                                         SkinSensitizationOrange = obj.PropertyValue("SkinSensitizationOrange") != null?System.Convert.ToDouble(obj.PropertyValue("SkinSensitizationOrange")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                       CancerRed = obj.PropertyValue("CancerRed") != null?System.Convert.ToDouble(obj.PropertyValue("CancerRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                       CancerOccupationalOnlyRed = obj.PropertyValue("CancerOccupationalOnlyRed") != null?System.Convert.ToDouble(obj.PropertyValue("CancerOccupationalOnlyRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                                                       DevelopmentalRed = obj.PropertyValue("DevelopmentalRed") != null?System.Convert.ToDouble(obj.PropertyValue("DevelopmentalRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                                                                              MutagenicityRed = obj.PropertyValue("MutagenicityRed") != null?System.Convert.ToDouble(obj.PropertyValue("MutagenicityRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                                                                                                    PersistantBioaccumulativeToxicantRed = obj.PropertyValue("PersistantBioaccumulativeToxicantRed") != null?System.Convert.ToDouble(obj.PropertyValue("PersistantBioaccumulativeToxicantRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               RespiratoryRed = obj.PropertyValue("RespiratoryRed") != null?System.Convert.ToDouble(obj.PropertyValue("RespiratoryRed")) : double.NaN,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    PersistantBioaccumulativeToxicantPurple = obj.PropertyValue("PersistantBioaccumulativeToxicantPurple") != null?System.Convert.ToDouble(obj.PropertyValue("PersistantBioaccumulativeToxicantPurple")) : double.NaN,
            };

            return(epd);
        }
 public Entity AddCustomObject(CustomObject newCustomObject)
 {
     var componentPool = GetComponentPool(ComponentIds.CustomObject);
     var component = (CustomObjectComponent)(componentPool.Count > 0 ? componentPool.Pop() : new CustomObjectComponent());
     component.customObject = newCustomObject;
     return AddComponent(ComponentIds.CustomObject, component);
 }
예제 #12
0
        public void Setup()
        {
            UnitTestStartAndEnd.Start(DatabaseName);

            var customObject = new CustomObject()
            {
                IntegerField = 42,
                StringField  = "The answer to everything..."
            };

            var customXml     = string.Empty;
            var stringBuilder = new StringBuilder();

            using (var writer = XmlWriter.Create(stringBuilder, new XmlWriterSettings()
            {
                OmitXmlDeclaration = true
            }))
            {
                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ns.Add(string.Empty, string.Empty);
                new XmlSerializer(typeof(CustomObject)).Serialize(writer, customObject, ns);
                customXml = stringBuilder.ToString();
            }

            ExecuteNonQuery("CREATE Table TestObject (id int not null, name varchar(250), location geography, customData xml)");
            ExecuteNonQuery("INSERT INTO TestObject (id, name, location, customData) values(1, 'One', geography::STGeomFromText('Point(-122.360 47.656)', 4326), '" + customXml + "')");
            ExecuteNonQuery("INSERT INTO TestObject (id, name, location, customData) values(2, 'Two', geography::STGeomFromText('Point(-122.360 47.656)', 4326), '" + customXml + "')");
            ExecuteNonQuery("INSERT INTO TestObject (id, name, location, customData) values(3, 'Three', geography::STGeomFromText('Point(-122.360 47.656)', 4326), '" + customXml + "')");
            ExecuteNonQuery("INSERT INTO TestObject (id, name, location, customData) values(4, 'Four', geography::STGeomFromText('Point(-122.360 47.656)', 4326), '" + customXml + "')");
            ExecuteNonQuery("INSERT INTO TestObject (id, name, location, customData) values(5, 'Five', geography::STGeomFromText('Point(-122.360 47.656)', 4326), '" + customXml + "')");
        }
예제 #13
0
 /// <exception cref="VariantException"></exception>
 /// <exception cref="TjsException"></exception>
 public virtual void AssignStructure(Dispatch2 dsp, AList <Dispatch2> stack)
 {
     // assign structured data from dsp
     //ArrayNI dicni = null;
     if (dsp.GetNativeInstance(DictionaryClass.ClassID) != null)
     {
         // copy from dictionary
         stack.AddItem(dsp);
         try
         {
             CustomObject owner = mOwner.Get();
             owner.Clear();
             DictionaryNI.AssignStructCallback callback = new DictionaryNI.AssignStructCallback
                                                              (stack, owner);
             dsp.EnumMembers(Interface.IGNOREPROP, callback, dsp);
         }
         finally
         {
             stack.Remove(stack.Count - 1);
         }
     }
     else
     {
         throw new TjsException(Error.SpecifyDicOrArray);
     }
 }
            public void RaisesAdvancedPropertyChangedEvents_WhenSetViaSetValueMethod()
            {
                var     counter                 = 0;
                var     propertyName            = default(string);
                var     oldValue                = default(object);
                var     newValue                = default(object);
                var     observableObject        = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via dynamic property.
                observableObject.SetValue("Property1", "oldtest");
                observableObject.PropertyChanged += (sender, e) =>
                {
                    AdvancedPropertyChangedEventArgs args = e as AdvancedPropertyChangedEventArgs;
                    if (args is not null)
                    {
                        counter++;
                        propertyName = args.PropertyName;
                        oldValue     = args.OldValue;
                        newValue     = args.NewValue;
                    }
                };
                observableObject.SetValue("Property1", "newtest");

                Assert.AreEqual(1, counter);
                Assert.AreEqual(propertyName, "Property1");
                Assert.AreEqual(oldValue, "oldtest");
                Assert.AreEqual(newValue, "newtest");
            }
        public async Task Redis_SetPocoValue_ValueReadFromRedis()
        {
            // Arrange
            var key            = Path.GetRandomFileName();
            var expectedObject = new CustomObject()
            {
                IntegerProperty = new Random().Next(),
                StringProperty  = Path.GetRandomFileName(),
            };

            // Act
            var response = await httpClient.PostAsync($"http://localhost:7075/test/poco/{key}",
                                                      new StringContent(JsonConvert.SerializeObject(expectedObject)));

            var content = await response.Content.ReadAsStringAsync();

            // Assert
            var database    = await _database.Value;
            var actualValue = await database.StringGetAsync(key);

            var actualObject = JsonConvert.DeserializeObject <CustomObject>(content);

            Assert.Equal(expectedObject.IntegerProperty, actualObject.IntegerProperty);
            Assert.Equal(expectedObject.StringProperty, actualObject.StringProperty);
        }
예제 #16
0
        private CustomObject IsValid(string str, char[] toBeIncluded)
        {
            HashSet <char> map = new HashSet <char>();
            CustomObject   ret = new CustomObject();

            foreach (char c in toBeIncluded)
            {
                map.Add(c);
            }
            for (int i = 0; i < str.Length; i++)
            {
                if (map.Contains(str[i]))
                {
                    if (ret.start == -1)
                    {
                        ret.start = i;
                    }
                    map.Remove(str[i]);
                }
                if (map.Count == 0)
                {
                    ret.end   = i;
                    ret.valid = true;
                    return(ret);
                }
            }
            ret.valid = false;
            return(ret);
        }
예제 #17
0
        public IList <AzureUtilizationRecord> doTheTask()
        {
            List <CustomObject> ResourceUtilizationList = new List <CustomObject>();
            var partnerOperations = this.authHelper.AppPartnerOperations;

            try
            {
                SeekBasedResourceCollection <Customer> customersPage = partnerOperations.Customers.Get();
                List <Customer> customers = customersPage.Items.ToList();
                Parallel.ForEach(customers, customer =>
                {
                    CustomObject obj = new CustomObject
                    {
                        CustomerCompanyName     = customer.CompanyProfile.CompanyName,
                        ResourceUtilizationList = GetDataPerCustomer(customer, partnerOperations)
                    };
                    ResourceUtilizationList.Add(obj);
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            //string output = JsonConvert.SerializeObject(ResourceUtilizationList);
            //System.IO.File.WriteAllText(@".\ResourceUtilizationList.json", output);
            //string json = System.IO.File.ReadAllText(@".\ResourceUtilizationList.json");
            //ResourceUtilizationList = JsonConvert.DeserializeObject<List<Microsoft.Store.PartnerCenter.Models.Utilizations.AzureUtilizationRecord>>(json);

            return(MapUtilizationToCustomClass(ResourceUtilizationList));
        }
예제 #18
0
            public void CorrectlyReturnsTheRightValue_WhenSetViaSetValueMethod()
            {
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via SetValue method, getting via dynamic property and via GetValue<T> method.
                DateTime dt = DateTime.ParseExact("2016-01-01 01:01:01", "yyyy-MM-dd HH:mm:ss", null);
                observableObject.SetValue("Property1", "test");
                observableObject.SetValue("Property2", 100);
                observableObject.SetValue("Property3", 3.14F);
                observableObject.SetValue("Property4", 1.2M);
                observableObject.SetValue("Property5", dt);

                Assert.AreEqual("test", dynamicObservableObject.Property1);
                Assert.AreEqual(100, dynamicObservableObject.Property2);
                Assert.AreEqual(3.14F, dynamicObservableObject.Property3);
                Assert.AreEqual(1.2M, dynamicObservableObject.Property4);
                Assert.AreEqual(dt, dynamicObservableObject.Property5);

                Assert.AreEqual("test", observableObject.GetValue<string>("Property1"));
                Assert.AreEqual(100, observableObject.GetValue<int>("Property2"));
                Assert.AreEqual(3.14F, observableObject.GetValue<float>("Property3"));
                Assert.AreEqual(1.2M, observableObject.GetValue<decimal>("Property4"));
                Assert.AreEqual(dt, observableObject.GetValue<DateTime>("Property5"));
            }
예제 #19
0
        /// <summary>
        /// Used to draw SDV items to the screen.
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="obj"></param>
        /// <param name="itemToDraw"></param>
        /// <param name="alpha"></param>
        /// <param name="addedDepth"></param>
        public static void Draw(SpriteBatch spriteBatch, CustomObject obj, StardewValley.Item itemToDraw, float alpha, float addedDepth)
        {
            if (itemToDraw.GetType() == typeof(StardewValley.Object))
            {
                Rectangle   rectangle;
                SpriteBatch spriteBatch1    = spriteBatch;
                Texture2D   shadowTexture   = Game1.shadowTexture;
                Vector2     position        = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(obj.TileLocation.X), (float)(obj.TileLocation.Y)));
                Rectangle?  sourceRectangle = new Rectangle?(Game1.shadowTexture.Bounds);
                Color       color           = Color.White * alpha;
                rectangle = Game1.shadowTexture.Bounds;
                double x1 = (double)rectangle.Center.X;
                rectangle = Game1.shadowTexture.Bounds;
                double  y1     = (double)rectangle.Center.Y;
                Vector2 origin = new Vector2((float)x1, (float)y1);
                double  num    = (double)obj.boundingBox.Bottom / 10000.0;
                spriteBatch1.Draw(shadowTexture, position, sourceRectangle, color, 0.0f, origin, 4f, SpriteEffects.None, (float)num);
                spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, obj.TileLocation * Game1.tileSize), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, itemToDraw.ParentSheetIndex, 16, 16), Color.White * alpha, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, ((float)(obj.boundingBox.Bottom + 1) / 10000f) + addedDepth);

                (itemToDraw as StardewValley.Object).draw(spriteBatch, (int)obj.TileLocation.X * Game1.tileSize, (int)obj.TileLocation.Y * Game1.tileSize, Math.Max(0f, (float)(((obj.TileLocation.Y + 1) + addedDepth) * Game1.tileSize) / 10000f) + .0001f, alpha);
            }
            if (ModCore.Serializer.IsSameOrSubclass(typeof(CustomObject), itemToDraw.GetType()))
            {
                (itemToDraw as CustomObject).draw(spriteBatch, (int)obj.TileLocation.X, (int)obj.TileLocation.Y);
                //(itemToDraw as CustomObject).draw(spriteBatch, (int)obj.TileLocation.X*Game1.tileSize, (int)obj.TileLocation.Y*Game1.tileSize,addedDepth,alpha);
            }
        }
예제 #20
0
    public void OnInteract(CustomObject obj, InteractType type)
    {
        if (m_targetScene == null) return;
        if (defaultStatus < 2) return;
        if (type == InteractType.Stay)
        {

          PlanerCore x = obj as PlanerCore;
          if (x != null&&x.State==0)
          {
          if (defaultStatus == 2)
            defaultStatus = 1;

          if (object.ReferenceEquals(x, Creator.Player))
          {
            PlayerSaveData.SaveDiscoveredScene(m_targetScene, defaultStatus);
            x.AddUpdateFunc(OnPlanerEnter);
            x.HasTarget = true;
          }
          else
          {
            Creator.DestroyObject(x);
          }
          }
        }
    }
예제 #21
0
 public void OnSendAction(ViewActionType actionType, CustomObject data)
 {
     foreach (var uiComponentView in _components)
     {
         uiComponentView?.SendAction(actionType, data);
     }
 }
    public void ReplaceCustomObject(CustomObject newCustomObject)
    {
        var component = CreateComponent <CustomObjectComponent>(GameComponentsLookup.CustomObject);

        component.customObject = newCustomObject;
        ReplaceComponent(GameComponentsLookup.CustomObject, component);
    }
예제 #23
0
        /***************************************************/

        public static IGeometry Geometry(this CustomObject obj)
        {
            if (obj == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the geometry of a null custom object.");
                return(null);
            }

            List <IGeometry> geometries = new List <IGeometry>();

            foreach (object item in obj.CustomData.Values)
            {
                IGeometry geometry = item.Geometry();
                if (geometry != null)
                {
                    geometries.Add(geometry);
                }
            }

            if (geometries.Count == 1)
            {
                return(geometries[0]);
            }

            return(new CompositeGeometry {
                Elements = geometries
            });
        }
예제 #24
0
 public LocalCustomObject(CustomObject customObject)
 {
     _id           = customObject.Id;
     _version      = customObject.Version;
     _downloadPath = customObject.DownloadPath;
     _description  = customObject.Description;
 }
예제 #25
0
        public void Zip_Objects()
        {
            //Arrange
            CustomObject object1 = new CustomObject();
            CustomObject object2 = new CustomObject();
            CustomObject object3 = new CustomObject();
            CustomObject object4 = new CustomObject();
            CustomList <CustomObject> objectsOdd = new CustomList <CustomObject>()
            {
                object1, object3,
            };
            CustomList <CustomObject> objectsEven = new CustomList <CustomObject>()
            {
                object2, object4
            };
            CustomList <CustomObject> expected = new CustomList <CustomObject>()
            {
                object1, object2, object3, object4
            };
            //Act
            CustomList <CustomObject> result = objectsOdd.ZipTo(objectsEven);

            //Assert
            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }
        public Entity AddCustomObject(CustomObject newCustomObject)
        {
            var component = new CustomObjectComponent();

            component.customObject = newCustomObject;
            return(AddCustomObject(component));
        }
        public Entity AddCustomObject(CustomObject newCustomObject)
        {
            var component = CreateComponent <CustomObjectComponent>(VisualDebuggingComponentIds.CustomObject);

            component.customObject = newCustomObject;
            return(AddComponent(VisualDebuggingComponentIds.CustomObject, component));
        }
예제 #28
0
        void snippet3()
        {
            // >> chart-binding-props-cs
            var chart = new TKChart(CGRect.Inflate(this.View.Bounds, -10, -10));

            this.View.AddSubview(chart);
            chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            Random r          = new Random();
            var    dataPoints = new List <CustomObject> ();

            for (int i = 0; i < 5; i++)
            {
                CustomObject obj = new CustomObject()
                {
                    ObjectID = i,
                    Value1   = r.Next(100),
                    Value2   = r.Next(100),
                    Value3   = r.Next(100)
                };
                dataPoints.Add(obj);
            }

            chart.BeginUpdates();
            chart.AddSeries(new TKChartLineSeries(dataPoints.ToArray(), "ObjectID", "Value1"));
            chart.AddSeries(new TKChartAreaSeries(dataPoints.ToArray(), "ObjectID", "Value2"));
            chart.AddSeries(new TKChartScatterSeries(dataPoints.ToArray(), "ObjectID", "Value3"));
            chart.EndUpdates();
            // << chart-binding-props-cs
        }
예제 #29
0
    private void Form1_Load(object sender, EventArgs e)
    {
        SqlCeDataReader rdr = null;

        try
        {
            using (SqlCeConnection conn = new SqlCeConnection(@"Data Source = |DataDirectory|\Database1.sdf"))
            {
                conn.Open();
                SqlCeCommand sqlcmd = new SqlCeCommand("SELECT ID, UserName FROM Table1", conn);
                sqlcmd.Connection.Open();
                rdr = sqlcmd.ExecuteReader();
                //Custom Object is object with same structure as your data table
                List <CustomObject> dataSource = new List <CustomObject>();
                while (rdr.Read())
                {
                    var customObject = new CustomObject();
                    customObject.Id = rdr.GetInt32(0);
                    //so on
                    dataSource.Add(customObject);
                }
                this.bindingSource1.DataSource = dataSource;
                rdr.Close();
            }
        }
        catch (Exception ex)
        {
            //Handle Exception
        }
    }
예제 #30
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            TKChart chart = new TKChart (this.ExampleBounds);
            chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.View.AddSubview (chart);

            Random r = new Random ();
            List<CustomObject> data = new List<CustomObject> ();
            for (int i = 0; i < 5; i++) {
                CustomObject obj = new CustomObject () {
                    ObjectID = i,
                    Value1 = r.Next (100),
                    Value2 = r.Next (100),
                    Value3 = r.Next (100)
                };
                data.Add (obj);
            }

            chart.AddSeries (new TKChartAreaSeries (data.ToArray(), "ObjectID", "Value1"));
            chart.AddSeries (new TKChartAreaSeries (data.ToArray(), "ObjectID", "Value2"));
            chart.AddSeries (new TKChartAreaSeries (data.ToArray(), "ObjectID", "Value3"));

            TKChartStackInfo stackInfo = new TKChartStackInfo (new NSNumber (1), TKChartStackMode.Stack);
            for (int i = 0; i < chart.Series.Length; i++) {
                TKChartSeries series = chart.Series [i];
                series.SelectionMode = TKChartSeriesSelectionMode.Series;
                series.StackInfo = stackInfo;
            }

            chart.ReloadData ();
        }
        public void buildMap(String path, List <String> m_list, String metaname)
        {
            CustomObject customObject = ManageXMLCustomObject.Deserialize(path);

            Console.WriteLine(metaname);
            foreach (String Metafile in m_list)
            {
                String [] customMetaSplit = Metafile.Split(".");
                String    m_nameObject    = customMetaSplit[0];
                Console.WriteLine(m_nameObject);
                String customInMeta = customMetaSplit[1];
                foreach (_BusinessProcess Meta in customObject.BusinessProcesses)
                {
                    if (!m_dictionaryObject.ContainsKey(m_nameObject))
                    {
                        m_dictionaryObject.Add(m_nameObject, new List <_BusinessProcess>());
                    }
                    if (Meta.FullName == customInMeta)
                    {
                        m_dictionaryObject[m_nameObject].Add(Meta);
                    }
                }
            }

            if (m_dictionaryObject.Count == 0)
            {
                throw new Exception("Erro não foi encontrado nenhum valor");
            }
        }
예제 #32
0
    // Displace the custom objects inside the map.
    public void DisplaceObjects(char[,] map, float squareSize, float height)
    {
        // categoryObjectsDictionary.Clear();
        // DestroyAllCustomObjects();

        for (int x = 0; x < map.GetLength(0); x++)
        {
            for (int y = 0; y < map.GetLength(1); y++)
            {
                if (charObjectsDictionary.ContainsKey(map[x, y]))
                {
                    CustomObject currentObject = charObjectsDictionary[map[x, y]].GetObject();

                    GameObject childObject = (GameObject)Instantiate(currentObject.prefab);
                    childObject.name                    = currentObject.prefab.name;
                    childObject.transform.parent        = transform.Find(currentObject.category);
                    childObject.transform.localPosition = new Vector3(squareSize * x,
                                                                      heightDirCorrection * (heightCorrection + height +
                                                                                             currentObject.heightCorrection), squareSize * y);
                    childObject.transform.localScale *= sizeCorrection;

                    if (categoryObjectsDictionary.ContainsKey(currentObject.category))
                    {
                        categoryObjectsDictionary[currentObject.category].Add(childObject);
                    }
                    else
                    {
                        categoryObjectsDictionary.Add(currentObject.category,
                                                      new List <GameObject>());
                        categoryObjectsDictionary[currentObject.category].Add(childObject);
                    }
                }
            }
        }
    }
        private CustomObject GetMainFormulaObject(DP_DataRepository mainDataItem)
        {
            CustomObject formulaObject = new CustomObject();

            formulaObject.DataItem = mainDataItem;
            return(formulaObject);
        }
예제 #34
0
        public void SetUp()
        {
            this.schema = new GraphQLSchema();

            var rootType   = new RootQueryType();
            var nestedType = new NestedQueryType();

            nestedType.Field("howdy", () => "xzyt");

            var anotherSestedType = new AnotherNestedQueryType();

            anotherSestedType.Field("stuff", () => "a");

            nestedType.Field("anotherNested", () => anotherSestedType);
            rootType.Field("nested", () => nestedType);

            var typeWithAccessor = new CustomObject();

            typeWithAccessor.Field("Hello", e => e.Hello);
            typeWithAccessor.Field("Test", e => e.Test);

            rootType.Field("acessorBasedProp", () => new TestType()
            {
                Hello = "world", Test = "stuff"
            });

            this.schema.AddKnownType(rootType);
            this.schema.AddKnownType(anotherSestedType);
            this.schema.AddKnownType(nestedType);
            this.schema.AddKnownType(typeWithAccessor);
            this.schema.Query(rootType);
        }
 public Entity ReplaceCustomObject(CustomObject newCustomObject)
 {
     var component = CreateComponent<CustomObjectComponent>(VisualDebuggingComponentIds.CustomObject);
     component.customObject = newCustomObject;
     ReplaceComponent(VisualDebuggingComponentIds.CustomObject, component);
     return this;
 }
예제 #36
0
        /***************************************************/

        public static Dictionary <string, object> PropertyDictionary(this CustomObject obj)
        {
            if (obj == null)
            {
                Compute.RecordWarning("Cannot query the property dictionary of a null custom object.  An empty dictionary will be returned.");
                return(new Dictionary <string, object>());
            }

            Dictionary <string, object> dic = new Dictionary <string, object>(obj.CustomData);

            if (!dic.ContainsKey("Name"))
            {
                dic["Name"] = obj.Name;
            }

            if (!dic.ContainsKey("BHoM_Guid"))
            {
                dic["BHoM_Guid"] = obj.BHoM_Guid;
            }

            if (!dic.ContainsKey("Tags"))
            {
                dic["Tags"] = obj.Tags;
            }

            return(dic);
        }
예제 #37
0
    public void OnInteract(CustomObject obj, InteractType type)
    {
        DistantPortalEnter x = obj as DistantPortalEnter;
        if (x != null)
        {

          if(x.defaultStatus<1)
        x.Status = 1;
        }
    }
 public Entity ReplaceCustomObject(CustomObject newCustomObject) {
     var previousComponent = hasCustomObject ? customObject : null;
     var component = _customObjectComponentPool.Count > 0 ? _customObjectComponentPool.Pop() : new CustomObjectComponent();
     component.customObject = newCustomObject;
     ReplaceComponent(ComponentIds.CustomObject, component);
     if (previousComponent != null) {
         _customObjectComponentPool.Push(previousComponent);
     }
     return this;
 }
 public Entity ReplaceCustomObject(CustomObject newCustomObject)
 {
     CustomObjectComponent component;
     if (hasCustomObject) {
         WillRemoveComponent(ComponentIds.CustomObject);
         component = customObject;
     } else {
         component = new CustomObjectComponent();
     }
     component.customObject = newCustomObject;
     return ReplaceComponent(ComponentIds.CustomObject, component);
 }
예제 #40
0
 void OnInteract(CustomObject obj, InteractType type)
 {
     if (type == InteractType.Enter)
     {
       IPlanerLike planer = obj as IPlanerLike;
       if (planer != null)
       {
     //placed = true;
     planer.AddUpdateFunc(PlanerNewUpdater);
     m_caughtList.Add(planer);
       }
     }
 }
예제 #41
0
 void OnInteract(CustomObject obj, InteractType type)
 {
     //Debug.Log("interact");
     if (type == InteractType.Stay)
     {
       PlanerCore planer = obj as PlanerCore;
       if (planer == null) return;
       planer.OnDamageDealt(damage);
       m_visualiser.transform.parent = transform.parent;
       (m_visualiser.GetComponent<BasicMineVisualiser>()).OnDestroyed();
       Creator.DestroyObject(this);
     }
 }
예제 #42
0
        protected override void OnStart()
        {
            var scene = new asd.Scene();

            var layer = new asd.Layer2D();

            scene.AddLayer(layer);

            var obj = new CustomObject();
            layer.AddObject(obj);

            asd.Engine.ChangeScene(scene);
        }
예제 #43
0
    void OnInteract(CustomObject obj, InteractType type)
    {
        if (PairPortal == null) return;
        if (type == InteractType.Stay)
        {
          PlanerCore x = obj as PlanerCore;

          if (x != null&&!x.EnteredPortal&&!(x.State==1))
          {
        x.AddUpdateFunc(OnPlanerEnter);
        x.HasTarget = true;
          }
        }
    }
예제 #44
0
 public void FullArgs(
     bool b,
     int i,
     char c,
     DayOfWeek e,
     string s,
     TimeSpan t,
     DateTime d,
     CustomObject o,
     string[] sa,
     int[] ia,
     long[] ea,
     object[] na,
     List<string> sl)
 {
 }
예제 #45
0
 public void OnInteract(CustomObject obj, InteractType type)
 {
     if(ReferenceEquals(obj, Creator.Player))
     {
       if (IsActive==0)
       {
     Activate();
     //TODO
       }
       else if(IsActive==1)
       {
     Deactivate();
     //TODO
       }
     }
 }
예제 #46
0
            public void CorrectlyReturnsTheDefaultValue_WhenNotSet()
            {
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                Assert.AreEqual(null, observableObject.GetValue<string>("Property1"));
                Assert.AreEqual(0, observableObject.GetValue<int>("Property2"));
                Assert.AreEqual(0F, observableObject.GetValue<float>("Property3"));
                Assert.AreEqual(0M, observableObject.GetValue<decimal>("Property4"));
                Assert.AreEqual(DateTime.MinValue, observableObject.GetValue<DateTime>("Property5"));
                //
                Assert.AreEqual(null, observableObject.GetValue<string>("Property1"));
                Assert.AreEqual(null, observableObject.GetValue<int?>("Property2"));
                Assert.AreEqual(null, observableObject.GetValue<float?>("Property3"));
                Assert.AreEqual(null, observableObject.GetValue<decimal?>("Property4"));
                Assert.AreEqual(null, observableObject.GetValue<DateTime?>("Property5"));
            }
예제 #47
0
    public void OnInteract(CustomObject obj, InteractType type)
    {
        if (type == InteractType.Stay) return;

        DistantPortalEnter x = obj as DistantPortalEnter;
        if (x != null)
        {
          if (x.defaultStatus == 0) return;
          if(x.defaultStatus==2)
        x.Status = 3;
          Creator.DestroyObject(this);
        }
        IFireflyDestroyable dest = obj as IFireflyDestroyable;
        if (dest != null&&!obj.Destroyed)
        {
          dest.FireflyDestroy(this);
        }
    }
        public void Serialized_To_Json_Object()
        {
            var obj = new CustomObject()
                {
                    Name = "Testing",
                    Id = new HiveId("content", "my-provider", new HiveIdValue(Guid.NewGuid()))
                };
            var hiveId = obj.Id;

            var result = JObject.FromObject(obj);
            Assert.IsNotNull(result["Id"]);
            var json = result["Id"];

            Assert.AreEqual(json["htmlId"].ToString(), hiveId.GetHtmlId());
            Assert.AreEqual(json["rawValue"].ToString(), hiveId.ToString());
            Assert.AreEqual(json["value"].ToString(), hiveId.Value.Value.ToString());
            Assert.AreEqual(json["valueType"].ToString(), ((int)hiveId.Value.Type).ToString(CultureInfo.InvariantCulture));
            Assert.AreEqual(json["provider"].ToString(), hiveId.ProviderId);
            Assert.AreEqual(json["scheme"].ToString(), hiveId.ProviderGroupRoot.ToString());
        }
            public void IgnoreFieldsMarkedWithNonHashedAttribute()
            {
                var graph = new CustomObject();

                graph.NonHashedField = ObjectHasher.Hash(graph);

                Assert.Equal(graph.NonHashedField, ObjectHasher.Hash(graph));
            }
예제 #50
0
            public void CorrectlyReturnsDynamicMemberNames_WhenSetViaSetValueMethod()
            {
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via SetValue method.
                DateTime dt = DateTime.ParseExact("2016-01-01 01:01:01", "yyyy-MM-dd HH:mm:ss", null);
                observableObject.SetValue("Property1", "test");
                observableObject.SetValue("Property2", 100);
                observableObject.SetValue("Property3", 3.14F);
                observableObject.SetValue("Property4", 1.2M);
                observableObject.SetValue("Property5", dt);

                // Get dynamic member names and sort (we get keys from dictionary where order is unspecified, so it's better to sort by names).
                var memberNames = observableObject.GetMetaObject(Expression.Constant(observableObject)).GetDynamicMemberNames().ToList();
                memberNames.Sort();
                Assert.AreEqual(5, memberNames.Count);
                Assert.AreEqual("Property1", memberNames[0]);
                Assert.AreEqual("Property2", memberNames[1]);
                Assert.AreEqual("Property3", memberNames[2]);
                Assert.AreEqual("Property4", memberNames[3]);
                Assert.AreEqual("Property5", memberNames[4]);
            }
예제 #51
0
            public void ThrowsArgumentExceptionWhenPropertyNameIsNullOrWhitespace_WhenSetViaSetValueMethod()
            {
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                Assert.Throws<ArgumentException>(() => observableObject.SetValue(null, "test"));
                Assert.Throws<ArgumentException>(() => observableObject.SetValue("", "test"));
                Assert.Throws<ArgumentException>(() => observableObject.SetValue(" ", "test"));
            }
예제 #52
0
            public void RaisesAdvancedPropertyChangedEvents_WhenSetViaSetValueMethod()
            {
                var counter = 0;
                var propertyName = default(string);
                var oldValue = default(object);
                var newValue = default(object);
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via dynamic property.
                observableObject.SetValue("Property1", "oldtest");
                observableObject.PropertyChanged += (sender, e) =>
                {
                    AdvancedPropertyChangedEventArgs args = e as AdvancedPropertyChangedEventArgs;
                    if (args != null)
                    {
                        counter++;
                        propertyName = args.PropertyName;
                        oldValue = args.OldValue;
                        newValue = args.NewValue;
                    }
                };
                observableObject.SetValue("Property1", "newtest");

                Assert.AreEqual(1, counter);
                Assert.AreEqual(propertyName, "Property1");
                Assert.AreEqual(oldValue, "oldtest");
                Assert.AreEqual(newValue, "newtest");
            }
예제 #53
0
        public void ConvertTest()
        {
            #region bool

            var vBool = SafeTypeConverter.Convert<bool>("true");
            Assert.AreEqual(vBool, true);

            vBool = SafeTypeConverter.Convert<bool>("1");
            Assert.AreEqual(vBool, true);

            vBool = SafeTypeConverter.Convert<bool>("0");
            Assert.AreEqual(vBool, false);

            try
            {
                vBool = SafeTypeConverter.Convert<bool>(new object());
                Assert.Fail();
            }
            catch
            {
            }

            try
            {
                vBool = SafeTypeConverter.Convert<bool>(null);
                Assert.Fail();
            }
            catch
            {
            }

            try
            {
                vBool = SafeTypeConverter.Convert<bool>(DBNull.Value);
                Assert.Fail();
            }
            catch
            {
            }

            var vnBool = SafeTypeConverter.Convert<bool?>("true");
            Assert.AreEqual(vnBool, true);

            vnBool = SafeTypeConverter.Convert<bool?>("1");
            Assert.AreEqual(vnBool, true);

            vnBool = SafeTypeConverter.Convert<bool?>("0");
            Assert.AreEqual(vnBool, false);

            vnBool = SafeTypeConverter.Convert<bool?>("invalid_string");
            Assert.AreEqual(vnBool, null);

            vnBool = SafeTypeConverter.Convert<bool?>(null);
            Assert.AreEqual(vnBool, null);

            vnBool = SafeTypeConverter.Convert<bool?>(DBNull.Value);
            Assert.AreEqual(vnBool, null);

            #endregion bool

            #region integral value types

            var vByte = SafeTypeConverter.Convert<byte>(123);
            Assert.AreEqual(vByte, 123);

            vByte = SafeTypeConverter.Convert<byte>(123.1f);
            Assert.AreEqual(vByte, 123);

            vByte = SafeTypeConverter.Convert<byte>(123.1m);
            Assert.AreEqual(vByte, 123);

            vByte = SafeTypeConverter.Convert<byte>("123");
            Assert.AreEqual(vByte, 123);

            vByte = SafeTypeConverter.Convert<byte>("123.1");
            Assert.AreEqual(vByte, 123);

            vByte = SafeTypeConverter.Convert<byte>("123.6");
            Assert.AreEqual(vByte, 124);

            try
            {
                vByte = SafeTypeConverter.Convert<byte>(-123);                
                Assert.Fail("Invalid cast exception expected.");
            }
            catch
            {
            }

            try
            {
                vByte = SafeTypeConverter.Convert<byte>("abc");
                Assert.Fail("Invalid cast exception expected.");
            }
            catch
            {
            }

            var vnByte = SafeTypeConverter.Convert<byte?>(123);
            Assert.IsTrue(vnByte == 123);

            vnByte = SafeTypeConverter.Convert<byte?>(123.1);
            Assert.IsTrue(vnByte == 123);

            vnByte = SafeTypeConverter.Convert<byte?>("123");
            Assert.IsTrue(vnByte == 123);

            vnByte = SafeTypeConverter.Convert<byte?>(null);
            Assert.IsTrue(vnByte == null);

            vnByte = SafeTypeConverter.Convert<byte?>(DBNull.Value);
            Assert.IsTrue(vnByte == null);

            vnByte = SafeTypeConverter.Convert<byte?>(-123);
            Assert.IsTrue(vnByte == 133);

            vnByte = SafeTypeConverter.Convert<byte?>("abc");
            Assert.IsTrue(vnByte == 97);

            #endregion integral value types

            #region floating-point values

            var d = SafeTypeConverter.Convert<double>(123);
            Assert.AreEqual(d, 123);

            d = SafeTypeConverter.Convert<double>(123.01f);
            Assert.AreEqual(Math.Round(d,2), 123.01);

            d = SafeTypeConverter.Convert<double>("123.01");
            Assert.AreEqual(d, 123.01);

            try
            {
                d = SafeTypeConverter.Convert<double>("abc");
                Assert.Fail("Invalid cast exception expected.");
            }
            catch
            {
            }

            var dn = SafeTypeConverter.Convert<double?>(123);
            Assert.AreEqual(dn, 123);

            dn = SafeTypeConverter.Convert<double?>(123.01f);
            Assert.AreEqual(Math.Round((double) dn, 2), 123.01);

            dn = SafeTypeConverter.Convert<double?>("123.01");
            Assert.AreEqual(dn, 123.01);

            dn = SafeTypeConverter.Convert<double?>(null);
            Assert.AreEqual(dn, null);

            dn = SafeTypeConverter.Convert<double?>(DBNull.Value);
            Assert.AreEqual(dn, null);

            dn = SafeTypeConverter.Convert<double?>("abc");
            Assert.AreEqual(dn, null);

            dn = SafeTypeConverter.Convert<double>(string.Empty);
            Assert.AreEqual(0, dn);

            #endregion floating-point values

            #region string

            var s = SafeTypeConverter.Convert<string>(123);
            Assert.AreEqual(s, "123");

            s = SafeTypeConverter.Convert<string>(123.01m);
            Assert.AreEqual(s, "123.01");

            s = SafeTypeConverter.Convert<string>(new CustomObject());
            Assert.AreEqual(s, "NoName");

            s = SafeTypeConverter.Convert<string>(null);
            Assert.AreEqual(s, null);

            s = SafeTypeConverter.Convert<string>(DBNull.Value);
            Assert.AreEqual(s, null);

            #endregion string

            #region enum

            var e = SafeTypeConverter.Convert<ZeroBasedEnum>(0);
            Assert.AreEqual(e, ZeroBasedEnum.Option0);

            e = SafeTypeConverter.Convert<ZeroBasedEnum>(1);
            Assert.AreEqual(e, ZeroBasedEnum.Option1);

            e = SafeTypeConverter.Convert<ZeroBasedEnum>("Option2");
            Assert.AreEqual(e, ZeroBasedEnum.Option2);

            var en = SafeTypeConverter.Convert<ZeroBasedEnum?>(null);
            Assert.AreEqual(en, null);

            en = SafeTypeConverter.Convert<ZeroBasedEnum?>(DBNull.Value);
            Assert.AreEqual(en, null);

            #endregion enum

            #region guid

            var guid = SafeTypeConverter.Convert<Guid>(Guid.Empty.ToString());
            Assert.AreEqual(guid, Guid.Empty);

            const string guidString = "12345678-1234-1234-1234-123412341234";
            var comparerGuid = Guid.Parse(guidString);
            guid = SafeTypeConverter.Convert<Guid>(guidString);
            Assert.AreEqual(comparerGuid, guid);

            #endregion

            #region object

            var obj = SafeTypeConverter.Convert<object>(2);
            Assert.AreEqual(obj, 2);

            var customObj = new CustomObject{FirstName = "name"};
            obj = SafeTypeConverter.Convert<object>(customObj);
            Assert.IsTrue(obj.Equals(customObj));

            #endregion
        }
예제 #54
0
 public void OnInteractEnter(CustomObject obj, InteractType type)
 {
     if (TargetTrigger == null) return;
     if (type == InteractType.Enter) return;
     if (TargetTrigger.IsAssignableFrom(obj.GetType()))
     {
             Activate();
     }
 }
예제 #55
0
 void OnInteract(CustomObject obj, InteractType type)
 {
     Warming warm = obj as Warming;
       if (warm != null&&!warm.isEaten)
       {
           AddHP();
     warm.isEaten = true;
       }
 }
예제 #56
0
 public float EntityValue(CustomObject entity)
 {
     //const int m_maxWeight = 500;
     if (entity.GetType() == typeof(BasicMine)) return 5f;
     if (entity.GetType() == typeof(Portal)) return BasicPlanerAI.MaxWeight;
     if (entity.GetType() == typeof(DistantPortalEnter)&&(entity as DistantPortalEnter).Status>0) return BasicPlanerAI.MaxWeight;
     if (entity.GetType() == typeof(WeaponPrototype)) return BasicPlanerAI.MaxWeight;
     if (entity.GetType() == typeof(RedFireflySpawner)) return BasicPlanerAI.MaxWeight;
     if (entity.GetType() == typeof(Anchor)) return BasicPlanerAI.MaxWeight;
     return 0;
 }
 public Entity AddCustomObject(CustomObject newCustomObject)
 {
     var component = CreateComponent<CustomObjectComponent>(VisualDebuggingComponentIds.CustomObject);
     component.customObject = newCustomObject;
     return AddComponent(VisualDebuggingComponentIds.CustomObject, component);
 }
            public void HashFieldsWithNoAttributes()
            {
                var graph = new CustomObject();

                graph.NonHashedField = ObjectHasher.Hash(graph);
                graph.NoAttributeField = Guid.NewGuid();

                Assert.NotEqual(graph.NonHashedField, ObjectHasher.Hash(graph));
            }
예제 #59
0
            public void RaisesAdvancedPropertyChangingEvents_WhenSetViaDynamicProperty()
            {
                var counter = 0;
                var propertyName = default(string);
                var observableObject = new CustomObject();
                dynamic dynamicObservableObject = observableObject;

                // Setting value via dynamic property.
                dynamicObservableObject.Property1 = "oldtest";
                observableObject.PropertyChanging += (sender, e) =>
                {
                    AdvancedPropertyChangingEventArgs args = e as AdvancedPropertyChangingEventArgs;
                    if (args != null)
                    {
                        counter++;
                        propertyName = args.PropertyName;
                    }
                };
                dynamicObservableObject.Property1 = "newtest";

                Assert.AreEqual(1, counter);
                Assert.AreEqual(propertyName, "Property1");
            }
 public void Handle(IConsoleAdapter console, IErrorAdapter error, Options command, CustomObject custom)
 {
     console.WriteLine("Custom string is \"{0}\"", custom.Message);
 }