Example #1
0
        public System.Version GetBackedUpVersion(IPlugin plugin)
        {
            System.Version version = null;
            IPlugin        p       = backedUpPlugins.Find(plugin);

            if (p != null)
            {
                version = p.Version;
            }
            return(version);
        }
Example #2
0
        static MonoCompat()
        {
            Type monoRuntimeType = typeof(object).Assembly.GetType("Mono.Runtime");

            if (monoRuntimeType != null)
            {
                IsMono = true;
                MethodInfo getDisplayNameMethod = monoRuntimeType.GetMethod("GetDisplayName", MonoMethodFlags, null, Type.EmptyTypes, null);

                if (getDisplayNameMethod != null)
                {
                    MonoVersionString = (string)getDisplayNameMethod.Invoke(null, null);

                    try
                    {
                        Match versionMatch = VersionRegex.Match(MonoVersionString);
                        int   major        = Int32.Parse(versionMatch.Groups[1].Value);
                        int   minor        = Int32.Parse(versionMatch.Groups[2].Value);
                        int   revision     = Int32.Parse(versionMatch.Groups[3].Value);
                        MonoVersion   = new System.Version(major, minor, revision);
                        IsSGenCapable = (major == 2 && minor >= 8);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(UnsupportedMessage, ex);
                    }

                    if (MonoVersion.Major < 2 && MonoVersion.Major < 6)
                    {
                        throw new Exception(UnsupportedMessage);
                    }
                }
                else
                {
                    throw new Exception(UnsupportedMessage);
                }
            }

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.MacOSX:
            case PlatformID.Unix:
                IsMono    = true;
                IsWindows = false;
                break;

            default:
                IsWindows = true;
                break;
            }

            IsCaseSensitive = !IsWindows;
        }
    private static Version GetExpectedAssemblyVersion(VersionOptions versionOptions, Version version)
    {
        // Function should be very similar to VersionOracle.GetAssemblyVersion()
        var assemblyVersion = (versionOptions?.AssemblyVersion?.Version ?? versionOptions.Version.Version).EnsureNonNegativeComponents();
        var precision       = versionOptions?.AssemblyVersion?.Precision ?? VersionOptions.DefaultVersionPrecision;

        assemblyVersion = new System.Version(
            assemblyVersion.Major,
            precision >= VersionOptions.VersionPrecision.Minor ? assemblyVersion.Minor : 0,
            precision >= VersionOptions.VersionPrecision.Build ? version.Build : 0,
            precision >= VersionOptions.VersionPrecision.Revision ? version.Revision : 0);
        return(assemblyVersion);
    }
Example #4
0
        public override void ConstructFromXml(XmlNode node, XmlDocument document)
        {
            base.ConstructFromXml(node, document);

            //One offs
            templateFormat = new System.Version(node.GetAttribute("format", "1.0"));
            priority       = node.GetAttribute <int>("priority", 0);

            if (IsTemplateFormatSupported(templateFormat))
            {
                bool hasAddedUsingPlaceholder = false;

                //Children
                foreach (XmlNode child in node.ChildNodes)
                {
                    XmlBase xmlBase = CreateXmlObjectFromNode(child, document);

                    if (xmlBase != null)
                    {
                        if (xmlBase is XmlUsingNamespace)
                        {
                            usings.Add(xmlBase as XmlUsingNamespace);

                            if (!hasAddedUsingPlaceholder)
                            {
                                children.Add(new XmlUsingNamespacePlaceholder());
                                hasAddedUsingPlaceholder = true;
                            }
                        }
                        else if (xmlBase is XmlBuildOption)
                        {
                            buildOptions.Add(xmlBase as XmlBuildOption);
                        }
                        else
                        {
                            children.Add(xmlBase);
                        }
                    }
                }
            }
            else
            {
                isMalformed = true;
            }
        }
