Esempio n. 1
0
 /// <summary>
 /// Called by <see cref="DataPortal" /> to load an
 /// existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
     if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
     {
         return(await _portal.Fetch(objectType, criteria, context, isSync));
     }
     else
     {
         var tcs = new TaskCompletionSource <DataPortalResult>();
         var bw  = new Csla.Threading.BackgroundWorker();
         bw.DoWork += (s, o) =>
         {
             o.Result = _portal.Fetch(objectType, criteria, context, isSync).Result;
         };
         bw.RunWorkerCompleted += (s, o) =>
         {
             if (o.Error == null)
             {
                 tcs.TrySetResult((DataPortalResult)o.Result);
             }
             else
             {
                 tcs.TrySetException(o.Error);
             }
         };
         bw.RunWorkerAsync();
         return(await tcs.Task);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Called by <see cref="DataPortal" /> to load an
        /// existing business object.
        /// </summary>
        /// <param name="objectType">Type of business object to retrieve.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" /> object passed to the server.
        /// </param>
        /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
        public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            DataPortalResult result;

            SetApplicationContext(criteria, CurrentApplicationContext);
            if (isSync || OriginalApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
            {
                result = await _portal.Fetch(objectType, criteria, context, isSync);
            }
            else
            {
                if (!Options.FlowSynchronizationContext || SynchronizationContext.Current == null)
                {
                    result = await Task.Run(() => this._portal.Fetch(objectType, criteria, context, isSync));
                }
                else
                {
                    result = await await Task.Factory.StartNew(() => this._portal.Fetch(objectType, criteria, context, isSync),
                                                               CancellationToken.None,
                                                               TaskCreationOptions.None,
                                                               TaskScheduler.FromCurrentSynchronizationContext());
                }
            }
            SetApplicationContext(result.ReturnObject, OriginalApplicationContext);
            SetApplicationContext(result.Error, OriginalApplicationContext);
            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Called by <see cref="DataPortal" /> to load an
 /// existing business object.
 /// </summary>
 /// <param name="objectType">Type of business object to retrieve.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
     if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
     {
         return(await _portal.Fetch(objectType, criteria, context, isSync));
     }
     else
     {
         return(await await _taskFactory.StartNew(() => this._portal.Fetch(objectType, criteria, context, isSync)));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Called by <see cref="DataPortal" /> to load an
        /// existing business object.
        /// </summary>
        /// <param name="objectType">Type of business object to retrieve.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" /> object passed to the server.
        /// </param>
        /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
        public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
            {
                return(await _portal.Fetch(objectType, criteria, context, isSync));
            }
            else
            {
                if (SynchronizationContext.Current == null)
                {
                    return(await await this._taskFactory.StartNew(() => this._portal.Fetch(objectType, criteria, context, isSync)));
                }

                return(await await this._taskFactory.StartNew(() => this._portal.Fetch(objectType, criteria, context, isSync),
                                                              CancellationToken.None,
                                                              TaskCreationOptions.None,
                                                              TaskScheduler.FromCurrentSynchronizationContext()));
            }
        }
Esempio n. 5
0
 public DataPortalResult Fetch(object criteria, DataPortalContext context)
 {
     return(_portal.Fetch(criteria, context));
 }
Esempio n. 6
0
 public Server.DataPortalResult Fetch(object criteria, Server.DataPortalContext context)
 {
     return(Portal.Fetch(criteria, context));
 }