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(),
     });
 }
Ejemplo n.º 5
0
 private object ParseValue(string value, EdmPropertyType propertyType)
 {
     return value == "null" ? null
         : propertyType.Name == EdmType.Boolean.Name ? bool.Parse(value)
         : propertyType.Name == EdmType.Byte.Name ? byte.Parse(value)
         : propertyType.Name == EdmType.SByte.Name ? sbyte.Parse(value)
         : propertyType.Name == EdmType.DateTime.Name ? DateTime.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.DateTimeOffset.Name ? DateTimeOffset.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int16.Name ? short.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int32.Name ? int.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int64.Name ? long.Parse(value.TrimEnd('L'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Single.Name ? float.Parse(value.TrimEnd('f'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Float.Name ? float.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Double.Name ? double.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Decimal.Name ? decimal.Parse(value.TrimEnd('M', 'm'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Guid.Name ? Guid.Parse(value.Replace("'", "").Replace("guid", ""))
         : propertyType.Name == EdmType.String.Name ? Uri.UnescapeDataString(value.Substring(1, value.Length - 2))
         : propertyType.Name == EdmType.Time.Name ? TimeSpan.Parse(value, CultureInfo.InvariantCulture)
         : (object)value;
 }
Ejemplo n.º 6
0
 public object ParseValue(string value, EdmPropertyType propertyType)
 {
     return value == "null" ? null
         : propertyType.Name == EdmType.Binary.Name ? ParseBinary(RemoveLiteral(RemoveLiteral(value, "binary"), "X"))
         : propertyType.Name == EdmType.Boolean.Name ? bool.Parse(value)
         : propertyType.Name == EdmType.Byte.Name ? byte.Parse(value)
         : propertyType.Name == EdmType.SByte.Name ? sbyte.Parse(value)
         : propertyType.Name == EdmType.DateTime.Name ? DateTime.Parse(RemoveLiteral(value, "datetime"), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.DateTimeOffset.Name ? DateTimeOffset.Parse(RemoveLiteral(value, "datetimeoffset"), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int16.Name ? short.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int32.Name ? int.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Int64.Name ? long.Parse(value.TrimEnd('L'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Single.Name ? float.Parse(value.TrimEnd('f'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Float.Name ? float.Parse(value, CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Double.Name ? double.Parse(value.TrimEnd('d'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Decimal.Name ? decimal.Parse(value.TrimEnd('M', 'm'), CultureInfo.InvariantCulture)
         : propertyType.Name == EdmType.Guid.Name ? Guid.Parse(RemoveLiteral(value, "guid"))
         : propertyType.Name == EdmType.String.Name ? Uri.UnescapeDataString(value.Substring(1, value.Length - 2))
         : propertyType.Name == EdmType.Time.Name ? TimeSpan.Parse(RemoveLiteral(value, "time"), CultureInfo.InvariantCulture)
         : (propertyType is EdmEnumPropertyType) ? ParseEnum(value, propertyType as EdmEnumPropertyType)
         : (object)value;
 }
Ejemplo n.º 7
0
 public Column(string actualName, EdmPropertyType propertyType, bool isNullable)
 {
     _actualName   = actualName;
     _propertyType = propertyType;
     _isNullable   = isNullable;
 }
Ejemplo n.º 8
0
 public Column(string actualName, EdmPropertyType propertyType, bool isNullable)
 {
     _actualName = actualName;
     _propertyType = propertyType;
     _isNullable = isNullable;
 }