コード例 #1
0
 private bool ModuleAlreadyInstalled(string packageId)
 {
     return(_extensionManager.AvailableExtensions().Where(m => DefaultExtensionTypes.IsModule(m.ExtensionType))
            .Any(module => module.Id.Equals(
                     packageId.Substring(PackagingSourceManager.GetExtensionPrefix(DefaultExtensionTypes.Module).Length),
                     StringComparison.OrdinalIgnoreCase)));
 }
コード例 #2
0
        public void CreatePackage(string extensionName, string path)
        {
            var packageData = _packageManager.Harvest(extensionName);

            if (packageData == null)
            {
                Context.Output.WriteLine(T("Module or Theme \"{0}\" does not exist in this Tomelt installation.", extensionName));
                return;
            }

            // append "Tomelt.[ExtensionType]" to prevent conflicts with other packages (e.g, TinyMce, jQuery, ...)
            var filename = string.Format("{0}{1}.{2}.nupkg",
                                         PackagingSourceManager.GetExtensionPrefix(packageData.ExtensionType),
                                         packageData.ExtensionName,
                                         packageData.ExtensionVersion);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // packages are created in a specific folder otherwise they are in /bin, which crashed the current shell
            filename = Path.Combine(path, filename);

            using (var stream = File.Create(filename)) {
                packageData.PackageStream.CopyTo(stream);
            }

            var fileInfo = new FileInfo(filename);

            Context.Output.WriteLine(T("Package \"{0}\" successfully created", fileInfo.FullName));
        }