Exemplo n.º 1
0
        private Type GetProxyType(Type contractType)
        {
            Type clientBaseType = typeof(ClientBase <>).MakeGenericType(
                contractType);

            Type[] allTypes  = ProxyAssembly.GetTypes();
            Type   proxyType = null;

            foreach (Type type in allTypes)
            {
                // Look for a proxy class that implements the service
                // contract and is derived from ClientBase<service contract>
                if (type.IsClass && contractType.IsAssignableFrom(type) &&
                    type.IsSubclassOf(clientBaseType))
                {
                    proxyType = type;
                    break;
                }
            }

            if (proxyType == null)
            {
                throw new DynamicProxyException(string.Format(
                                                    Constants.ErrorMessages.ProxyTypeNotFound,
                                                    contractType.FullName));
            }

            return(proxyType);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="objTypeName">Name of the obj type.</param>
        /// <returns></returns>
        private object CreateInstance(string objTypeName)
        {
            try
            {
                foreach (Type ty in ProxyAssembly.GetTypes())
                {
                    if (ty.BaseType == typeof(SoapHttpClientProtocolExtended))
                    {
                        if (objTypeName == null || objTypeName.Length == 0 || ty.Name == objTypeName)
                        {
                            objTypeName = ty.Name;
                            break;
                        }
                    }
                }

                Type t = ass.GetType(CodeConstants.CODENAMESPACE + "." + objTypeName);

                return(Activator.CreateInstance(t));
            }
            catch (Exception ex)
            {
                throw new ProxyTypeInstantiationException("An error occured while instantiating the proxy type.", ex);
            }
            catch
            {
                throw new ProxyTypeInstantiationException("An error occured while instantiating the proxy type.");
            }
        }
Exemplo n.º 3
0
        private Type GetProxyType(Type contractType)
        {
            Type clientBaseType = typeof(ClientBase <>).MakeGenericType(contractType);

            Type[] allTypes = ProxyAssembly.GetTypes();

            Type proxyType = allTypes.FirstOrDefault(type => type.IsClass && contractType.IsAssignableFrom(type) && type.IsSubclassOf(clientBaseType));

            if (proxyType == null)
            {
                throw new DynamicProxyException(string.Format(Constants.ErrorMessages.ProxyTypeNotFound, contractType.FullName));
            }

            return(proxyType);
        }
Exemplo n.º 4
0
        private object CreateInstance(string objTypeName)
        {
            // check whether the type is already created or not
            if (objTypeName == "" || objTypeName == null)
            {
                foreach (Type ty in ProxyAssembly.GetTypes())
                {
                    if (ty.BaseType == typeof(SoapHttpClientProtocolEx))
                    {
                        objTypeName = ty.Name;
                        break;
                    }
                }
            }
            Type t = ass.GetType("OW.Tools.WebServices.DynamicProxy." + objTypeName);

            return(Activator.CreateInstance(t));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <returns></returns>
        private object CreateProxyInstance()
        {
            string objTypeName = null;

            try
            {
                foreach (Type ty in ProxyAssembly.GetTypes())
                {
                    if (ty.BaseType == typeof(SoapHttpClientProtocolExtended))
                    {
                        objTypeName = ty.Name;
                        break;
                    }
                }

                Type t = ass.GetType(CodeConstants.CODENAMESPACE + "." + objTypeName);

                return(Activator.CreateInstance(t));
            }
            catch (Exception ex)
            {
                throw new ProxyTypeInstantiationException("An error occured while instantiating the proxy type: " + ex.Message + ", " + ex.StackTrace, ex);
            }
        }