Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }