/// <summary> /// Creates an instance of the object. /// </summary> /// <param name="returnObject">Object to return as part /// of the result.</param> /// <param name="globalContext"> Global context delivered via current reuest from the server /// </param> public DataPortalResult(object returnObject, ContextDictionary globalContext) { ReturnObject = returnObject; GlobalContext = globalContext; }
/// <summary> /// Creates an instance of the object. /// </summary> public DataPortalResult() { GlobalContext = ApplicationContext.ContextManager.GetGlobalContext(); }
/// <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 = ApplicationContext.ContextManager.GetGlobalContext(); }
/// <summary> /// Sets the client context. /// </summary> /// <param name="clientContext">Client context.</param> public void SetClientContext(ContextDictionary clientContext) { HttpContext.Items[_clientContextName] = clientContext; }
/// <summary> /// Sets the global context. /// </summary> /// <param name="globalContext">Global context.</param> public void SetGlobalContext(ContextDictionary globalContext) { HttpContext.Items[_globalContextName] = globalContext; }
public ContextAddressHeader(IDictionary<string, string> context) { this.context = new ContextDictionary(context); }
private static ThemeStyle ProcessStyle(string name, string content, StringDictionary variables, ContextDictionary context) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(content)) { return(null); } StringDictionary values = new StringDictionary(); content.ParseKeyValuePair((t1, t2) => values.Add(t1, t2)); string module = null; ThemeParserContext styleContext = ThemeParserContext.Default; if (values.TryGetValue("$module", out module)) { context.TryGetValue(module, out styleContext); values.Remove("$module"); } ThemeStyle style = new ThemeStyle(styleContext, name); style.UpdateProperties(values); return(style); }
public void SetClientContext(ContextDictionary clientContext) { _myContext[_clientContextName] = clientContext; }
public void SetGlobalContext(ContextDictionary globalContext) { _myContext[_globalContextName] = globalContext; }
/// <summary> /// Creates a new DataPortalContext object. /// </summary> /// <param name="principal">The current Principal object.</param> /// <param name="isRemotePortal">Indicates whether the DataPortal is remote.</param> /// <param name="clientContext">Client context.</param> /// <param name="clientCulture">Client culture.</param> /// <param name="clientUICulture">Client UI culture.</param> /// <param name="globalContext">Global context.</param> public DataPortalContext(IPrincipal principal, bool isRemotePortal, string clientCulture, string clientUICulture, ContextDictionary clientContext, ContextDictionary globalContext) { _principal = principal; _clientContext = clientContext; _clientCulture = clientCulture; _clientUICulture = clientUICulture; _globalContext = globalContext; _remotePortal = isRemotePortal; }
public void SetLocalContext(ContextDictionary localContext) { _myContext[_localContextName] = localContext; }
/// <summary> /// Called by <see cref="DataPortal" /> to delete a /// business object. /// </summary> /// <param name="objectType">Type of business object to create.</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> #pragma warning disable 1998 public async Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync) #pragma warning restore 1998 { #if !(ANDROID || IOS) && !NETFX_CORE ChannelFactory <IWcfPortal> cf = GetChannelFactory(); var proxy = GetProxy(cf); WcfResponse response = null; #if NET40 try { var request = new DeleteRequest(objectType, criteria, context); if (isSync) { response = proxy.Delete(request); } else { var worker = new Csla.Threading.BackgroundWorker(); var tcs = new TaskCompletionSource <WcfResponse>(); worker.RunWorkerCompleted += (o, e) => { tcs.SetResult((WcfResponse)e.Result); }; worker.DoWork += (o, e) => { e.Result = proxy.Delete(request); }; worker.RunWorkerAsync(); response = await tcs.Task; } if (cf != null) { cf.Close(); } object result = response.Result; if (result is Exception) { throw (Exception)result; } return((DataPortalResult)result); } catch { cf.Abort(); throw; } #else try { var request = new DeleteRequest(objectType, criteria, context); if (isSync) { response = proxy.Delete(request); } else { response = await proxy.DeleteAsync(request); } if (cf != null) { cf.Close(); } } catch { cf.Abort(); throw; } object result = response.Result; if (result is Exception) { throw (Exception)result; } return((DataPortalResult)result); #endif #else var request = GetBaseCriteriaRequest(); request.TypeName = objectType.AssemblyQualifiedName; if (!(criteria is IMobileObject)) { criteria = new PrimitiveCriteria(criteria); } request.CriteriaData = MobileFormatter.Serialize(criteria); request = ConvertRequest(request); var proxy = GetProxy(); DataPortalResult result = null; #if !NETFX_CORE && !(IOS || ANDROID) var tcs = new TaskCompletionSource <DataPortalResult>(); proxy.DeleteCompleted += (s, e) => { try { Csla.WcfPortal.WcfResponse response = null; if (e.Error == null) { response = ConvertResponse(e.Result); } ContextDictionary globalContext = null; if (response != null) { globalContext = (ContextDictionary)MobileFormatter.Deserialize(response.GlobalContext); } if (e.Error == null && response != null && response.ErrorData == null) { result = new DataPortalResult(null, null, globalContext); } else if (response != null && response.ErrorData != null) { var ex = new DataPortalException(response.ErrorData); result = new DataPortalResult(null, ex, globalContext); } else { result = new DataPortalResult(null, e.Error, globalContext); } } catch (Exception ex) { result = new DataPortalResult(null, ex, null); } finally { tcs.SetResult(result); } }; proxy.DeleteAsync(request); var finalresult = await tcs.Task; if (finalresult.Error != null) { throw finalresult.Error; } return(finalresult); #else try { var response = await proxy.DeleteAsync(request); response = ConvertResponse(response); if (response == null) { throw new DataPortalException("null response", null); } var globalContext = (ContextDictionary)MobileFormatter.Deserialize(response.GlobalContext); if (response.ErrorData == null) { result = new DataPortalResult(null, null, globalContext); } else { var ex = new DataPortalException(response.ErrorData); result = new DataPortalResult(null, ex, globalContext); } } catch (Exception ex) { result = new DataPortalResult(null, ex, null); } if (result.Error != null) { throw result.Error; } return(result); #endif #endif }
internal void SetContext(ContextDictionary clientContext) { lock (_syncContext) ContextManager.SetClientContext(clientContext, ExecutionLocation); }
/// <summary> /// Called by <see cref="DataPortal" /> to update a /// business object. /// </summary> /// <param name="obj">The business object to update.</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> #pragma warning disable 1998 public async Task <DataPortalResult> Update(object obj, DataPortalContext context, bool isSync) #pragma warning restore 1998 { #if !SILVERLIGHT && !NETFX_CORE ChannelFactory <IWcfPortal> cf = GetChannelFactory(); var proxy = GetProxy(cf); WcfResponse response = null; #if NET40 try { var request = new UpdateRequest(obj, context); if (isSync) { response = proxy.Update(request); } else { var worker = new Csla.Threading.BackgroundWorker(); var tcs = new TaskCompletionSource <WcfResponse>(); worker.RunWorkerCompleted += (o, e) => { tcs.SetResult((WcfResponse)e.Result); }; worker.DoWork += (o, e) => { e.Result = proxy.Update(request); }; worker.RunWorkerAsync(); response = await tcs.Task; } if (cf != null) { cf.Close(); } object result = response.Result; if (result is Exception) { throw (Exception)result; } return((DataPortalResult)result); } catch { cf.Abort(); throw; } #else try { var request = new UpdateRequest(obj, context); if (isSync) { response = proxy.Update(request); } else { response = await proxy.UpdateAsync(request); } if (cf != null) { cf.Close(); } } catch { cf.Abort(); throw; } object result = response.Result; if (result is Exception) { throw (Exception)result; } return((DataPortalResult)result); #endif #else var request = GetBaseUpdateCriteriaRequest(); request.ObjectData = MobileFormatter.Serialize(obj); request = ConvertRequest(request); var proxy = GetProxy(); DataPortalResult result = null; #if !NETFX_CORE var tcs = new TaskCompletionSource <DataPortalResult>(); proxy.UpdateCompleted += (s, e) => { try { Csla.WcfPortal.WcfResponse response = null; if (e.Error == null) { response = ConvertResponse(e.Result); } ContextDictionary globalContext = null; if (response != null) { globalContext = (ContextDictionary)MobileFormatter.Deserialize(response.GlobalContext); } if (e.Error == null && response != null && response.ErrorData == null) { var newobj = MobileFormatter.Deserialize(response.ObjectData); result = new DataPortalResult(newobj, null, globalContext); } else if (response != null && response.ErrorData != null) { var ex = new DataPortalException(response.ErrorData); result = new DataPortalResult(null, ex, globalContext); } else { result = new DataPortalResult(null, e.Error, globalContext); } } catch (Exception ex) { result = new DataPortalResult(null, ex, null); } finally { tcs.SetResult(result); } }; proxy.UpdateAsync(request); var finalresult = await tcs.Task; if (finalresult.Error != null) { throw finalresult.Error; } return(finalresult); #else try { var response = await proxy.UpdateAsync(request); response = ConvertResponse(response); if (response == null) { throw new DataPortalException("null response", null); } var globalContext = (ContextDictionary)MobileFormatter.Deserialize(response.GlobalContext); if (response.ErrorData == null) { var newobj = MobileFormatter.Deserialize(response.ObjectData); result = new DataPortalResult(newobj, null, globalContext); } else { var ex = new DataPortalException(response.ErrorData); result = new DataPortalResult(null, ex, globalContext); } } catch (Exception ex) { result = new DataPortalResult(null, ex, null); } if (result.Error != null) { throw result.Error; } return(result); #endif #endif }
/// <summary> /// Creates an instance of the object. /// </summary> /// <param name="returnObject">Object to return as part /// of the result.</param> /// <param name="ex"> /// Error that occurred during the DataPotal call. /// This will be null if no errors occurred. /// </param> /// <param name="globalContext"> Global context delivered via current reuest from the server /// </param> public DataPortalResult(object returnObject, Exception ex, ContextDictionary globalContext) { ReturnObject = returnObject; Error = ex; GlobalContext = globalContext; }
/// <summary> /// Sets the client context. /// </summary> /// <param name="clientContext">Client context.</param> /// <param name="executionLocation"></param> public void SetClientContext(ContextDictionary clientContext, ApplicationContext.ExecutionLocations executionLocation) { HttpContext.Items[_clientContextName] = clientContext; }
/// <summary> /// Sets the local context. /// </summary> /// <param name="localContext">Local context.</param> public void SetLocalContext(ContextDictionary localContext) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_localContextName); Thread.SetData(slot, localContext); }
/// <summary> /// Sets the local context. /// </summary> /// <param name="localContext">Local context.</param> public void SetLocalContext(ContextDictionary localContext) { HttpContext.Items[_localContextName] = localContext; }
public ContextAddressHeader(IDictionary<string, string> context) : base() { Fx.Assert(context != null, "caller must validate"); this.context = new ContextDictionary(context); }
private static void ProcessInstruction(string name, string content, ThemeList styles, StringDictionary variables, ContextDictionary context) { switch (name) { case "@vals": ParseVariables(variables, content); break; case "@include": break; case "@modules": ParseContext(content, context); break; } }