ContractCacheEntry ExportInterface_internal(ContractDescription cd, CodeNamespace cns)
        {
            if (generated_contracts.ContainsKey(cd))
            {
                return(generated_contracts [cd]);
            }

            var type = new CodeTypeDeclaration();

            type.TypeAttributes  = TypeAttributes.Interface;
            type.TypeAttributes |= TypeAttributes.Public;
            cns.Types.Add(type);
            type.Name = identifiers.AddUnique(cd.Name, null);

            var configName = type.Name;
            CodeAttributeDeclaration ad =
                new CodeAttributeDeclaration(
                    new CodeTypeReference(
                        typeof(ServiceContractAttribute)));

            ad.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(cd.Namespace)));
            ad.Arguments.Add(new CodeAttributeArgument("ConfigurationName", new CodePrimitiveExpression(configName)));
            type.CustomAttributes.Add(ad);
            contract_context = new ServiceContractGenerationContext(this, cd, type);

            AddOperationMethods(type, cd);

            var cache = new ContractCacheEntry(cd, configName, type);

            generated_contracts.Add(cd, cache);
            return(cache);
        }
Exemplo n.º 2
0
		ContractCacheEntry ExportInterface_internal (ContractDescription cd, CodeNamespace cns)
		{
			if (generated_contracts.ContainsKey (cd))
				return generated_contracts [cd];

			var type = new CodeTypeDeclaration ();
			type.TypeAttributes = TypeAttributes.Interface;
			type.TypeAttributes |= TypeAttributes.Public;
			cns.Types.Add (type);
			type.Name = identifiers.AddUnique (cd.Name, null);

			var configName = type.Name;
			CodeAttributeDeclaration ad = 
				new CodeAttributeDeclaration (
					new CodeTypeReference (
					typeof (ServiceContractAttribute)));
			ad.Arguments.Add (new CodeAttributeArgument ("Namespace", new CodePrimitiveExpression (cd.Namespace)));
			ad.Arguments.Add (new CodeAttributeArgument ("ConfigurationName", new CodePrimitiveExpression (configName)));
			type.CustomAttributes.Add (ad);
			contract_context = new ServiceContractGenerationContext (this, cd, type);
			
			AddOperationMethods (type, cd);

			var cache = new ContractCacheEntry (cd, configName, type);
			generated_contracts.Add (cd, cache);
			return cache;
		}