Ejemplo n.º 1
0
        public IMockObject CreateInstance(string cacheKey, IInvokeDynamicFactory invokeDynamicFactory, bool skipCacheCheck)
        {
            IMockObject objectContract;
            KeyValuePair <Type, string> keyValuePair;
            IDynamicInvocation          dynamicInvocation = null;
            Type objectType;

            //if (base.Disposed)
            //    throw new ObjectDisposedException(typeof(MockProxyFactory).FullName);

            if ((object)cacheKey == null)
            {
                throw new ArgumentNullException("cacheKey");
            }

            if ((object)invokeDynamicFactory == null)
            {
                throw new ArgumentNullException("invokeDynamicFactory");
            }

            keyValuePair = new KeyValuePair <Type, string>(typeof(IMockObject), cacheKey);

            if (!skipCacheCheck && !base.IsInstanceInCache(keyValuePair))
            {
                objectType = typeof(IMockObject);

                // spin up an (Wcf)Service instance
                dynamicInvocation = invokeDynamicFactory.GetDynamicInvoker(cacheKey, objectType);
            }

            objectContract = base.CreateOrGetInstance(keyValuePair, () => this.CreateInstance(dynamicInvocation));

            return(objectContract);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Initializes a new instance of the DynamicInvokerRealProxy`1 class.
        /// </summary>
        /// <param name="dynamicInvocation"> The dynamic invoker object to use. </param>
        protected DynamicInvokerRealProxy(IDynamicInvocation dynamicInvocation)
            : base(typeof(TTransparentProxy))
        {
            if ((object)dynamicInvocation == null)
            {
                throw new ArgumentNullException("dynamicInvocation");
            }

            this.dynamicInvocation = dynamicInvocation;
        }
Ejemplo n.º 3
0
        public IMockObject CreateInstance(IDynamicInvocation dynamicInvocation)
        {
            IMockObject proxy;

            if (base.Disposed)
            {
                throw new ObjectDisposedException(typeof(MockProxyFactory).FullName);
            }

            if ((object)dynamicInvocation == null)
            {
                throw new ArgumentNullException("invokeDynamic");
            }

            proxy = new MockObject();

            return(proxy);
        }
 public MockDynamicInvokerRealProxy(IDynamicInvocation dynamicInvocation)
     : base(dynamicInvocation)
 {
 }