System.Xml.Serialization.CodeExporter.AddTypeMetadata C# (CSharp) Method

AddTypeMetadata() private method

private AddTypeMetadata ( CodeAttributeDeclarationCollection metadata, Type type, string defaultName, string name, string ns, bool includeInSchema ) : void
metadata System.CodeDom.CodeAttributeDeclarationCollection
type System.Type
defaultName string
name string
ns string
includeInSchema bool
return void
        internal void AddTypeMetadata(CodeAttributeDeclarationCollection metadata, Type type, string defaultName, string name, string ns, bool includeInSchema) {
            CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(type.FullName);
            if (name == null || name.Length == 0) {
                attribute.Arguments.Add(new CodeAttributeArgument("AnonymousType", new CodePrimitiveExpression(true)));
            }
            else {
                if (defaultName != name) {
                    attribute.Arguments.Add(new CodeAttributeArgument("TypeName", new CodePrimitiveExpression(name)));
                }
                if (ns != null && ns.Length != 0) {
                    attribute.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(ns)));
                }
            }
            if (!includeInSchema) {
                attribute.Arguments.Add(new CodeAttributeArgument("IncludeInSchema", new CodePrimitiveExpression(false)));
            }
            if (attribute.Arguments.Count > 0) {
                metadata.Add(attribute);
            }
        }