/// <summary> /// Builds the proxy. If no explicit ForMember(s) calls were made, all members will be thread-safe, except any explicitly excluded through /// NotForMember(s) calls. If no WithLockFactory call was made, a default lock factory which uses System.Threading.Monitor (equivalent to the /// lock keyword) will be used. If no WithLockingObject call was made, a dedicated locking object will be newed up with each call. /// </summary> /// <returns></returns> public TProxy Build() { var methodInfoIncluder = GenerateMethodInfoPredicate(true, _includedMethodInfosSpecified, _includedMethodInfos); var methodInfoExcluder = GenerateMethodInfoPredicate(false, _excludedMethodInfosSpecified, _excludedMethodInfos); Predicate <MethodInfo> compositeMethodIncluder = methodInfo => methodInfoIncluder(methodInfo) && (!methodInfoExcluder(methodInfo)); var theLock = _lockFactory(_lockingObject ?? new object()); if (typeof(TProxy) == ProxyType) { return(_threadSafeProxyFactory.CreateProxy <TProxy>(_subject, compositeMethodIncluder, theLock)); } return(_dynamicThreadSafeProxyFactoryInvoker.CreateProxy( _threadSafeProxyFactory, _subject, ProxyType, compositeMethodIncluder, theLock) as TProxy); }
public override object Invoke(IThreadSafeProxyFactory threadSafeProxyFactory, object obj, Predicate <MethodInfo> methodIncluder, ILock theLock) { return(threadSafeProxyFactory.CreateProxy <TProxy>(obj as TProxy, methodIncluder, theLock)); }