public HttpRestClientCodeGenerator(Type serviceInterfaceType)
        {
            Contract.Requires <ArgumentNullException>(serviceInterfaceType != null);
            HttpRestInterfaceValidator.ValidateInterface(serviceInterfaceType, true);

            this._serviceInterface = serviceInterfaceType;
        }
        public CodeCompileUnit GenerateCodeDomCode(string targetNamespace, string className)
        {
            CodeCompileUnit targetUnit         = new CodeCompileUnit();
            CodeNamespace   samples            = new CodeNamespace(targetNamespace);
            string          restProxyNameSpace = typeof(HttpRestClient <>).Namespace;

            samples.Imports.Add(new CodeNamespaceImport(this._serviceInterface.Namespace));
            var targetClass = new CodeTypeDeclaration(className);

            targetClass.BaseTypes.Add(string.Format("{0}.HttpRestClient<{1}>", restProxyNameSpace, this._serviceInterface.Name));
            targetClass.BaseTypes.Add(this._serviceInterface);

            AddGeneratedCodeAttribute(targetClass);

            samples.Types.Add(targetClass);

            targetUnit.Namespaces.Add(samples);

            //Create a public overload for every constructor in the base class, in our case RestProxy
            this.GenerateContructors(targetClass, typeof(HttpRestClient <>));

            //for each interface method that is tagged with [OperationContract] and [WebInvoke] or [WebGet] generate
            //the proxy implementation. else generate a dummy not implemented exception
            foreach (var method in this._serviceInterface.GetMethods()
                     .Where(meth => !meth.IsSpecialName))
            {
                if (HttpRestInterfaceValidator.ValidateInterfaceMethod(method))
                {
                    //Generate the interface implementation
                    var interfaceImplementation = this.GenerateInterfaceImplementationForOperationContract(method);
                    targetClass.Members.Add(interfaceImplementation);
                }
                else
                {
                    targetClass.Members.Add(GenerateDummyImplemention(method));
                }
            }

            return(targetUnit);
        }