Exemple #1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Executes the command.
        /// </summary>
        public void Execute()
        {
#if ENABLE_OLD_CODE
            //  TODO: This code is from the old AddCommand, so it needs to be
            //  updated eventually.

            Dataset dataset = Dataset.LoadOrCreate(Dataset.DefaultPath);
            EditableExtensionInfo.Dataset = dataset;
            ExtensionParser parser    = new ExtensionParser();
            ExtensionInfo   extension = Data.Load <ExtensionInfo>(extensionInfoPath, parser);

            List <string> missingLibs = new List <string>();
            foreach (string library in extension.ReferencedAssemblies)
            {
                if (!dataset.ReferencedByEntries(library))
                {
                    missingLibs.Add(library);
                }
            }

            List <string> libsToBeInstalled = new List <string>();
            foreach (string libPath in extension.LibraryPaths)
            {
                libsToBeInstalled.Add(Path.GetFileNameWithoutExtension(libPath));
            }

            foreach (string libToBeInstalled in libsToBeInstalled)
            {
                missingLibs.Remove(libToBeInstalled);
            }
            if (missingLibs.Count > 0)
            {
                MultiLineText message = new MultiLineText();
                message.Add("Error: The extension requires the following libraries which are not");
                message.Add("       currently installed and are not listed in the extension info file:");
                foreach (string lib in missingLibs)
                {
                    message.Add("         " + lib);
                }
                throw new MultiLineException(message);
            }

            Console.WriteLine("Installation directory: {0}", installDir);
            Console.WriteLine("Copying files to installation directory ...");
            CopyFileToInstallDir(extension.AssemblyPath);
            foreach (string libPath in extension.LibraryPaths)
            {
                CopyFileToInstallDir(libPath);
            }

            dataset.Add(extension);
            dataset.Save();
            Console.WriteLine("Extension {0} installed", extension.Name);
#endif
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Executes the command.
        /// </summary>
        public void Execute()
        {
            Dataset dataset = Util.OpenDatasetForChange(Dataset.DefaultPath);

            EditableExtensionInfo.Dataset = dataset;
            //Model model = new Model(null, null);

            ExtensionParser parser    = new ExtensionParser();
            ExtensionInfo   extension = Load <ExtensionInfo>(extensionInfoPath, parser);

            dataset.Add(extension);
            dataset.Save();
            Console.WriteLine("Added the extension \"{0}\"", extension.Name);
        }