当前位置: 首页>>代码示例>>C#>>正文


C# Version.CompareTo方法代码示例

本文整理汇总了C#中System.Version.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Version.CompareTo方法的具体用法?C# Version.CompareTo怎么用?C# Version.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Version的用法示例。


在下文中一共展示了Version.CompareTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

 private static AbstractPersistentData Deserialize(string filePath, string importedBuildPath)
 {
     var deserializer = new IPersistentDataDeserializer[]
     {
         new PersistentDataDeserializerUpTo230(), new PersistentDataDeserializerCurrent()
     };
     var xmlString = File.ReadAllText(filePath);
     var version = SerializationUtils.XmlDeserializeString<XmlPersistentDataVersion>(xmlString).AppVersion;
     IPersistentDataDeserializer suitableDeserializer;
     if (version == null)
     {
         suitableDeserializer = deserializer.FirstOrDefault(c => c.MinimumDeserializableVersion == null);
     }
     else
     {
         var v = new Version(version);
         suitableDeserializer = deserializer.FirstOrDefault(c =>
             v.CompareTo(c.MinimumDeserializableVersion) >= 0
             && v.CompareTo(c.MaximumDeserializableVersion) <= 0);
     }
     if (suitableDeserializer == null)
     {
         throw new Exception(
             $"No converter available that can deserialize a PersistentData file with version {version}");
     }
     var data = new PersistentData(suitableDeserializer, importedBuildPath);
     suitableDeserializer.DeserializePersistentDataFile(xmlString);
     return data;
 }
开发者ID:EmmittJ,项目名称:PoESkillTree,代码行数:29,代码来源:PersistentDataSerializationService.cs

示例2: IsOnlineVersionGreater

        /// <summary>
        /// Conditional function to determine whether the supplied version is greater than the one found online.
        /// </summary>
        /// <param name="Type">Translation file type. Can also be for the App itself.</param>
        /// <param name="LocalVersionString">Version string of the local file to check against</param>
        /// <returns></returns>
        public bool IsOnlineVersionGreater(TranslationType Type, string LocalVersionString)
        {
            if (VersionXML == null)
                return true;

            IEnumerable<XElement> Versions = VersionXML.Root.Descendants("Item");
            string ElementName = "Version";
            Version LocalVersion = new Version(LocalVersionString);

            switch (Type)
            {
                case TranslationType.App:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("App")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Equipment:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Equipment")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Operations:
                case TranslationType.OperationSortie:
                case TranslationType.OperationMaps:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Operations")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Quests:
                case TranslationType.QuestDetail:
                case TranslationType.QuestTitle:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Quests")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.Ships:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("Ships")).FirstOrDefault().Element(ElementName).Value)) < 0;
                case TranslationType.ShipTypes:
                    return LocalVersion.CompareTo(new Version(Versions.Where(x => x.Element("Name").Value.Equals("ShipTypes")).FirstOrDefault().Element(ElementName).Value)) < 0;

            }

            return false;
        }
开发者ID:razgriz1412,项目名称:KanColleViewer,代码行数:38,代码来源:Updater.cs

