Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a new managed adapter proxy.
        /// </summary>
        /// <param name="adapterType">The managed adapter type</param>
        /// <param name="typeToProxy">The type of adapter which the proxy works for.</param>
        public ManagedAdapterProxy(Type adapterType, Type typeToProxy)
            : base(typeToProxy)
        {
            trueType = adapterType;
            try
            {
                instance = TestToolHelpers.CreateInstanceFromTypeName(adapterType.FullName) as ManagedAdapterBase;
            }
            catch (InvalidOperationException)
            {
            }

            if (instance == null)
            {
                throw new InvalidOperationException(
                          String.Format("Adapter {0} instance creation failed",
                                        typeToProxy.FullName));
            }
            else if (!typeToProxy.IsAssignableFrom(instance.GetType()))
            {
                throw new InvalidOperationException(
                          String.Format("Adapter {0} does not implement {1}",
                                        adapterType.Name, typeToProxy.FullName));
            }
        }
        /// <summary>
        /// Constructs a new managed adapter proxy.
        /// </summary>
        /// <param name="adapterType">The managed adapter type</param>
        /// <param name="typeToProxy">The type of adapter which the proxy works for.</param>
        public ManagedAdapterProxy(Type adapterType, Type typeToProxy)
            : base(typeToProxy)
        {
            trueType = adapterType;
            try
            {
                instance = TestToolHelpers.CreateInstanceFromTypeName(adapterType.FullName) as ManagedAdapterBase;
            }
            catch (InvalidOperationException)
            {
            }

            if (instance == null)
            {
                throw new InvalidOperationException(
                   String.Format("Adapter {0} instance creation failed",
                                 typeToProxy.FullName));
            }
            else if (!typeToProxy.IsAssignableFrom(instance.GetType()))
            {
                throw new InvalidOperationException(
                    String.Format("Adapter {0} does not implement {1}",
                                  adapterType.Name, typeToProxy.FullName));
            }
        }