Example #1
0
        public static PackageInformation GetPackageInformation(string packageName)
        {
            var package             = new PackageInformation();
            var packageXml          = GetPackageXml(packageName);
            var packageInformation  = packageXml.Root.ForceElement(mi + "PackageInformation");
            var packageRequirements = packageXml.Root.ForceElement(mi + "PackageRequirements");

            package.Id = packageInformation.AttributeValue("id") != null ? new Guid(packageInformation.AttributeValue("id")) : Guid.NewGuid();

            package.Author = packageInformation.AttributeValue("author") ?? string.Empty;

            package.GroupName   = packageInformation.AttributeValue("groupName") ?? UserSettings.LastSpecifiedNamespace;
            package.Name        = packageInformation.AttributeValue("name") ?? package.GroupName + ".NewPackage";
            package.ReadMoreUrl = packageInformation.AttributeValue("readMoreUrl") ?? string.Empty;

            package.Version = packageInformation.AttributeValue("version") ?? "1.0.0";
            var request = HttpContext.Current.Request;

            package.Website = packageInformation.AttributeValue("website") ?? (new Uri(request.Url, request.ApplicationPath)).ToString();

            package.Description      = string.IsNullOrEmpty(packageInformation.ForceElement("Description").Value) ? string.Empty : packageInformation.ForceElement("Description").Value;//string.Format("Created by {0}", package.Author) : packageInformation.ForceElement("Description").Value;
            package.TechnicalDetails = string.IsNullOrEmpty(packageInformation.ForceElement("TechnicalDetails").Value) ? string.Empty : packageInformation.ForceElement("TechnicalDetails").Value;

            package.FlushOnCompletion = bool.Parse(packageInformation.AttributeValue("flushOnCompletion") ?? true.ToString());
            package.CanBeUninstalled  = bool.Parse(packageInformation.AttributeValue("canBeUninstalled") ?? true.ToString());
            package.SystemLockingType = packageInformation.AttributeValue("systemLocking") ?? "hard";

            package.ReloadConsoleOnCompletion = bool.Parse(packageInformation.AttributeValue("reloadConsoleOnCompletion") ?? false.ToString());;

            package.MinCompositeVersionSupported = (packageRequirements.AttributeValue("minimumCompositeVersion") != null) ? new Version(packageRequirements.AttributeValue("minimumCompositeVersion")) : RuntimeInformation.ProductVersion;
            package.MaxCompositeVersionSupported = new Version(packageRequirements.AttributeValue("maximumCompositeVersion") ?? "9.9999.9999.9999");

            return(package);
        }
        /// <summary>
        /// Save package information to the config file
        /// </summary>
        /// <param name="package">Package information</param>
        /// <param name="packageName">Previous package name</param>
        public static void SavePackageInformation(PackageInformation package, string packageName)
        {
            lock (_lockEditPackage)
            {
                if (!package.Name.Equals(packageName))
                {
                    try
                    {
                        File.Move(GetPackageConfigPath(packageName), GetPackageConfigPath(package.Name));
                    }
                    catch
                    {
                        throw new InvalidOperationException("New package name is not valid");
                    }
                }
                XDocument packageXml          = GetPackageXml(package.Name);
                var       packageInformation  = packageXml.Root.ForceElement(mi + "PackageInformation");
                var       packageRequirements = packageXml.Root.ForceElement(mi + "PackageRequirements");
                packageInformation.SetAttributeValue("name", package.Name);
                packageInformation.SetAttributeValue("groupName", package.GroupName);
                packageInformation.SetAttributeValue("version", package.Version);
                packageInformation.SetAttributeValue("author", package.Author);
                packageInformation.SetAttributeValue("website", package.Website);
                packageInformation.SetAttributeValue("readMoreUrl", package.ReadMoreUrl);
                packageInformation.SetAttributeValue("id", package.Id);
                packageInformation.SetAttributeValue("canBeUninstalled", package.CanBeUninstalled);
                packageInformation.SetAttributeValue("systemLocking", package.SystemLockingType);
                packageInformation.SetAttributeValue("flushOnCompletion", package.FlushOnCompletion);
                packageInformation.SetAttributeValue("allowOverwrite", package.OverwriteDataOnInstall);
                if (package.ReloadConsoleOnCompletion)
                {
                    packageInformation.SetAttributeValue("reloadConsoleOnCompletion", "true");
                }
                packageInformation.ForceElement("Description").Value      = package.Description;
                packageInformation.ForceElement("TechnicalDetails").Value = package.TechnicalDetails;

                packageRequirements.SetAttributeValue("minimumCompositeVersion", package.MinCompositeVersionSupported.ToString());
                packageRequirements.SetAttributeValue("maximumCompositeVersion", package.MaxCompositeVersionSupported.ToString());

                packageXml.SaveTabbed(GetPackageConfigPath(package.Name));
            }
        }
Example #3
0
 public static EntityToken GetEntityToken(this PackageInformation packageInformation)
 {
     return(new PackageCreatorPackageElementProviderEntityToken(packageInformation.Name));
 }
Example #4
0
 /// <summary>
 /// Save package information to the config file
 /// </summary>
 /// <param name="package">Package information</param>
 public static void SavePackageInformation(PackageInformation package)
 {
     SavePackageInformation(package, package.Name);
 }