Ejemplo n.º 1
0
 public static ComplexType FromXml(XElement xml)
 {
     if (xml.Name.LocalName != ElementName) throw new ArgumentException("xml was not a ComplexType element");
     var obj = new ComplexType { Name = xml.AttributeValue("Name") };
     obj.Properties.AddRange(from e in xml.Elements()
                             where e.Name.LocalName == "Property"
                             select Property.FromXml(e));
     return obj;
 }
Ejemplo n.º 2
0
 private static string BuildJsonExample(ComplexType ct, IEnumerable<Schema> otherSchema)
 {
     Dictionary<string, object> dict = BuildDictionaryExample(ct, otherSchema);
     return JsonConvert.SerializeObject(dict);
 }
Ejemplo n.º 3
0
 private static Dictionary<string, object> BuildDictionaryExample(ComplexType ct, IEnumerable<Schema> otherSchema)
 {
     return ct.Properties.Where(prop => prop.Type != "Edm.Stream").ToDictionary(prop => prop.Name, prop => ExampleOfType(prop.Type, otherSchema));
 }
Ejemplo n.º 4
0
 private static ResourceDefinition ResourceDefinitionFromType(Schema schema, IEnumerable<Schema> otherSchema, ComplexType ct)
 {
     var annotation = new CodeBlockAnnotation() { ResourceType = string.Concat(schema.Namespace, ".", ct.Name), BlockType = CodeBlockType.Resource };
     var json = BuildJsonExample(ct, otherSchema);
     ResourceDefinition rd = new JsonResourceDefinition(annotation, json, null);
     return rd;
 }
Ejemplo n.º 5
0
 internal void RenameEntityType(ComplexType renamedType)
 {
     // renamedType could be ComplexType or EntityType
     this.RenameTypeInObjectGraph(renamedType.WorkloadName, renamedType.Name);
 }
Ejemplo n.º 6
0
 private static Dictionary <string, object> BuildDictionaryExample(ComplexType ct, IEnumerable <Schema> otherSchema)
 {
     return(ct.Properties.Where(prop => prop.Type != "Edm.Stream").ToDictionary(prop => prop.Name, prop => ExampleOfType(prop.Type, otherSchema)));
 }
Ejemplo n.º 7
0
        private static string BuildJsonExample(ComplexType ct, IEnumerable <Schema> otherSchema)
        {
            Dictionary <string, object> dict = BuildDictionaryExample(ct, otherSchema);

            return(JsonConvert.SerializeObject(dict));
        }
Ejemplo n.º 8
0
        private static ResourceDefinition ResourceDefinitionFromType(Schema schema, IEnumerable <Schema> otherSchema, ComplexType ct)
        {
            var annotation = new CodeBlockAnnotation()
            {
                ResourceType = string.Concat(schema.Namespace, ".", ct.Name), BlockType = CodeBlockType.Resource
            };
            var json = BuildJsonExample(ct, otherSchema);
            ResourceDefinition rd = new ResourceDefinition(annotation, json, null, "json");

            return(rd);
        }