public Compile ( String xibFile, String directory ) : bool | ||
xibFile | String | The XIB file. |
directory | String | The directory. |
Результат | bool |
/// <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); } }
/// <summary> /// Compiles the XIB files. /// </summary> /// <param name = 'monitor'>The progress monitor.</param> /// <param name = 'project'>The project.</param> /// <param name = 'maker'>The bundle maker.</param> /// <param name = 'result'>The build result.</param> public static void CompileXIBFiles(IProgressMonitor monitor, MonobjcProject project, BundleMaker maker, BuildResult result) { XibCompiler xibCompiler = new XibCompiler (); IEnumerable<FilePair> files = project.GetIBFiles (Constants.InterfaceDefinition, maker.ResourcesFolder); if (files == null || files.Count() == 0) { return; } List<FilePair> pairs = new List<FilePair> (files); monitor.BeginTask (GettextCatalog.GetString ("Compiling XIB files..."), files.Count ()); foreach (FilePair pair in pairs) { monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", pair.Source.ToRelative (project.BaseDirectory))); xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result); xibCompiler.Compile (pair.Source, pair.DestinationDir); monitor.Step (1); } monitor.EndTask (); }
/// <summary> /// Embeds the XIB files. /// </summary> /// <param name = 'monitor'>The progress monitor.</param> /// <param name = 'project'>The project.</param> /// <param name = 'maker'>The bundle maker.</param> /// <param name = 'result'>The build result.</param> public static void EmbedXIBFiles(IProgressMonitor monitor, MonobjcProject project, BuildResult result) { XibCompiler xibCompiler = new XibCompiler (); IEnumerable<FilePair> files = project.GetIBFiles (Constants.EmbeddedInterfaceDefinition, null); if (files == null || files.Count() == 0) { return; } monitor.BeginTask (GettextCatalog.GetString ("Embed XIB files..."), files.Count ()); foreach (FilePair pair in files) { // If the destination file is a place-holder, change its dates FileInfo sourceInfo = new FileInfo (pair.Source); FileInfo destInfo = new FileInfo (pair.Destination); if (destInfo.Length == 0) { DateTime dateTime = sourceInfo.CreationTime.Subtract (new TimeSpan (0, 0, 1)); File.SetCreationTime (pair.Destination, dateTime); File.SetLastAccessTime (pair.Destination, dateTime); File.SetLastWriteTime (pair.Destination, dateTime); } FilePath relativeFile = pair.Source.ToRelative (project.BaseDirectory); monitor.Log.WriteLine (GettextCatalog.GetString ("Compiling {0}", relativeFile)); xibCompiler.Logger = new BuildLogger (pair.Source, monitor, result); xibCompiler.Compile (pair.Source, pair.DestinationDir); monitor.Step (1); } monitor.EndTask (); }
/// <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; }