Пример #1
0
        /// <summary>
        ///   Executes the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            XibCompiler compiler = new XibCompiler();

            compiler.Logger = new ExecutionLogger(this);
            if (!compiler.Compile(this.XibFile.ToString(), this.ToDirectory.ToString()))
            {
                throw new BuildException(Resources.XibCompilationFailed);
            }
        }
Пример #2
0
        /// <summary>
        ///   Executes the task.
        /// </summary>
        public override bool Execute()
        {
            List <ITaskItem> files       = new List <ITaskItem> ();
            List <ITaskItem> directories = new List <ITaskItem> ();

            this.Log.LogMessage("XibFile       : {0}", "" + this.XibFile);
            this.Log.LogMessage("XibFiles      : {0}", "" + this.XibFiles);
            this.Log.LogMessage("ToDirectory   : {0}", "" + this.ToDirectory);
            this.Log.LogMessage("ToDirectories : {0}", "" + this.ToDirectories);

            if (this.XibFile != null && this.ToDirectory != null)
            {
                files.Add(this.XibFile);
                directories.Add(this.ToDirectory);
            }
            else if (this.XibFiles != null && this.ToDirectory != null)
            {
                files.AddRange(this.XibFiles);
                for (int i = 0; i < files.Count; i++)
                {
                    directories.Add(this.ToDirectory);
                }
            }
            else if (this.XibFiles != null && this.ToDirectories != null)
            {
                files.AddRange(this.XibFiles);
                directories.AddRange(this.ToDirectories);
            }
            else if (this.XibFile == null && this.XibFiles == null)
            {
                return(true);
            }
            else
            {
                return(true);
            }

            this.Log.LogMessage("Processing {0} files to {1} folders", files.Count, directories.Count);

            if (files.Count == 0)
            {
                return(true);
            }

            if (files.Count != directories.Count)
            {
                this.Log.LogError(Resources.XibCompilationFailed);
                return(false);
            }

            XibCompiler compiler = new XibCompiler();

            compiler.Logger = new ExecutionLogger(this);

            for (int i = 0; i < files.Count; i++)
            {
                String file   = files [i].ItemSpec;
                String dest   = directories [i].ItemSpec;
                String parent = Path.GetDirectoryName(file);
                dest = Path.Combine(dest, parent);

                if (!compiler.Compile(file, dest))
                {
                    this.Log.LogError(Resources.XibCompilationFailed);
                    return(false);
                }
            }

            return(true);
        }