internal void WriteAssociationEndElementHeader(RelationshipEndMember associationEnd)
 {
     this._xmlWriter.WriteStartElement("End");
     this._xmlWriter.WriteAttributeString("Role", associationEnd.Name);
     this._xmlWriter.WriteAttributeString("Type", XmlSchemaWriter.GetQualifiedTypeName("Self", associationEnd.GetEntityType().Name));
     this._xmlWriter.WriteAttributeString("Multiplicity", RelationshipMultiplicityConverter.MultiplicityToString(associationEnd.RelationshipMultiplicity));
 }
        public virtual void WriteFunctionElementHeader(EdmFunction function)
        {
            this._xmlWriter.WriteStartElement("Function");
            this._xmlWriter.WriteAttributeString("Name", function.Name);
            this._xmlWriter.WriteAttributeString("Aggregate", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(function.AggregateAttribute));
            this._xmlWriter.WriteAttributeString("BuiltIn", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(function.BuiltInAttribute));
            this._xmlWriter.WriteAttributeString("NiladicFunction", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(function.NiladicFunctionAttribute));
            this._xmlWriter.WriteAttributeString("IsComposable", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(function.IsComposableAttribute));
            this._xmlWriter.WriteAttributeString("ParameterTypeSemantics", function.ParameterTypeSemanticsAttribute.ToString());
            this._xmlWriter.WriteAttributeString("Schema", function.Schema);
            if (function.StoreFunctionNameAttribute != null && function.StoreFunctionNameAttribute != function.Name)
            {
                this._xmlWriter.WriteAttributeString("StoreFunctionName", function.StoreFunctionNameAttribute);
            }
            if (function.ReturnParameters == null || !function.ReturnParameters.Any <FunctionParameter>())
            {
                return;
            }
            EdmType edmType = function.ReturnParameters.First <FunctionParameter>().TypeUsage.EdmType;

            if (edmType.BuiltInTypeKind != BuiltInTypeKind.PrimitiveType)
            {
                return;
            }
            this._xmlWriter.WriteAttributeString("ReturnType", EdmXmlSchemaWriter.GetTypeName(edmType));
        }
 internal void WriteNavigationPropertyElementHeader(NavigationProperty member)
 {
     this._xmlWriter.WriteStartElement("NavigationProperty");
     this._xmlWriter.WriteAttributeString("Name", member.Name);
     this._xmlWriter.WriteAttributeString("Relationship", XmlSchemaWriter.GetQualifiedTypeName("Self", member.Association.Name));
     this._xmlWriter.WriteAttributeString("FromRole", member.GetFromEnd().Name);
     this._xmlWriter.WriteAttributeString("ToRole", member.ToEndMember.Name);
 }
 private static string GetTypeReferenceName(EdmProperty property)
 {
     if (property.IsPrimitiveType)
     {
         return(property.TypeName);
     }
     if (property.IsComplexType)
     {
         return(XmlSchemaWriter.GetQualifiedTypeName("Self", property.ComplexType.Name));
     }
     return(XmlSchemaWriter.GetQualifiedTypeName("Self", property.EnumType.Name));
 }
 internal void WriteEnumTypeElementHeader(EnumType enumType)
 {
     this._xmlWriter.WriteStartElement("EnumType");
     this._xmlWriter.WriteAttributeString("Name", enumType.Name);
     this._xmlWriter.WriteAttributeString("IsFlags", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(enumType.IsFlags));
     this.WriteExtendedProperties((MetadataItem)enumType);
     if (enumType.UnderlyingType == null)
     {
         return;
     }
     this._xmlWriter.WriteAttributeString("UnderlyingType", enumType.UnderlyingType.PrimitiveTypeKind.ToString());
 }
 private void WritePolymorphicTypeAttributes(EdmType edmType)
 {
     if (edmType.BaseType != null)
     {
         this._xmlWriter.WriteAttributeString("BaseType", XmlSchemaWriter.GetQualifiedTypeName("Self", edmType.BaseType.Name));
     }
     if (!edmType.Abstract)
     {
         return;
     }
     this._xmlWriter.WriteAttributeString("Abstract", "true");
 }
 internal virtual void WriteEntitySetElementHeader(EntitySet entitySet)
 {
     this._xmlWriter.WriteStartElement("EntitySet");
     this._xmlWriter.WriteAttributeString("Name", entitySet.Name);
     this._xmlWriter.WriteAttributeString("EntityType", XmlSchemaWriter.GetQualifiedTypeName("Self", entitySet.ElementType.Name));
     if (!string.IsNullOrWhiteSpace(entitySet.Schema))
     {
         this._xmlWriter.WriteAttributeString("Schema", entitySet.Schema);
     }
     if (!string.IsNullOrWhiteSpace(entitySet.Table))
     {
         this._xmlWriter.WriteAttributeString("Table", entitySet.Table);
     }
     this.WriteExtendedProperties((MetadataItem)entitySet);
 }
 internal void WriteAssociationSetElementHeader(AssociationSet associationSet)
 {
     this._xmlWriter.WriteStartElement("AssociationSet");
     this._xmlWriter.WriteAttributeString("Name", associationSet.Name);
     this._xmlWriter.WriteAttributeString("Association", XmlSchemaWriter.GetQualifiedTypeName("Self", associationSet.ElementType.Name));
 }
        internal void WritePropertyElementHeader(EdmProperty property)
        {
            this._xmlWriter.WriteStartElement("Property");
            this._xmlWriter.WriteAttributeString("Name", property.Name);
            this._xmlWriter.WriteAttributeString("Type", EdmXmlSchemaWriter.GetTypeReferenceName(property));
            if (property.CollectionKind != CollectionKind.None)
            {
                this._xmlWriter.WriteAttributeString("CollectionKind", property.CollectionKind.ToString());
            }
            if (property.ConcurrencyMode == ConcurrencyMode.Fixed)
            {
                this._xmlWriter.WriteAttributeString("ConcurrencyMode", "Fixed");
            }
            this.WriteExtendedProperties((MetadataItem)property);
            if (property.Annotations.GetClrAttributes() != null)
            {
                int num1 = 0;
                foreach (Attribute clrAttribute in (IEnumerable <Attribute>)property.Annotations.GetClrAttributes())
                {
                    if (clrAttribute.GetType().FullName.Equals("System.Data.Services.MimeTypeAttribute", StringComparison.Ordinal))
                    {
                        this._xmlWriter.WriteAttributeString("m", "MimeType", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", clrAttribute.GetType().GetDeclaredProperty("MimeType").GetValue((object)clrAttribute, (object[])null) as string);
                    }
                    else if (clrAttribute.GetType().FullName.Equals("System.Data.Services.Common.EntityPropertyMappingAttribute", StringComparison.Ordinal))
                    {
                        string str1;
                        if (num1 != 0)
                        {
                            str1 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "_{0}", (object)num1);
                        }
                        else
                        {
                            str1 = string.Empty;
                        }
                        string str2 = str1;
                        string str3 = clrAttribute.GetType().GetDeclaredProperty("SourcePath").GetValue((object)clrAttribute, (object[])null) as string;
                        int    num2 = str3.IndexOf("/", StringComparison.Ordinal);
                        if (num2 != -1 && num2 + 1 < str3.Length)
                        {
                            this._xmlWriter.WriteAttributeString("m", "FC_SourcePath" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str3.Substring(num2 + 1));
                        }
                        object       obj1             = clrAttribute.GetType().GetDeclaredProperty("TargetSyndicationItem").GetValue((object)clrAttribute, (object[])null);
                        string       str4             = clrAttribute.GetType().GetDeclaredProperty("KeepInContent").GetValue((object)clrAttribute, (object[])null).ToString();
                        PropertyInfo declaredProperty = clrAttribute.GetType().GetDeclaredProperty("CriteriaValue");
                        string       str5             = (string)null;
                        if (declaredProperty != (PropertyInfo)null)
                        {
                            str5 = declaredProperty.GetValue((object)clrAttribute, (object[])null) as string;
                        }
                        if (str5 != null)
                        {
                            this._xmlWriter.WriteAttributeString("m", "FC_TargetPath" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", EdmXmlSchemaWriter.SyndicationItemPropertyToString(obj1));
                            this._xmlWriter.WriteAttributeString("m", "FC_KeepInContent" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str4);
                            this._xmlWriter.WriteAttributeString("m", "FC_CriteriaValue" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str5);
                        }
                        else if (string.Equals(obj1.ToString(), "CustomProperty", StringComparison.Ordinal))
                        {
                            string str6 = clrAttribute.GetType().GetDeclaredProperty("TargetPath").GetValue((object)clrAttribute, (object[])null).ToString();
                            string str7 = clrAttribute.GetType().GetDeclaredProperty("TargetNamespacePrefix").GetValue((object)clrAttribute, (object[])null).ToString();
                            string str8 = clrAttribute.GetType().GetDeclaredProperty("TargetNamespaceUri").GetValue((object)clrAttribute, (object[])null).ToString();
                            this._xmlWriter.WriteAttributeString("m", "FC_TargetPath" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str6);
                            this._xmlWriter.WriteAttributeString("m", "FC_NsUri" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str8);
                            this._xmlWriter.WriteAttributeString("m", "FC_NsPrefix" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str7);
                            this._xmlWriter.WriteAttributeString("m", "FC_KeepInContent" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str4);
                        }
                        else
                        {
                            object obj2 = clrAttribute.GetType().GetDeclaredProperty("TargetTextContentKind").GetValue((object)clrAttribute, (object[])null);
                            this._xmlWriter.WriteAttributeString("m", "FC_TargetPath" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", EdmXmlSchemaWriter.SyndicationItemPropertyToString(obj1));
                            this._xmlWriter.WriteAttributeString("m", "FC_ContentKind" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", EdmXmlSchemaWriter.SyndicationTextContentKindToString(obj2));
                            this._xmlWriter.WriteAttributeString("m", "FC_KeepInContent" + str2, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", str4);
                        }
                        ++num1;
                    }
                }
            }
            if (property.IsMaxLength)
            {
                this._xmlWriter.WriteAttributeString("MaxLength", "Max");
            }
            else if (!property.IsMaxLengthConstant && property.MaxLength.HasValue)
            {
                this._xmlWriter.WriteAttributeString("MaxLength", property.MaxLength.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            if (!property.IsFixedLengthConstant && property.IsFixedLength.HasValue)
            {
                this._xmlWriter.WriteAttributeString("FixedLength", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(property.IsFixedLength.Value));
            }
            if (!property.IsUnicodeConstant && property.IsUnicode.HasValue)
            {
                this._xmlWriter.WriteAttributeString("Unicode", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(property.IsUnicode.Value));
            }
            if (!property.IsPrecisionConstant && property.Precision.HasValue)
            {
                this._xmlWriter.WriteAttributeString("Precision", property.Precision.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            if (!property.IsScaleConstant && property.Scale.HasValue)
            {
                this._xmlWriter.WriteAttributeString("Scale", property.Scale.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            if (property.StoreGeneratedPattern != StoreGeneratedPattern.None)
            {
                this._xmlWriter.WriteAttributeString("StoreGeneratedPattern", property.StoreGeneratedPattern == StoreGeneratedPattern.Computed ? "Computed" : "Identity");
            }
            if (this._serializeDefaultNullability || !property.Nullable)
            {
                this._xmlWriter.WriteAttributeString("Nullable", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(property.Nullable));
            }
            MetadataProperty metadataProperty;

            if (!property.MetadataProperties.TryGetValue("http://schemas.microsoft.com/ado/2009/02/edm/annotation:StoreGeneratedPattern", false, out metadataProperty))
            {
                return;
            }
            this._xmlWriter.WriteAttributeString("StoreGeneratedPattern", "http://schemas.microsoft.com/ado/2009/02/edm/annotation", metadataProperty.Value.ToString());
        }
 private void WriteIsNullConditionAttribute(bool isNullValue)
 {
     this._xmlWriter.WriteAttributeString("IsNull", XmlSchemaWriter.GetLowerCaseStringFromBoolValue(isNullValue));
 }