Inheritance: UnityEngine.MonoBehaviour
示例#1
0
        public override void ExecuteCommand()
        {
            string searchId = base.Arguments[0];

            PrepareSources();
            PrepareDestinations();

            Console.WriteLine("Copying all packages with '{0}' from {1} to {2}.", searchId, Source.Count == 0 ? "any source" : string.Join(";", Source), string.Join(";", Destination));

            IEnumerable <IPackage> packages = new List <IPackage>();

            try
            {
                packages = GetPackages(searchId);
                Console.WriteLine("Retrieved {0} packages, not counting dependencies for copying from one or more sources to one or more destinations.", packages.Count());
            }
            catch (Exception)
            {
                Console.WriteError("Oopsy!");
                throw;
            }

            Copy copy = new Copy(_repositoryFactory, _sourceProvider);

            copy.Console = this.Console;
            copy.ApiKey  = ApiKey;
            foreach (string src in Source)
            {
                copy.Source.Add(src);
            }
            foreach (string dest in Destination)
            {
                copy.Destination.Add(dest);
            }

            IList <string> report = new List <string>();

            foreach (IPackage package in packages)
            {
                copy.Arguments.Clear();
                copy.Arguments.Add(package.Id);
                copy.Version = package.Version.ToString();
                try
                {
                    copy.Execute();
                }
                catch (Exception ex)
                {
                    string message = string.Format("Had an error getting package '{0} - {1}': {2}", package.Id, package.Version.ToString(), ex.Message);
                    Console.WriteError(message);
                    report.Add(message);
                }
            }

            PrintReport(searchId, report);
        }
示例#2
0
 private void PrintReport(string searchFilter, IList <string> report)
 {
     if (report.Count != 0)
     {
         Console.WriteWarning("Finished copying all packages with searchFilter '{0}' except where the following errors occurred:", searchFilter);
         foreach (string line in report)
         {
             Console.WriteWarning("  " + line);
         }
     }
     else
     {
         Console.WriteLine("Finished copying all packages with searchFilter '{0}' successfully.", searchFilter);
     }
 }