void Visit(ContractDescription contractDescription) { bool isDuplex = IsDuplex(contractDescription); this.contractMemberScope = new UniqueCodeIdentifierScope(); this.callbackMemberScope = isDuplex ? new UniqueCodeIdentifierScope() : null; UniqueCodeNamespaceScope codeNamespaceScope = new UniqueCodeNamespaceScope(parent.NamespaceManager.EnsureNamespace(contractDescription.Namespace)); CodeTypeDeclaration contract = typeFactory.CreateInterfaceType(); CodeTypeReference contractReference = codeNamespaceScope.AddUnique(contract, contractDescription.CodeName, Strings.DefaultContractName); CodeTypeDeclaration callbackContract = null; CodeTypeReference callbackContractReference = null; if (isDuplex) { callbackContract = typeFactory.CreateInterfaceType(); callbackContractReference = codeNamespaceScope.AddUnique(callbackContract, contractDescription.CodeName + Strings.CallbackTypeSuffix, Strings.DefaultContractName); } this.context = new ServiceContractGenerationContext(parent, contractDescription, contract, callbackContract); this.context.Namespace = codeNamespaceScope.CodeNamespace; this.context.TypeFactory = this.typeFactory; this.context.ContractTypeReference = contractReference; this.context.DuplexCallbackTypeReference = callbackContractReference; AddServiceContractAttribute(this.context); }
private void Visit(ContractDescription contractDescription) { bool flag = IsDuplex(contractDescription); this.contractMemberScope = new UniqueCodeIdentifierScope(); this.callbackMemberScope = flag ? new UniqueCodeIdentifierScope() : null; UniqueCodeNamespaceScope scope = new UniqueCodeNamespaceScope(this.parent.NamespaceManager.EnsureNamespace(contractDescription.Namespace)); CodeTypeDeclaration codeType = this.typeFactory.CreateInterfaceType(); CodeTypeReference reference = scope.AddUnique(codeType, contractDescription.CodeName, "IContract"); CodeTypeDeclaration declaration2 = null; CodeTypeReference reference2 = null; if (flag) { declaration2 = this.typeFactory.CreateInterfaceType(); reference2 = scope.AddUnique(declaration2, contractDescription.CodeName + "Callback", "IContract"); } this.context = new ServiceContractGenerationContext(this.parent, contractDescription, codeType, declaration2); this.context.Namespace = scope.CodeNamespace; this.context.TypeFactory = this.typeFactory; this.context.ContractTypeReference = reference; this.context.DuplexCallbackTypeReference = reference2; this.AddServiceContractAttribute(this.context); }