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
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);
        }
        CodeTypeDeclaration ExportStruct(StructMapping mapping)
        {
            if (mapping.TypeDesc.IsRoot)
            {
                ExportRoot(mapping, typeof(SoapIncludeAttribute));
                return(null);
            }
            if (!mapping.IncludeInSchema)
            {
                return(null);
            }

            string className = mapping.TypeDesc.Name;
            string baseName  = mapping.TypeDesc.BaseTypeDesc == null ? string.Empty : mapping.TypeDesc.BaseTypeDesc.Name;

            CodeTypeDeclaration codeClass = new CodeTypeDeclaration(className);

            codeClass.IsPartial = CodeProvider.Supports(GeneratorSupport.PartialTypes);
            codeClass.Comments.Add(new CodeCommentStatement(Res.GetString(Res.XmlRemarks), true));

            CodeNamespace.Types.Add(codeClass);

            if (baseName != null && baseName.Length > 0)
            {
                codeClass.BaseTypes.Add(baseName);
            }
            else
            {
                AddPropertyChangedNotifier(codeClass);
            }

            codeClass.TypeAttributes |= TypeAttributes.Public;
            if (mapping.TypeDesc.IsAbstract)
            {
                codeClass.TypeAttributes |= TypeAttributes.Abstract;
            }

            CodeExporter.AddIncludeMetadata(codeClass.CustomAttributes, mapping, typeof(SoapIncludeAttribute));

            if (GenerateProperties)
            {
                for (int i = 0; i < mapping.Members.Length; i++)
                {
                    ExportProperty(codeClass, mapping.Members[i], mapping.Scope);
                }
            }
            else
            {
                for (int i = 0; i < mapping.Members.Length; i++)
                {
                    ExportMember(codeClass, mapping.Members[i]);
                }
            }
            for (int i = 0; i < mapping.Members.Length; i++)
            {
                EnsureTypesExported(mapping.Members[i].Elements, null);
            }

            if (mapping.BaseMapping != null)
            {
                ExportType(mapping.BaseMapping);
            }

            ExportDerivedStructs(mapping);
            CodeGenerator.ValidateIdentifiers(codeClass);
            return(codeClass);
        }
        private CodeTypeDeclaration ExportStruct(StructMapping mapping)
        {
            CodeConstructor constructor;

            if (mapping.TypeDesc.IsRoot)
            {
                base.ExportRoot(mapping, typeof(XmlIncludeAttribute));
                return(null);
            }
            string name = mapping.TypeDesc.Name;
            string str2 = ((mapping.TypeDesc.BaseTypeDesc == null) || mapping.TypeDesc.BaseTypeDesc.IsRoot) ? string.Empty : mapping.TypeDesc.BaseTypeDesc.FullName;
            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);
            constructor = new CodeConstructor {
                Attributes = (constructor.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public
            };
            declaration.Members.Add(constructor);
            if (mapping.TypeDesc.IsAbstract)
            {
                constructor.Attributes |= MemberAttributes.Abstract;
            }
            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(XmlIncludeAttribute));
            if (mapping.IsSequence)
            {
                int num = 0;
                for (int j = 0; j < mapping.Members.Length; j++)
                {
                    MemberMapping mapping2 = mapping.Members[j];
                    if (mapping2.IsParticle && (mapping2.SequenceId < 0))
                    {
                        mapping2.SequenceId = num++;
                    }
                }
            }
            if (base.GenerateProperties)
            {
                for (int k = 0; k < mapping.Members.Length; k++)
                {
                    this.ExportProperty(declaration, mapping.Members[k], mapping.Namespace, mapping.Scope, constructor);
                }
            }
            else
            {
                for (int m = 0; m < mapping.Members.Length; m++)
                {
                    this.ExportMember(declaration, mapping.Members[m], mapping.Namespace, constructor);
                }
            }
            for (int i = 0; i < mapping.Members.Length; i++)
            {
                if (mapping.Members[i].Xmlns == null)
                {
                    this.EnsureTypesExported(mapping.Members[i].Elements, mapping.Namespace);
                    this.EnsureTypesExported(mapping.Members[i].Attribute, mapping.Namespace);
                    this.EnsureTypesExported(mapping.Members[i].Text, mapping.Namespace);
                }
            }
            if (mapping.BaseMapping != null)
            {
                this.ExportType(mapping.BaseMapping, null, mapping.Namespace, null, false);
            }
            this.ExportDerivedStructs(mapping);
            CodeGenerator.ValidateIdentifiers(declaration);
            if (constructor.Statements.Count == 0)
            {
                declaration.Members.Remove(constructor);
            }
            return(declaration);
        }