示例#1
0
        private static object ReadServerResult(DataPortalResult result)
        {
            //同步服务端返回的统一的上下文,到本地的上下文对象中。
            DistributionContext.SetGlobalContext(result.GlobalContext);

            return(result.ReturnObject);
        }
示例#2
0
        /// <summary>
        /// Creates the data portal context.
        /// </summary>
        /// <returns></returns>
        private static DataPortalContext CreateDataPortalContext()
        {
            var res = new DataPortalContext();

            res.Principal       = RafyEnvironment.Principal;
            res.ClientCulture   = Thread.CurrentThread.CurrentCulture.Name;
            res.ClientUICulture = Thread.CurrentThread.CurrentUICulture.Name;
            res.ClientContext   = DistributionContext.GetClientContext();
            res.GlobalContext   = DistributionContext.GetGlobalContext();

            return(res);
        }
示例#3
0
        private static void SetContext(DataPortalContext context)
        {
            // set the app context to the value we got from the
            // client
            DistributionContext.SetClientContext(context.ClientContext);
            DistributionContext.SetGlobalContext(context.GlobalContext);

            // set the thread's culture to match the client
            Thread.CurrentThread.CurrentCulture   = new CultureInfo(context.ClientCulture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(context.ClientUICulture);

            // We expect the some Principal object
            if (context.Principal == null)
            {
                System.Security.SecurityException ex =
                    new System.Security.SecurityException(
                        "Resources.BusinessPrincipalException" + " Nothing");
                ex.Action = System.Security.Permissions.SecurityAction.Demand;
                throw ex;
            }

            RafyEnvironment.Principal = context.Principal;
        }
示例#4
0
 private static void ClearContext(DataPortalContext context)
 {
     DistributionContext.Clear();
     RafyEnvironment.Principal = null;
 }
示例#5
0
 /// <summary>
 /// Creates an instance of the object.
 /// </summary>
 /// <param name="returnObject">Object to return as part
 /// of the result.</param>
 public DataPortalResult(object returnObject)
 {
     _returnObject  = returnObject;
     _globalContext = DistributionContext.GetGlobalContext();
 }
示例#6
0
 /// <summary>
 /// Creates an instance of the object.
 /// </summary>
 public DataPortalResult()
 {
     _globalContext = DistributionContext.GetGlobalContext();
 }