Ejemplo n.º 1
0
 public static IEnumerable <ApiDefinition> GetApiDefinitions(this DataGraphClass classItem, DataGraphSchema schema, string pathPrefix)
 {
     foreach (var prop in classItem.Properties)
     {
         yield return(new ApiDefinition()
         {
             RelativePath = pathPrefix + "/" + prop.Name,
             ReturnFormat = prop.GetApiReturnFormat(schema).ToString()
         });
     }
 }
Ejemplo n.º 2
0
        public static JObject GetApiReturnFormat(this DataGraphClass classItem, DataGraphSchema schema)
        {
            JObject obj = new JObject();

            obj.Add("Id", obj.GetHashCode());

            foreach (var prop in classItem.Properties)
            {
                obj.Add(prop.Name, prop.GetApiReturnFormat(schema));
            }

            return(obj);
        }
Ejemplo n.º 3
0
        private DataGraphObject AddObject(string customerId, int graphId, string userId, DataGraphClass customType, JObject obj)
        {
            var newObject = new DataGraphObject
            {
                CustomerId = customerId,
                GraphId    = graphId,
                ObjectType = customType.ClassName,
                UserId     = userId
            };

            foreach (var p in obj.Properties())
            {
                if (customType.TryGetProperty(p.Name, out DataGraphProperty typeProp))
                {
                    // Scoping it to simple props right now
                    if (!typeProp.IsCustomType() && !typeProp.IsArray)
                    {
                        AssertTypeMatches(p.Value, typeProp);

                        _context.LiteralPropertyValues.Add(new DataGraphLiteralPropertyValue()
                        {
                            CustomerId       = customerId,
                            GraphId          = graphId,
                            Object           = newObject,
                            PropertyName     = typeProp.Name,
                            ProperyValueJson = p.Value.ToString(Newtonsoft.Json.Formatting.None)
                        });
                    }
                }
            }

            return(newObject);
        }