Composite.Data.DynamicTypes.DataTypeDescriptor.ToXml C# (CSharp) Метод

ToXml() публичный Метод

Serialize the data type description to XML
public ToXml ( ) : System.Xml.Linq.XElement
Результат System.Xml.Linq.XElement
        public XElement ToXml()
        {
            var element = new XElement("DataTypeDescriptor",
                new XAttribute("dataTypeId", this.DataTypeId),
                new XAttribute("name", this.Name),
                new XAttribute("namespace", this.Namespace),
                this.Title != null ? new XAttribute("title", this.Title) : null,
                new XAttribute("isCodeGenerated", this.IsCodeGenerated),
                new XAttribute("cachable", this.Cachable),
                this.LabelFieldName != null ? new XAttribute("labelFieldName", this.LabelFieldName) : null,
                !string.IsNullOrEmpty(this.InternalUrlPrefix) ? new XAttribute("internalUrlPrefix", this.InternalUrlPrefix) : null,
                this.TypeManagerTypeName != null ? new XAttribute("typeManagerTypeName", this.TypeManagerTypeName) : null,
                !string.IsNullOrEmpty(this.BuildNewHandlerTypeName) ? new XAttribute("buildNewHandlerTypeName", this.BuildNewHandlerTypeName) : null);


            element.Add(new[]
            {
                new XElement("DataAssociations",
                              DataAssociations.Select(da => da.ToXml())),
                new XElement("DataScopes", 
                              DataScopes.Select(dsi => new XElement("DataScopeIdentifier", new XAttribute("name", dsi)))),
                new XElement("KeyPropertyNames",
                              KeyPropertyNames.Select(name => new XElement("KeyPropertyName", new XAttribute("name", name)))),
                VersionKeyPropertyNames.Any() 
                    ? new XElement("VersionKeyPropertyNames",
                            VersionKeyPropertyNames.Select(name => new XElement("VersionKeyPropertyName", new XAttribute("name", name))))
                    : null,
                new XElement("SuperInterfaces", 
                              SuperInterfaces.Select(su => new XElement("SuperInterface", new XAttribute("type", TypeManager.SerializeType(su))))),
                new XElement("Fields", Fields.Select(f => f.ToXml()))
            });
            
            if (Indexes.Any())
            {
                element.Add(new XElement("Indexes", Indexes.Select(i => i.ToXml())));   
            }

            return element;
        }

Usage Example

        public bool TrySerialize(Type objectToSerializeType, object objectToSerialize, IXmlSerializer xmlSerializer, out XElement serializedObject)
        {
            if (objectToSerializeType == null)
            {
                throw new ArgumentNullException("objectToSerializeType");
            }

            serializedObject = null;

            if (objectToSerializeType != typeof(DataTypeDescriptor))
            {
                return(false);
            }

            if (objectToSerialize == null)
            {
                serializedObject = new XElement("DataTypeDescriptor");
            }
            else
            {
                DataTypeDescriptor dataTypeDescriptor = (DataTypeDescriptor)objectToSerialize;

                serializedObject = dataTypeDescriptor.ToXml();
            }

            return(true);
        }
All Usage Examples Of Composite.Data.DynamicTypes.DataTypeDescriptor::ToXml