本文整理汇总了C#中System.Version类的典型用法代码示例。如果您正苦于以下问题:C# Version类的具体用法?C# Version怎么用?C# Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Version类属于System命名空间,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
/// <summary>
/// Создает на основе типа фильтр
/// </summary>
/// <param name="lib"></param>
/// <param name="type"></param>
public Filter(string lib, Type type)
{
libname = lib;
if (type.BaseType == typeof(AbstractFilter))
{
Exception fullex = new Exception("");
ConstructorInfo ci = type.GetConstructor(System.Type.EmptyTypes);
filter = ci.Invoke(null);
PropertyInfo everyprop;
everyprop = type.GetProperty("Name");
name = (string)everyprop.GetValue(filter, null);
everyprop = type.GetProperty("Author");
author = (string)everyprop.GetValue(filter, null);
everyprop = type.GetProperty("Ver");
version = (Version)everyprop.GetValue(filter, null);
help = type.GetMethod("Help");
MethodInfo[] methods = type.GetMethods();
filtrations = new List<Filtration>();
foreach (MethodInfo mi in methods)
if (mi.Name == "Filter")
{
try
{
filtrations.Add(new Filtration(mi));
}
catch (TypeLoadException)
{
//Не добавляем фильтрацию.
}
}
if (filtrations == null) throw new TypeIncorrectException("Класс " + name + " не содержит ни одной фильтрации");
}
else
throw new TypeLoadException("Класс " + type.Name + " не наследует AbstractFilter");
}
示例2: UpdateBarModel
public UpdateBarModel(Version version, string downloadUri)
{
if (version == null || downloadUri == null)
{
UpdateAvailable = false;
return;
}
Version = version;
var currentVersion = typeof(CertInspector).Assembly.GetName().Version;
var closed = Fiddler.FiddlerApplication.Prefs.GetPref(PreferenceNames.HIDE_UPDATED_PREF, false);
UpdateAvailable = version > currentVersion && !closed;
Fiddler.FiddlerApplication.Log.LogString($"FiddlerCert Inspector: Current version is {currentVersion}, latest version is {version}.");
_downloadCommand = new RelayCommand(_ =>
{
var uri = new Uri(downloadUri);
if (uri?.Scheme == Uri.UriSchemeHttps)
{
Process.Start(uri.AbsoluteUri);
}
else
{
Fiddler.FiddlerApplication.Log.LogString("Refusing to open non-HTTPS page.");
}
});
_closeCommand = new RelayCommand(_ =>
{
Fiddler.FiddlerApplication.Prefs.SetPref(PreferenceNames.HIDE_UPDATED_PREF, true);
UpdateAvailable = false;
});
}
示例3: UpdateFiles
public void UpdateFiles()
{
try
{
WriteLine("Local version: " + Start.m_Version);
WebClient wc = new WebClient();
string versionstr;
using(System.IO.StreamReader sr = new System.IO.StreamReader(wc.OpenRead(baseurl + "version.txt")))
{
versionstr = sr.ReadLine();
}
Version remoteversion = new Version(versionstr);
WriteLine("Remote version: " + remoteversion);
if(Start.m_Version < remoteversion)
{
foreach(string str in m_Files)
{
WriteLine("Updating: " + str);
wc.DownloadFile(baseurl + str, str);
}
}
wc.Dispose();
WriteLine("Update complete");
}
catch(Exception e)
{
WriteLine("Update failed:");
WriteLine(e);
}
this.Button_Ok.Enabled = true;
}
示例4: Can_Upgrade_From_470_To_600
public override void Can_Upgrade_From_470_To_600()
{
var configuredVersion = new Version("4.11.0");
var targetVersion = new Version("6.0.0");
var provider = GetDatabaseProvider();
var db = GetConfiguredDatabase();
var fix = new PublishAfterUpgradeToVersionSixth();
//Setup the MigrationRunner
var migrationRunner = new MigrationRunner(configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName);
bool upgraded = migrationRunner.Execute(db, provider, true);
Assert.That(upgraded, Is.True);
bool hasTabTable = db.TableExist("cmsTab");
bool hasPropertyTypeGroupTable = db.TableExist("cmsPropertyTypeGroup");
bool hasAppTreeTable = db.TableExist("umbracoAppTree");
fix.Unsubscribe();
Assert.That(hasTabTable, Is.False);
Assert.That(hasPropertyTypeGroupTable, Is.True);
Assert.That(hasAppTreeTable, Is.False);
}
示例5: UserAccountsMigrator_1
public UserAccountsMigrator_1()
{
Version = new Version(0, 0, 1);
MigrationName = "UserAccounts";
schema = new List<SchemaDefinition>();
//Remove the old name
this.RemoveSchema("UserAccounts");
//Add the `Name` column
AddSchema("useraccounts", ColDefs(
ColDef("PrincipalID", ColumnTypes.Char36),
ColDef("ScopeID", ColumnTypes.Char36),
ColDef("FirstName", ColumnTypes.String64),
ColDef("LastName", ColumnTypes.String64),
ColDef("Email", ColumnTypes.String64),
ColDef("ServiceURLs", ColumnTypes.Text),
ColDef("Created", ColumnTypes.Integer11),
ColDef("UserLevel", ColumnTypes.Integer11),
ColDef("UserFlags", ColumnTypes.Integer11),
ColDef("UserTitle", ColumnTypes.String64),
ColDef("Name", ColumnTypes.String255)
), IndexDefs(
IndexDef(new string[1] {"PrincipalID"}, IndexType.Primary)
));
}
示例6: RetargetWithMetadataConverter
/// <remarks>Internal for testing.</remarks>
internal static void RetargetWithMetadataConverter(XDocument xdoc, Version targetSchemaVersion, MetadataConverterDriver converter)
{
Debug.Assert(xdoc != null, "xdoc != null");
Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid target schema version");
var inputXml = new XmlDocument { PreserveWhitespace = true };
using (var reader = xdoc.CreateReader())
{
inputXml.Load(reader);
}
var outputXml = converter.Convert(inputXml, targetSchemaVersion);
if (outputXml != null)
{
// Dev10 Bug 550594: There is a bug in XmlEditor that prevents from deleting the root node
// unless the root node has previous sibling (like a comment or Xml declaration).
if (xdoc.Root.PreviousNode == null)
{
xdoc.Root.AddBeforeSelf(new XComment(""));
}
// update xml document with new root element
xdoc.Root.Remove();
using (var reader = new XmlNodeReader(outputXml))
{
var newDoc = XDocument.Load(reader);
xdoc.Add(newDoc.Root);
}
// Do not reload artifact here
// Until the transaction is commited, the XLinq representation of the parsed xml tree hasn't been generated yet.
}
}
示例7: GetVersionPresent
public override Version GetVersionPresent(object feature)
{
Version version = null;
if (feature == LayeredWindows)
{
if ((Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.CompareTo(new Version(5, 0, 0, 0)) >= 0))
{
version = new Version(0, 0, 0, 0);
}
return version;
}
if (feature == Themes)
{
if (!themeSupportTested)
{
try
{
SafeNativeMethods.IsAppThemed();
themeSupport = true;
}
catch
{
themeSupport = false;
}
themeSupportTested = true;
}
if (themeSupport)
{
version = new Version(0, 0, 0, 0);
}
}
return version;
}
示例8: CheckVersion
public static void CheckVersion()
{
try
{
var match =
new Regex(
@"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]")
.Match(DownloadServerVersion());
if (!match.Success) return;
var gitVersion =
new Version(
string.Format(
"{0}.{1}.{2}.{3}",
match.Groups[1],
match.Groups[2],
match.Groups[3],
match.Groups[4]));
if (gitVersion <= Assembly.GetExecutingAssembly().GetName().Version)
{
ColoredConsoleWrite(ConsoleColor.Green, "Awesome! You have already got the newest version! " + Assembly.GetExecutingAssembly().GetName().Version);
return;
}
ColoredConsoleWrite(ConsoleColor.Red, "There is a new Version available: " + gitVersion);
ColoredConsoleWrite(ConsoleColor.Red, "You can find it at https://github.com/DetectiveSquirrel/Pokemon-Go-Rocket-API");
}
catch (Exception)
{
ColoredConsoleWrite(ConsoleColor.Red, "Unable to check for updates now...");
}
}
示例9: IsSupported
public bool IsSupported(Version cssVersion, ICssCompletionListEntry entry)
{
if (WESettings.GetBoolean(WESettings.Keys.ShowUnsupported))
return entry.IsSupported(cssVersion);
return entry.GetAttribute("browsers") != "none" || entry.DisplayText.Contains("gradient");
}
示例10: WriteSolutionVersionProperties
public void WriteSolutionVersionProperties(SolutionFormatVersion version, Version currVSVersion, Version minVSVersion)
{
if (version >= SolutionFormatVersion.VS2012) {
writer.WriteLine("VisualStudioVersion = {0}", currVSVersion);
writer.WriteLine("MinimumVisualStudioVersion = {0}", minVSVersion);
}
}
示例11: AuthMigrator_3
public AuthMigrator_3()
{
Version = new Version(0, 0, 3);
MigrationName = "Auth";
schema = new List<SchemaDefinition>();
//
// Change summery:
//
// Make the password hash much longer to accommodate other types of passwords)
//
AddSchema("auth", ColDefs(
ColDef("UUID", ColumnTypes.Char36),
ColDef("passwordHash", ColumnTypes.String1024),
ColDef("passwordSalt", ColumnTypes.String1024),
ColDef("accountType", ColumnTypes.Char32)
), IndexDefs(
IndexDef(new string[2]{ "UUID", "accountType" }, IndexType.Primary)
));
AddSchema("tokens", ColDefs(
ColDef("UUID", ColumnTypes.Char36),
ColDef("token", ColumnTypes.String255),
ColDef("validity", ColumnTypes.Date)
), IndexDefs(
IndexDef(new string[2]{ "UUID", "token" }, IndexType.Primary)
));
}
示例12: NormalizeVersionValue
private static Version NormalizeVersionValue(Version version)
{
return new Version(version.Major,
version.Minor,
Math.Max(version.Build, 0),
Math.Max(version.Revision, 0));
}
示例13: CheckVersion
public void CheckVersion()
{
try
{
var match =
new Regex(
@"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]")
.Match(DownloadServerVersion());
if (!match.Success) return;
var gitVersion =
new Version(
string.Format(
"{0}.{1}.{2}.{3}",
match.Groups[1],
match.Groups[2],
match.Groups[3],
match.Groups[4]));
// makes sense to display your version and say what the current one is on github
ColoredConsoleWrite(Color.Green, "Your version is " + Assembly.GetExecutingAssembly().GetName().Version);
ColoredConsoleWrite(Color.Green, "Github version is " + gitVersion);
ColoredConsoleWrite(Color.Green, "You can find it at www.GitHub.com/DetectiveSquirrel/Pokemon-Go-Rocket-API");
}
catch (Exception)
{
ColoredConsoleWrite(Color.Red, "Unable to check for updates now...");
}
}
示例14: OnAppStart
public static void OnAppStart(Version version, LoginType loginType, bool isNew)
{
if(!Config.Instance.GoogleAnalytics)
return;
Google.TrackPageView($"/app/v{version.ToVersionString()}/{loginType.ToString().ToLower()}{(isNew ? "/new" : "")}", "");
WritePoint(new InfluxPointBuilder("hdt_app_start").Tag("version", version.ToVersionString()).Tag("login_type", loginType).Tag("new", isNew).Build());
}
示例15: SchedulerMigrator_1
public SchedulerMigrator_1()
{
Version = new Version(0, 0, 1);
MigrationName = "Scheduler";
schema = new List<Rec<string, ColumnDefinition[]>>();
AddSchema("scheduler", ColDefs(ColDef("id", ColumnTypes.String36, true),
ColDef("fire_function", ColumnTypes.String128),
ColDef("fire_params", ColumnTypes.String1024),
ColDef("run_once", ColumnTypes.TinyInt1),
ColDef("run_every", ColumnTypes.Integer30),
ColDef("runs_next", ColumnTypes.Integer30, true),
ColDef("keep_history", ColumnTypes.TinyInt1),
ColDef("require_reciept", ColumnTypes.TinyInt1),
ColDef("last_history_id", ColumnTypes.String36),
ColDef("create_time", ColumnTypes.Integer30),
ColDef("enabled", ColumnTypes.TinyInt1, true)
));
AddSchema("scheduler_history", ColDefs(ColDef("id", ColumnTypes.String36, true),
ColDef("scheduler_id", ColumnTypes.String36, true),
ColDef("ran_time", ColumnTypes.Integer30),
ColDef("run_time", ColumnTypes.Integer30),
ColDef("reciept", ColumnTypes.String1024),
ColDef("is_complete", ColumnTypes.TinyInt1),
ColDef("complete_time", ColumnTypes.Integer30)
));
}