private static CodeTypeDeclaration GetCallbackContractType(CodeTypeDeclaration iface) { CodeAttributeDeclaration serviceContractAttribute = null; foreach (CodeAttributeDeclaration attr in iface.CustomAttributes) { if (CodeDomHelpers.MatchType(attr.AttributeType, typeof(ServiceContractAttribute))) { serviceContractAttribute = attr; break; } } if (serviceContractAttribute != null) { foreach (CodeAttributeArgument arg in serviceContractAttribute.Arguments) { if (arg.Name == "CallbackContract") { CodeTypeOfExpression exp = (CodeTypeOfExpression)arg.Value; return(CodeDomHelpers.ResolveTypeReference(exp.Type)); } } } return(null); }
protected override void VisitClientClass(CodeTypeDeclaration type) { base.VisitClientClass(type); CodeTypeDeclaration serviceContractInterface = CodeDomHelpers.ResolveTypeReference(type.BaseTypes[0].TypeArguments[0]); CodeTypeDeclaration callbackInterface = GetCallbackContractType(serviceContractInterface); RemoveAsyncMethods(callbackInterface); CreateEventBasedDuplexClass(type, callbackInterface); }