protected override CodeTypeDeclaration BeginClass() { MethodNames.Clear(); ExtraCodeClasses.Clear(); CodeAttributeDeclarationCollection metadata = new CodeAttributeDeclarationCollection(); if (Style == ServiceDescriptionImportStyle.Client) { WebCodeGenerator.AddCustomAttribute(metadata, typeof(DebuggerStepThroughAttribute), new CodeExpression[0]); WebCodeGenerator.AddCustomAttribute(metadata, typeof(DesignerCategoryAttribute), new CodeExpression[] { new CodePrimitiveExpression("code") }); } Type[] requiredTypes = new Type[] { typeof(SoapDocumentMethodAttribute), typeof(XmlAttributeAttribute), typeof(WebService), typeof(Object), typeof(DebuggerStepThroughAttribute), typeof(DesignerCategoryAttribute), typeof(TransactionOption), }; WebCodeGenerator.AddImports(this.CodeNamespace, WebCodeGenerator.GetNamespacesForTypes(requiredTypes)); CodeFlags flags = 0; if (Style == ServiceDescriptionImportStyle.Server) { flags = CodeFlags.IsAbstract; } else if (Style == ServiceDescriptionImportStyle.ServerInterface) { flags = CodeFlags.IsInterface; } CodeTypeDeclaration codeClass = WebCodeGenerator.CreateClass(this.ClassName, BaseClass.FullName, new string[0], metadata, CodeFlags.IsPublic | flags, ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes)); codeClass.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); CodeConstructor ctor = WebCodeGenerator.AddConstructor(codeClass, new string[0], new string[0], null, CodeFlags.IsPublic); ctor.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); HttpAddressBinding httpAddressBinding = Port == null ? null : (HttpAddressBinding)Port.Extensions.Find(typeof(HttpAddressBinding)); string url = (httpAddressBinding != null) ? httpAddressBinding.Location : null; ServiceDescription serviceDescription = Binding.ServiceDescription; ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, serviceDescription.AppSettingUrlKey, serviceDescription.AppSettingBaseUrl, false); codeClasses.Add(codeClass); return(codeClass); }
// These overridable methods have no parameters. The subclass uses properties on this // base object to obtain the information. This allows us to grow the set of // information passed to the methods over time w/o breaking anyone. They are protected // instead of public because this object is passed to extensions and we don't want // those calling these methods. /// <include file='doc\ProtocolImporter.uex' path='docs/doc[@for="ProtocolImporter.BeginNamespace"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected virtual void BeginNamespace() { MethodNames.Clear(); }