NStub.Core.NStubCore.NStubCore C# (CSharp) Method

NStubCore() public method

Initializes a new instance of the NStubCore class which will generate the given System.CodeDom.CodeNamespace to the given output directory using the given implementation of NStub.Core.ICodeGenerator.
codeNamespace, /// outputDirectory, or codeGenerator is null. outputDirectory is an /// empty string. outputDirectory /// is not a valid directory.
public NStubCore ( IBuildSystem buildSystem, CodeNamespace codeNamespace, string outputDirectory, ICodeGenerator codeGenerator ) : System
buildSystem IBuildSystem The build system.
codeNamespace System.CodeDom.CodeNamespace The code namespace which contains the types /// to be generated.
outputDirectory string The directory where the resulting /// files will be output to.
codeGenerator ICodeGenerator The code generator which will perform the /// generation.
return System
        public NStubCore(IBuildSystem buildSystem, CodeNamespace codeNamespace, string outputDirectory,
            ICodeGenerator codeGenerator)
        {
            #region Validation

            Guard.NotNull(() => buildSystem, buildSystem);
            this.sbs = buildSystem;

            // Null arguments will not be accepted
            if (codeNamespace == null)
            {
                throw new ArgumentNullException("codeNamespace",
                    Exceptions.ParameterCannotBeNull);
            }
            //Guard.NotNullOrEmpty(() => outputDirectory, outputDirectory);
            if (outputDirectory == null)
            {
                throw new ArgumentNullException("outputDirectory",
                    Exceptions.ParameterCannotBeNull);
            }
            if (codeGenerator == null)
            {
                throw new ArgumentNullException("codeGenerator",
                    Exceptions.ParameterCannotBeNull);
            }
            // The output directory can't be empty
            if (outputDirectory.Length == 0)
            {
                throw new ArgumentException(Exceptions.StringCannotBeEmpty,
                    "outputDirectory");
            }
            // Ensure the output directory is valid
            if (!(buildSystem.DirectoryExists(outputDirectory)))
            {
                throw new System.IO.DirectoryNotFoundException(Exceptions.DirectoryCannotBeFound);
            }

            #endregion Validation

            // Set our member variables
            _codeNamespace = codeNamespace;
            _outputDirectory = outputDirectory;

            InitCodeGenerator(codeGenerator);
        }