Exemple #1
0
        private static void FormatActions(AttributableCodeDomObject method, CodeAttributeDeclaration targetAttribute, string serviceNamespace, string serviceName)
        {
            serviceNamespace = serviceNamespace.TrimEnd('/');
            string operationName = method.ExtendedObject.Name;

            CodeAttributeArgument asyncPatternArgument = targetAttribute.FindArgument("AsyncPattern");

            if (asyncPatternArgument != null)
            {
                CodePrimitiveExpression value = asyncPatternArgument.Value as CodePrimitiveExpression;
                if (value != null && (bool)value.Value && operationName.StartsWith("Begin", StringComparison.OrdinalIgnoreCase))
                {
                    operationName = operationName.Substring(5);
                }
            }

            CodeAttributeArgument actionArgument = targetAttribute.FindArgument("Action");

            if (actionArgument != null)
            {
                string action = string.Format("{0}/{1}/{2}", serviceNamespace, serviceName, operationName);
                actionArgument.Value = new CodePrimitiveExpression(action);
            }

            CodeAttributeArgument replyArgument = targetAttribute.FindArgument("ReplyAction");

            if (replyArgument != null)
            {
                string action = string.Format("{0}/{1}/{2}Response", serviceNamespace, serviceName, operationName);
                replyArgument.Value = new CodePrimitiveExpression(action);
            }
        }
Exemple #2
0
        private static void FormatActions(AttributableCodeDomObject method, CodeAttributeDeclaration targetAttribute, string serviceNamespace, string serviceName)
        {
            serviceNamespace = serviceNamespace.TrimEnd('/');
            string operationName = method.ExtendedObject.Name;

            CodeAttributeArgument asyncPatternArgument = targetAttribute.FindArgument("AsyncPattern");
            if (asyncPatternArgument != null)
            {
                CodePrimitiveExpression value = asyncPatternArgument.Value as CodePrimitiveExpression;
                if (value != null && (bool)value.Value && operationName.StartsWith("Begin", StringComparison.OrdinalIgnoreCase))
                {
                    operationName = operationName.Substring(5);
                }
            }

            CodeAttributeArgument actionArgument = targetAttribute.FindArgument("Action");
            if (actionArgument != null)
            {
                string action = string.Format("{0}/{1}/{2}", serviceNamespace, serviceName, operationName);
                actionArgument.Value = new CodePrimitiveExpression(action);
            }

            CodeAttributeArgument replyArgument = targetAttribute.FindArgument("ReplyAction");
            if (replyArgument != null)
            {
                string action = string.Format("{0}/{1}/{2}Response", serviceNamespace, serviceName, operationName);
                replyArgument.Value = new CodePrimitiveExpression(action);
            }
        }