Example #5
0
        /// <summary>
        /// checks if there is an update for this assembly
        /// </summary>
        public static void UpdateCheck()
        {
            try
            {
                using (var web = new WebClient())
                {
                    var source = "https://raw.githubusercontent.com/KyonLeague/RAREScripts/master/RAREKarthus/RAREKarthus/RAREKarthus.csproj";

                    if (source == "")
                    {
                        return;
                    }

                    var rawFile   = web.DownloadString(source);
                    var checkFile =
                        new Regex(@"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]").Match
                            (rawFile);

                    if (!checkFile.Success)
                    {
                        return;
                    }

                    var gitVersion =
                        new System.Version(
                            $"{checkFile.Groups[1]}.{checkFile.Groups[2]}.{checkFile.Groups[3]}.{checkFile.Groups[4]}");

                    if (gitVersion > Assembly.GetExecutingAssembly().GetName().Version)
                    {
                        PrintChat("Outdated! Newest Version: " + gitVersion);
                    }
                    else
                    {
                        PrintChat("You are on the newest version: " + gitVersion);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        private void PopulateFromPackageData(LocalPackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);
            //this will load in all the metadata too
            var tempDir = ins.Import(model.ZipFilePath, false);

            model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempDir);
            model.Name       = ins.Name;
            model.Author     = ins.Author;
            model.AuthorUrl  = ins.AuthorUrl;
            model.IconUrl    = ins.IconUrl;
            model.License    = ins.License;
            model.LicenseUrl = ins.LicenseUrl;
            model.ReadMe     = ins.ReadMe;
            model.ConflictingMacroAliases       = ins.ConflictingMacroAliases;
            model.ConflictingStyleSheetNames    = ins.ConflictingStyleSheetNames;
            model.ConflictingTemplateAliases    = ins.ConflictingTemplateAliases;
            model.ContainsBinaryFileErrors      = ins.ContainsBinaryFileErrors;
            model.ContainsLegacyPropertyEditors = ins.ContainsLegacyPropertyEditors;
            model.ContainsMacroConflict         = ins.ContainsMacroConflict;
            model.ContainsStyleSheetConflicts   = ins.ContainsStyleSheeConflicts;
            model.ContainsTemplateConflicts     = ins.ContainsTemplateConflicts;
            model.ContainsUnsecureFiles         = ins.ContainsUnsecureFiles;
            model.Url     = ins.Url;
            model.Version = ins.Version;

            model.UmbracoVersion = ins.RequirementsType == RequirementsType.Strict
                ? string.Format("{0}.{1}.{2}", ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch)
                : string.Empty;

            //now we need to check for version comparison
            model.IsCompatible = true;
            if (ins.RequirementsType == RequirementsType.Strict)
            {
                var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
                if (UmbracoVersion.Current < packageMinVersion)
                {
                    model.IsCompatible = false;
                }
            }
        }
        public PackageInstallModel Import(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            var tempPath = ins.Import(model.ZipFilePath);

            //now we need to check for version comparison
            if (ins.RequirementsType == RequirementsType.Strict)
            {
                var packageMinVersion = new System.Version(ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch);
                if (UmbracoVersion.Current < packageMinVersion)
                {
                    throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse(
                                                        Services.TextService.Localize("packager/targetVersionMismatch", new[] { packageMinVersion.ToString() })));
                }
            }

            model.TemporaryDirectoryPath = Path.Combine(SystemDirectories.Data, tempPath);
            model.Id = ins.CreateManifest(IOHelper.MapPath(model.TemporaryDirectoryPath), model.PackageGuid.ToString(), model.RepositoryGuid.ToString());

            return(model);
        }
Example #8
0
        public void RefreshInstalledPlugins()
        {
            if (Application.Current.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
            {
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, (System.Windows.Forms.MethodInvoker)RefreshInstalledPlugins);
                return;
            }

            installedPlugins.Clear();
            foreach (var plugin in Kernel.Instance.Plugins.OrderBy(p => p.Name))
            {
                System.Version v  = GetLatestVersion(plugin);
                System.Version rv = plugin.RequiredMBVersion;
                if (v != null)
                {
                    plugin.UpdateAvail = (v > plugin.Version && rv <= Kernel.Instance.Version);
                    UpdateAvailableAttributes(plugin, true);
                }
                plugin.Installed = true;
                installedPlugins.Add(plugin);
            }
        }