示例3: TestCloneCompare

        public static void TestCloneCompare(Assert assert)
        {
            assert.Expect(13);

            var v1 = new Version(1, 2, 3, (4 << 16) + 5);

            var o = v1.Clone();
            assert.Ok(o != null, "v1 Cloned");

            var v2 = o as Version;
            assert.Ok(v2 != null, "v1 Cloned as Version");

            assert.Equal(v2.Major, 1, "v2.Major 1");
            assert.Equal(v2.Minor, 2, "v2.Minor 2");
            assert.Equal(v2.Build, 3, "v2.Build 3");
            assert.Equal(v2.Revision, 262149, "v2.Revision  (4 << 16) + 5 = 262149");
            assert.Equal(v2.MajorRevision, 4, "v2.MajorRevision 4");
            assert.Equal(v2.MinorRevision, 5, "v2.MinorRevision 5");

            var v3 = new Version(1, 2, 2, (4 << 16) + 5);
            assert.Equal(v1.CompareTo(v3), 1, "v1.CompareTo(v3)");

            var v4 = new Version(1, 3, 3, (4 << 16) + 5);
            assert.Equal(v1.CompareTo(v4), -1, "v1.CompareTo(v4)");

            assert.Equal(v1.CompareTo(o), 0, "v1.CompareTo(o)");
            assert.Equal(v1.CompareTo(v2), 0, "v1.CompareTo(v2)");
            assert.NotEqual(v1.CompareTo(null), 0, "v1.CompareTo(null)");
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:29,代码来源:TestVersion.cs

示例4: IsSupportedVersion

 public override bool IsSupportedVersion(Version version)
 {
     if (version == null) { return false; }
     var min = new Version("8.0");
     var max = new Version("8.1");
     if (version.CompareTo(min) != -1 && version.CompareTo(max) == -1)
     {
         return true;
     }
     return base.IsSupportedVersion(version);
 }
开发者ID:adamconn,项目名称:sitecore-linqpad,代码行数:11,代码来源:Sitecore8AppConfigReader.cs

示例5: FormCentralManager_Load

		private void FormCentralManager_Load(object sender,EventArgs e) {
			IsStartingUp=true;
			if(!GetConfigAndConnect()){
				return;
			}
			Cache.Refresh(InvalidType.Prefs);
			Version storedVersion=new Version(PrefC.GetString(PrefName.ProgramVersion));
			Version currentVersion=Assembly.GetAssembly(typeof(Db)).GetName().Version;
			if(storedVersion.CompareTo(currentVersion)!=0){
				MessageBox.Show("Program version: "+currentVersion.ToString()+"\r\n"
					+"Database version: "+storedVersion.ToString()+"\r\n"
					+"Versions must match.  Please manually connect to the database through the main program in order to update the version.");
				Application.Exit();
				return;
			}
			if(PrefC.GetString(PrefName.CentralManagerPassHash)!=""){
				FormCentralPasswordCheck formC=new FormCentralPasswordCheck();
				formC.ShowDialog();
				if(formC.DialogResult!=DialogResult.OK){
					Application.Exit();
					return;
				}
			}
			FillGrid();
			IsStartingUp=false;
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:26,代码来源:FormCentralManager.cs

示例6: FormCentralManager_Load

		private void FormCentralManager_Load(object sender,EventArgs e) {
			if(!GetConfigAndConnect()){
				return;
			}
			Cache.Refresh(InvalidType.Prefs);
			Version storedVersion=new Version(PrefC.GetString(PrefName.ProgramVersion));
			Version currentVersion=Assembly.GetAssembly(typeof(Db)).GetName().Version;
			if(storedVersion.CompareTo(currentVersion)!=0){
				MessageBox.Show(Lan.g(this,"Program version")+": "+currentVersion.ToString()+"\r\n"
					+Lan.g(this,"Database version")+": "+storedVersion.ToString()+"\r\n"
					+Lan.g(this,"Versions must match.  Please manually connect to the database through the main program in order to update the version."));
				Application.Exit();
				return;
			}
			if(PrefC.GetString(PrefName.CentralManagerPassHash)!=""){
				FormCentralPasswordCheck FormCPC=new FormCentralPasswordCheck();
				FormCPC.ShowDialog();
				if(FormCPC.DialogResult!=DialogResult.OK){
					Application.Exit();
					return;
				}
			}
			_listConnectionGroups=ConnectionGroups.GetListt();
			comboConnectionGroups.Items.Clear();
			comboConnectionGroups.Items.Add("All");
			for(int i=0;i<_listConnectionGroups.Count;i++) {
				comboConnectionGroups.Items.Add(_listConnectionGroups[i].Description);
			}
			comboConnectionGroups.SelectedIndex=0;//Select 'All' on load.
			FillGrid();
		}
开发者ID:mnisl,项目名称:OD,代码行数:31,代码来源:FormCentralManager.cs

示例7: Check

        public static void Check(string oldVersionStr)
        {
            try
            {
                var newVersionStr = new WebClient().DownloadString(new Uri(versionUrl));

                var newVersion = new Version(newVersionStr);
                var oldVersion = new Version(oldVersionStr);

                if(newVersion.CompareTo(oldVersion) > 0)
                {
                    var result = MessageBox.Show(
                        string.Format(
                            "Version {0} is available for download. You are running version {1}." +
                            Environment.NewLine + "Would you like to be sent to the download page?",
                            newVersion, oldVersion
                        ),

                        "New Version Available", MessageBoxButtons.YesNo, MessageBoxIcon.Question
                    );

                    if(result == DialogResult.Yes)
                        Process.Start(downloadPageUrl);
                }
            }
            catch
            {
                /* Suppress */
            }
        }
开发者ID:Nhowka,项目名称:WebMCam,代码行数:30,代码来源:Updater.cs

示例8: CheckVersion

        public static void CheckVersion(String coreVersion, String configVersion, String type, int mode = 0)
        {
            try
            {
                Version ver = new Version(configVersion);

                if (String.IsNullOrEmpty(coreVersion))
                    throw new UnsupportedCoreException(String.Format("Unsupported {0}. Version '{1}' or greater is required", type, configVersion));

                Version cv = new Version(coreVersion);

                if (mode == 0)
                {
                    if (ver.CompareTo(cv) > 0)
                        throw new UnsupportedCoreException(String.Format("Unsupported {0} '{1}'. Version '{2}' or greater is required", type, coreVersion, configVersion));

                    if (cv.Major != ver.Major)
                        throw new UnsupportedCoreException(String.Format("Unsupported {0} '{1}'. Major version is incompatible with server version '{2}'", type, coreVersion, configVersion));
                }

                if (mode == 1)
                {
                    if (!(ver.Major.Equals(cv.Major) && ver.Minor.Equals(cv.Minor) && ver.Build.Equals(cv.Build)))
                        throw new UnsupportedCoreException(String.Format("Unsupported {0} '{1}'. Version '{2}' is required", type, coreVersion, configVersion));
                }

            }
            catch (FormatException)
            {
                throw new System.FormatException(String.Format("Invalid {0} version format", type));
            }

        }
开发者ID:Fedorm,项目名称:core-master,代码行数:33,代码来源:Logon.cs

示例9: EmulatorLastVersionInfoRetrieved

        private void EmulatorLastVersionInfoRetrieved(object sender, EventArgs e)
        {
            Version currentEmulatorVersion = null;
            Version lastEmulatorVersion = null;

            menuItemUpdateEmulator.Enabled = true;
            progressCheckingLastVersion.Visible = false;

            if (Global.CurrentEmulatorVersion.Equals("N/A"))
            {
                labelNewVersionAvailable.BackColor = Color.Red;
                labelNewVersionAvailable.Text = "No se encontró el emulador WinUAE. Es neceario actualizar.";
            }
            else
            {
                currentEmulatorVersion = new Version(Global.CurrentEmulatorVersion);
                lastEmulatorVersion = new Version(Global.LastEmulatorVersion);

                if (currentEmulatorVersion.CompareTo(lastEmulatorVersion) < 0)
                {
                    labelNewVersionAvailable.BackColor = Color.LightGreen;
                    labelNewVersionAvailable.Text = "Hay una versión más actual del emulador.";
                }
                else
                {
                    labelNewVersionAvailable.Text = "El emulador está actualizado.";
                }
            }
        }
开发者ID:ariaththewise,项目名称:UWL,代码行数:29,代码来源:MainGUI.cs

示例10: displayUpdateInfo

        static void displayUpdateInfo(string remoteVersionString, string localVersionString) {
            var remoteVersion = new Version(remoteVersionString);
            var localVersion = new Version(localVersionString);

            switch (remoteVersion.CompareTo(localVersion)) {
                case 1:
                    if (EditorUtility.DisplayDialog("Entitas Update",
                            string.Format("A newer version of Entitas is available!\n\n" +
                            "Currently installed version: {0}\n" +
                            "New version: {1}", localVersion, remoteVersion),
                            "Show release",
                            "Cancel"
                        )) {
                        Application.OpenURL(URL_GITHUB_RELEASES);
                    }
                    break;
                case 0:
                    EditorUtility.DisplayDialog("Entitas Update",
                        "Entitas is up to date (" + localVersionString + ")",
                        "Ok"
                    );
                    break;
                case -1:
                    if (EditorUtility.DisplayDialog("Entitas Update",
                            string.Format("Your Entitas version seems to be newer than the latest release?!?\n\n" +
                            "Currently installed version: {0}\n" +
                            "Latest release: {1}", localVersion, remoteVersion),
                            "Show release",
                            "Cancel"
                        )) {
                        Application.OpenURL(URL_GITHUB_RELEASES);
                    }
                    break;
            }
        }
开发者ID:thebatoust,项目名称:EntitasTurnBasedGame,代码行数:35,代码来源:EntitasCheckForUpdates.cs

示例11: extractVersion

		private string extractVersion(XmlDocument doc)
		{
			if (doc != null)
			{				
				XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
				XmlNodeList nodes = doc.GetElementsByTagName("title");
				Version version = new Version();
				foreach (XmlNode node in nodes)
				{
					Regex versionRe = new Regex(@"d?nGREP\s+(?<version>[\d\.]+)\.\w+");

					if (versionRe.IsMatch(node.InnerText))
					{
						Version tempVersion = new Version(versionRe.Match(node.InnerText).Groups["version"].Value);
						if (version == null || version.CompareTo(tempVersion) < 0)
							version = tempVersion;
					}
				}
				return version.ToString();
			}
			else
			{
				return null;
			}
		}
开发者ID:shu2333,项目名称:dnGrep,代码行数:25,代码来源:PublishedVersionExtractor.cs

示例12: CompareToLatestVersion

 internal static void CompareToLatestVersion(Version CurrentVersionNumber)
 {
     if (CurrentVersionNumber.CompareTo(_LatestVersionNumber) < 0)
     {
         _NewerVersionAvailable = true;
     }
 }
开发者ID:OptecInc,项目名称:TCF-Software--PC-,代码行数:7,代码来源:NewVersionChecker.cs

示例13: VerifyDotNet

        public static bool VerifyDotNet(out string message, Version assemblyDotNETVersion)
        {
            if (assemblyDotNETVersion == null)
            {
                message = "Invalid executing assembly.";
                return false;
            }

            message = "";
            try
            {
                Version maxVersion = GetMaxVersion();
                int compare = assemblyDotNETVersion.CompareTo(maxVersion);
                if (compare > 0)
                {
                    message = String.Format("You have an outdated version of the .NET framework (v{0}).\nPlease update to version {1}.",
                                            maxVersion, assemblyDotNETVersion);
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return false;
            }
        }
开发者ID:REALTOBIZ,项目名称:SymmetricWebServer,代码行数:27,代码来源:VersionVerification.cs

示例14: CompareVersionsString

		public static int CompareVersionsString(this string strA, string strB)
		{
			var vA = new Version(strA.Replace(",", "."));
			var vB = new Version(strB.Replace(",", "."));

			return vA.CompareTo(vB);
		}
开发者ID:Synestry,项目名称:Unity-Framework,代码行数:7,代码来源:StringExtensions.cs

示例15: HasNewerVersion

        public static bool HasNewerVersion(out string p_CurrentVersion, out string p_Version, out string p_ReleaseURL, out bool p_PreRelease)
        {
            var s_Assembly = Assembly.GetExecutingAssembly();
            var s_VersionInfo = FileVersionInfo.GetVersionInfo(s_Assembly.Location);
            p_CurrentVersion = s_VersionInfo.FileVersion.Trim();

            p_Version = p_CurrentVersion;
            p_ReleaseURL = null;
            p_PreRelease = false;

            var s_ReleaseData = GetLatestReleaseData();

            if (string.IsNullOrWhiteSpace(s_ReleaseData))
                return false;

            string s_LatestVersionString;
            if (!ParseReleaseData(s_ReleaseData, out s_LatestVersionString, out p_ReleaseURL, out p_PreRelease))
                return false;

            try
            {
                var s_CurrentVersion = new Version(p_CurrentVersion);
                var s_LatestVersion = new Version(s_LatestVersionString);

                p_Version = s_LatestVersionString;

                return s_LatestVersion.CompareTo(s_CurrentVersion) > 0;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:OrfeasZ,项目名称:Statman,代码行数:33,代码来源:UpdateChecker.cs


注:本文中的System.Version.CompareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。