public string GetEntityDefinition(JObject entityName)
        {
            string entityNameStr = entityName.ToObject <Name>().name;

            if (NullString(entityNameStr))
            {
                return("false");
            }

            EntityDefinition entity = EntityFacade.GetEntityDefinition(entityNameStr);

            FactDefinition factDefinition = new FactDefinition();

            factDefinition.factName = entityNameStr;
            factDefinition.fields   = new List <FactFieldDefinition>();

            foreach (var field in entity.EntityFields)
            {
                factDefinition.fields.Add(new FactFieldDefinition()
                {
                    fieldName = field.FieldName,
                    fieldType = field.FieldTypeStr
                });
            }

            return(JsonConvert.SerializeObject(factDefinition));
        }
        public string AddUpdateFact(JObject factDefinition)
        {
            var o = factDefinition.ToObject <FactDefinition>();
            //var o = JsonConvert.DeserializeObject<FactDefinition>(factDefinition);

            EntityDefinition entity = new EntityDefinition();

            if (NullString(o.factName))
            {
                return("false");
            }
            entity.EntityName   = o.factName;
            entity.EntityFields = new List <EntityFieldDefinition>();
            foreach (var field in o.fields)
            {
                if (NullString(field.fieldName) || NullString(field.fieldType))
                {
                    return("false");
                }
                entity.EntityFields.Add(new EntityFieldDefinition()
                {
                    FieldName    = field.fieldName,
                    FieldTypeStr = field.fieldType
                });
            }

            EntityFacade.AddorUpdateEntity(entity);

            return("true");
        }
Exemplo n.º 3
0
        public void GetEntityObjectTest()
        {
            EntityFacade.RemoveEntity("Person");

            List <EntityFieldDefinition> definition = new List <EntityFieldDefinition>();

            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "FirstName", FieldTypeStr = "System.String"
            });
            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "Age", FieldTypeStr = "System.Int32"
            });
            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "IncrementedAge", FieldTypeStr = "System.Int32"
            });

            IEntity obj = EntityFacade.GetType(new EntityDefinition()
            {
                EntityName = "Person", EntityFields = definition
            });

            obj.SetProperty("FirstName", "Hello");

            Assert.AreEqual(obj.GetProperty <string>("FirstName"), "Hello", "Get Entity Test Failed");

            IEntity objByName = EntityFacade.GetType("Person");

            Assert.AreEqual(objByName.GetType().GetProperties().First(p => p.Name == "Age").PropertyType, typeof(int));
        }
        public string DeleteEntity(JObject entityName)
        {
            string entityNameStr = entityName.ToObject <Name>().name;

            if (NullString(entityNameStr))
            {
                return("false");
            }

            EntityFacade.DeleteEntity(entityNameStr);
            return("true");
        }
Exemplo n.º 5
0
        public void GetEntityObjectFromCacheTest()
        {
            EntityFacade.RemoveEntity("Person");

            List <EntityFieldDefinition> definition = new List <EntityFieldDefinition>();

            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "FirstName", FieldTypeStr = "System.String"
            });
            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "Age", FieldTypeStr = "System.Int32"
            });
            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "IncrementedAge", FieldTypeStr = "System.Int32"
            });

            IEntity obj = EntityFacade.GetType(new EntityDefinition()
            {
                EntityName = "Person", EntityFields = definition
            });

            obj.SetProperty("FirstName", "Hello");

            definition.Add(new EntityFieldDefinition()
            {
                FieldName = "IncrementedAge1", FieldTypeStr = "System.Int32"
            });

            IEntity obj1 = EntityFacade.GetType(new EntityDefinition()
            {
                EntityName = "Person", EntityFields = definition
            });

            try
            {
                obj.SetProperty("IncrementedAge1", 23);
                Assert.Fail("IncrementedAge1 should not be present in Person definition");
            }
            catch
            {
            }
        }
 public GameInfrastructure()
 {
     EntityFacade = new EntityFacade();
 }