/// <summary>
 /// 实例化RESTfulInvocationHandler
 /// </summary>
 /// <param name="attribute"></param>
 /// <param name="token"></param>
 /// <param name="foramt"></param>
 public RESTfulInvocationHandler(string url, PublishKindAttribute attribute, Token token, DataFormat foramt, int timeout)
 {
     this.format = foramt;
     this.attribute = attribute;
     this.token = token;
     this.url = url;
     this.timeout = timeout;
 }
Пример #2
0
 /// <summary>
 /// 实例化RESTfulInvocationHandler
 /// </summary>
 /// <param name="attribute"></param>
 /// <param name="token"></param>
 /// <param name="foramt"></param>
 public RESTfulInvocationHandler(string url, PublishKindAttribute attribute, Token token, DataFormat foramt, int timeout)
 {
     this.format    = foramt;
     this.attribute = attribute;
     this.token     = token;
     this.url       = url;
     this.timeout   = timeout;
 }
Пример #3
0
        /// <summary>
        /// 获取服务
        /// </summary>
        /// <typeparam name="IServiceInterfaceType"></typeparam>
        /// <returns></returns>
        public IServiceInterfaceType GetChannel <IServiceInterfaceType>(Token token)
        {
            Exception ex = new ArgumentException("Generic parameter type - 【" + typeof(IServiceInterfaceType).FullName
                                                 + "】 must be an interface marked with PublishKindAttribute.");


            PublishKindAttribute kindattr = null;

            if (!typeof(IServiceInterfaceType).IsInterface)
            {
                throw ex;
            }
            else
            {
                bool markedWithServiceContract = false;
                var  attr = CoreHelper.GetTypeAttribute <PublishKindAttribute>(typeof(IServiceInterfaceType));
                if (attr != null)
                {
                    markedWithServiceContract = true;
                }

                kindattr = attr;
                attr     = null;

                if (!markedWithServiceContract)
                {
                    throw ex;
                }
            }

            var serviceType  = typeof(IServiceInterfaceType);
            var handler      = new RESTfulInvocationHandler(url, kindattr, token, format, timeout);
            var dynamicProxy = ProxyFactory.GetInstance().Create(handler, serviceType, true);

            return((IServiceInterfaceType)dynamicProxy);
        }