private object ReverseObject(object src) { object retVal = src; ProxyResult prs = src as ProxyResult; if (prs != null) { var fx = new Func <string, IObjectProxy>(s => { IObjectProxy retObj = null; if (!CustomProxy.IsProxyAvailable(prs.Type)) { ObjectProxy proxy = CreateProxyInternal(s, prs.Type); retObj = proxy.ActLike <IObjectProxy>(prs.Type); } else { retObj = CustomProxy.GetCustomProxy(prs.Type, this, s); } return(retObj); }); retVal = abandonnableProxies.AddOrUpdate(prs.UniqueName, fx, (s, o) => o ?? fx(s)); } return(retVal); }
/// <summary> /// Creates a proxy object for the requested objectName /// </summary> /// <typeparam name="T">the Client-interface type for the given objectName</typeparam> /// <param name="objectName">the name of the remote-Object to wrap</param> /// <returns>a Proxy - object that wraps the requested object</returns> public T CreateProxy <T>(string objectName) where T : class { ObjectAvailabilityResult result; try { result = CheckRemoteObjectAvailability(objectName); } catch (Exception ex) { LogEnvironment.LogDebugEvent( null, $"Error checking Object-Availability:", (int)LogSeverity.Error, null); LogException(ex, true); throw; } if (!result.Available) { throw new InvalidOperationException( $"The requested object is not present on the connected service. Server-Message: {result.Message}"); } Type t = typeof(T); LogEnvironment.LogDebugEvent(null, $"Creating proxy for Type: {t.FullName}", (int)LogSeverity.Report, null); if (!CustomProxy.IsProxyAvailable(typeof(T))) { ObjectProxy proxy = CreateProxyInternal(objectName, typeof(T)); LogEnvironment.LogDebugEvent(null, "Proxy successfully created", (int)LogSeverity.Report, null); return(proxy.ActLike <T>(typeof(IObjectProxy))); } return(CustomProxy.GetCustomProxy <T>(this, objectName)); }