NAnt.Core.Tasks.CopyTask.Initialize C# (CSharp) Method

Initialize() protected method

Checks whether the task is initialized with valid attributes.
protected Initialize ( ) : void
return void
        protected override void Initialize()
        {
            if (Flatten && ToDirectory == null) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "'flatten' attribute requires that 'todir' has been set."),
                    Location);
            }

            if (ToDirectory == null && CopyFileSet != null && CopyFileSet.Includes.Count > 0) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "The 'todir' should be set when using the <fileset> element"
                    + " to specify the list of files to be copied."), Location);
            }

            if (SourceFile != null && CopyFileSet != null && CopyFileSet.Includes.Count > 0) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "The 'file' attribute and the <fileset> element"
                    + " cannot be combined."), Location);
            }

            if (ToFile == null && ToDirectory == null) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "Either the 'tofile' or 'todir' attribute should be set."),
                    Location);
            }

            if (ToFile != null && ToDirectory != null) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "The 'tofile' and 'todir' attribute cannot both be set."),
                    Location);
            }
        }