public WebHttpDispatchOperationSelector(ServiceEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }
            if (endpoint.Address == null)
            {
                throw new InvalidOperationException("EndpointAddress must be set in the argument ServiceEndpoint");
            }

            foreach (OperationDescription od in endpoint.Contract.Operations)
            {
                WebAttributeInfo info = od.GetWebAttributeInfo();
                if (info != null)
                {
                    UriTemplateTable table;
                    if (!tables.TryGetValue(info.Method, out table))
                    {
                        table = new UriTemplateTable(endpoint.Address.Uri);
                        tables.Add(info.Method, table);
                    }
                    table.KeyValuePairs.Add(new TemplateTablePair(info.BuildUriTemplate(od, null), od));
                }
            }
        }
Ejemplo n.º 2
0
        public static WebAttributeInfo GetWebAttributeInfo(this OperationDescription od)
        {
#if NET_2_1
            var mi   = od.BeginMethod ?? od.SyncMethod;
            var atts = mi.GetCustomAttributes(typeof(WebGetAttribute), true);
            if (atts.Length == 1)
            {
                return(((WebGetAttribute)atts [0]).Info);
            }
            atts = mi.GetCustomAttributes(typeof(WebInvokeAttribute), true);
            if (atts.Length == 1)
            {
                return(((WebInvokeAttribute)atts [0]).Info);
            }
            return(null);
#else
            foreach (IOperationBehavior ob in od.Behaviors)
            {
                WebAttributeInfo info = null;
                var wg = ob as WebGetAttribute;
                if (wg != null)
                {
                    return(wg.Info);
                }
                var wi = ob as WebInvokeAttribute;
                if (wi != null)
                {
                    return(wi.Info);
                }
            }
            return(new WebGetAttribute().Info);             // blank one
#endif
        }
Ejemplo n.º 3
0
 public static WebAttributeInfo GetWebAttributeInfo(this OperationDescription od)
 {
     foreach (IOperationBehavior ob in od.Behaviors)
     {
         WebAttributeInfo info = null;
         var wg = ob as WebGetAttribute;
         if (wg != null)
         {
             return(wg.Info);
         }
         var wi = ob as WebInvokeAttribute;
         if (wi != null)
         {
             return(wi.Info);
         }
     }
     return(new WebGetAttribute().Info);             // blank one
 }
        void ApplyWebAttribute()
        {
            MethodInfo mi = operation.SyncMethod ?? operation.BeginMethod;

            object [] atts = mi.GetCustomAttributes(typeof(WebGetAttribute), false);
            if (atts.Length > 0)
            {
                info = ((WebGetAttribute)atts [0]).Info;
            }
            atts = mi.GetCustomAttributes(typeof(WebInvokeAttribute), false);
            if (atts.Length > 0)
            {
                info = ((WebInvokeAttribute)atts [0]).Info;
            }
            if (info == null)
            {
                info = new WebAttributeInfo();
            }

            template = info.BuildUriTemplate(Operation, GetMessageDescription(MessageDirection.Input));
        }
Ejemplo n.º 5
0
 WebMessageBodyStyle GetBodyStyle(WebAttributeInfo wai)
 {
     return(wai != null && wai.IsBodyStyleSetExplicitly ? wai.BodyStyle : DefaultBodyStyle);
 }