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

AddIncludeMetadata() static private method

static private AddIncludeMetadata ( CodeAttributeDeclarationCollection metadata, StructMapping mapping, Type type ) : void
metadata System.CodeDom.CodeAttributeDeclarationCollection
mapping StructMapping
type System.Type
return void
        internal static void AddIncludeMetadata(CodeAttributeDeclarationCollection metadata, StructMapping mapping, Type type) {
            if (mapping.IsAnonymousType)
                return;
            for (StructMapping derived = mapping.DerivedMappings; derived != null; derived = derived.NextDerivedMapping) {
                CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(type.FullName);
                attribute.Arguments.Add(new CodeAttributeArgument(new CodeTypeOfExpression(derived.TypeDesc.FullName)));
                metadata.Add(attribute);
                AddIncludeMetadata(metadata, derived, type);
            }
        }

Usage Example

Example #1
0
        private CodeTypeDeclaration ExportStruct(StructMapping mapping)
        {
            if (mapping.TypeDesc.IsRoot)
            {
                base.ExportRoot(mapping, typeof(SoapIncludeAttribute));
                return(null);
            }
            if (!mapping.IncludeInSchema)
            {
                return(null);
            }
            string name = mapping.TypeDesc.Name;
            string str2 = (mapping.TypeDesc.BaseTypeDesc == null) ? string.Empty : mapping.TypeDesc.BaseTypeDesc.Name;
            CodeTypeDeclaration declaration = new CodeTypeDeclaration(name)
            {
                IsPartial = base.CodeProvider.Supports(GeneratorSupport.PartialTypes)
            };

            declaration.Comments.Add(new CodeCommentStatement(Res.GetString("XmlRemarks"), true));
            base.CodeNamespace.Types.Add(declaration);
            if ((str2 != null) && (str2.Length > 0))
            {
                declaration.BaseTypes.Add(str2);
            }
            else
            {
                base.AddPropertyChangedNotifier(declaration);
            }
            declaration.TypeAttributes |= TypeAttributes.Public;
            if (mapping.TypeDesc.IsAbstract)
            {
                declaration.TypeAttributes |= TypeAttributes.Abstract;
            }
            CodeExporter.AddIncludeMetadata(declaration.CustomAttributes, mapping, typeof(SoapIncludeAttribute));
            if (base.GenerateProperties)
            {
                for (int j = 0; j < mapping.Members.Length; j++)
                {
                    this.ExportProperty(declaration, mapping.Members[j], mapping.Scope);
                }
            }
            else
            {
                for (int k = 0; k < mapping.Members.Length; k++)
                {
                    this.ExportMember(declaration, mapping.Members[k]);
                }
            }
            for (int i = 0; i < mapping.Members.Length; i++)
            {
                this.EnsureTypesExported(mapping.Members[i].Elements, null);
            }
            if (mapping.BaseMapping != null)
            {
                this.ExportType(mapping.BaseMapping);
            }
            this.ExportDerivedStructs(mapping);
            CodeGenerator.ValidateIdentifiers(declaration);
            return(declaration);
        }
All Usage Examples Of System.Xml.Serialization.CodeExporter::AddIncludeMetadata