Ejemplo n.º 1
0
 private static EdmProperty ParseProperty(
     XElement element,
     IEnumerable <EdmComplexType> complexTypes,
     IEnumerable <EdmEntityType> entityTypes)
 {
     return(new EdmProperty
     {
         Name = element.Attribute("Name").Value,
         Type = EdmPropertyType.Parse(element.Attribute("Type").Value, complexTypes, entityTypes),
         Nullable = ParseBooleanAttribute(element.Attribute("Nullable")),
     });
 }
Ejemplo n.º 2
0
        private static EdmPropertyType ParseType(
            XAttribute attribute,
            IEnumerable <EdmComplexType> complexTypes,
            IEnumerable <EdmEntityType> entityTypes)
        {
            if (attribute == null || attribute.Value == null)
            {
                return(null);
            }

            var attritbuteValue = ParseStringAttribute(attribute);

            return(EdmPropertyType.Parse(attritbuteValue, complexTypes, entityTypes));
        }
Ejemplo n.º 3
0
 private static Tuple <bool, EdmCollectionPropertyType> TryParseCollectionType(string s, IEnumerable <EdmComplexType> complexTypes, IEnumerable <EdmEntityType> entityTypes)
 {
     if (s.StartsWith("Collection(") && s.EndsWith(")"))
     {
         int start    = s.IndexOf("(");
         int end      = s.LastIndexOf(")");
         var baseType = EdmPropertyType.Parse(s.Substring(start + 1, end - start - 1), complexTypes, entityTypes);
         return(new Tuple <bool, EdmCollectionPropertyType>(true, new EdmCollectionPropertyType()
         {
             BaseType = baseType
         }));
     }
     else
     {
         return(new Tuple <bool, EdmCollectionPropertyType>(false, null));
     }
 }
Ejemplo n.º 4
0
 private static IEnumerable <EdmEntityContainer> ParseEntityContainers(
     IEnumerable <XElement> elements,
     IEnumerable <EdmComplexType> complexTypes,
     IEnumerable <EdmEntityType> entityTypes)
 {
     return(from e in elements
            select new EdmEntityContainer()
     {
         Name = e.Attribute("Name").Value,
         IsDefaulEntityContainer = ParseBooleanAttribute(e.Attribute("m", "IsDefaultEntityContainer")),
         EntitySets = (from s in e.Descendants(null, "EntitySet")
                       select new EdmEntitySet()
         {
             Name = s.Attribute("Name").Value,
             EntityType = s.Attribute("EntityType").Value,
         }).ToArray(),
         AssociationSets = (from s in e.Descendants(null, "AssociationSet")
                            select new EdmAssociationSet()
         {
             Name = s.Attribute("Name").Value,
             Association = s.Attribute("Association").Value,
             End = (from n in s.Descendants(null, "End")
                    select new EdmAssociationSetEnd()
             {
                 Role = n.Attribute("Role").Value,
                 EntitySet = n.Attribute("EntitySet").Value,
             }).ToArray(),
         }).ToArray(),
         FunctionImports = (from s in e.Descendants(null, "FunctionImport")
                            select new EdmFunctionImport()
         {
             Name = s.Attribute("Name").Value,
             HttpMethod = ParseStringAttribute(s.Attribute("m", "HttpMethod")),
             ReturnType = ParseType(s.Attribute("ReturnType"), complexTypes, entityTypes),
             EntitySet = ParseStringAttribute(s.Attribute("EntitySet")),
             Parameters = (from p in s.Descendants(null, "Parameter")
                           select new EdmParameter()
             {
                 Name = p.Attribute("Name").Value,
                 Type = EdmPropertyType.Parse(p.Attribute("Type").Value, complexTypes, entityTypes),
             }).ToArray(),
         }).ToArray(),
     });
 }