コード例 #1
0
        /// <summary>
        /// 呼叫本地logic
        /// </summary>
        /// <param name="url">请求的路由,格式:/xxxx/yyyy</param>
        /// <param name="method">请求的method,post,get,patch等</param>
        /// <param name="header">额外附加的header信息</param>
        /// <param name="query_string">额外附加的query_string信息</param>
        /// <param name="post_data">额外附加的post_data信息</param>
        /// <returns></returns>
        public object CallLocalLogic(string url, string method, FrameDLRObject header = null, FrameDLRObject query_string = null, FrameDLRObject post_data = null)
        {
            object obj = new EWRAData();
            var    dp  = CallContext_Parameter.DeepCopy <EWRAParameter>();

            dp.RequestUri         = new Uri(ServerInfo.SiteHostUrl + url);
            dp.RequestRoute       = url;
            dp.RestResourcesArray = url.Split('/');
            dp.MethodName         = method;

            if (header != null)
            {
                foreach (var item in header.Items)
                {
                    dp.SetValue(DomainKey.HEADER, item.Key, item.Value);
                }
            }
            if (query_string != null)
            {
                foreach (var item in query_string.Items)
                {
                    dp.SetValue(DomainKey.QUERY_STRING, item.Key, item.Value);
                }
            }
            if (post_data != null)
            {
                foreach (var item in post_data.Items)
                {
                    dp.SetValue(DomainKey.POST_DATA, item.Key, item.Value);
                }
            }

            GlobalCommon.Proxys["busi"].CallModule(ref obj, new object[] { dp });
            return(((EWRAData)obj).Result);
        }
コード例 #2
0
        /// <summary>
        /// 从Querystring和postdata中获取数据,并生成对应的Model,效能较低,谨慎使用
        /// </summary>
        /// <typeparam name="M"></typeparam>
        /// <returns></returns>
        public M GetModel <M>()
        {
            M    rtn = (M)Activator.CreateInstance(typeof(M), true);
            Type te  = typeof(M);

            PropertyInfo[] pis = te.GetProperties();

            foreach (PropertyInfo fi in pis)
            {
                foreach (var val in CallContext_Parameter.Domain(DomainKey.QUERY_STRING))
                {
                    string colname = fi.Name;
                    if (fi.Name.Equals(val.Key, StringComparison.OrdinalIgnoreCase))
                    {
                        SetPropertyValue <M>(ref rtn, fi, val.Value);
                    }
                }
                foreach (var val in CallContext_Parameter.Domain(DomainKey.POST_DATA))
                {
                    string colname = fi.Name;
                    if (fi.Name.Equals(val.Key, StringComparison.OrdinalIgnoreCase))
                    {
                        SetPropertyValue <M>(ref rtn, fi, val.Value);
                    }
                }
            }

            return(rtn);
        }