本文整理汇总了C#中System.Version.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Version.ToString方法的具体用法?C# Version.ToString怎么用?C# Version.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Version
的用法示例。
在下文中一共展示了Version.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCompilerVersionString
private static string GetCompilerVersionString(Version version)
{
if (version > new Version(4, 5))
return "v" + version.ToString(3); //v 4.5.1
else
return "v" + version.ToString(2);
}
示例2: Export
public void Export(IEnumerable<ApplicationStatistics> statistics, Version version, TimeSpan sessionDuration, Guid appKey)
{
var statToExport = Mapper.Map<IEnumerable<ApplicationStatistics>, IEnumerable<StatisticEntry>>(statistics);
var app = Get.Scalars().GetApplicationByAppKey(appKey);
if (app == null)
{
Get.Exporter().Insert(new Application()
{
ApplicationKey = Guid.NewGuid(),
InstallationDate = DateTime.Today,
LastUpdate = DateTime.Today,
UpdateVersion = DateTime.Today,
Version = version.ToString(),
});
}
else if (app.Version != version.ToString())
{
Get.Exporter().Update(app);
}
Get.Exporter().Insert(statToExport);
Get.Exporter().Insert(new SessionDuration()
{
Duration = sessionDuration,
TimeStamp = DateTime.Today,
Version = version.ToString(),
});
}
示例3: LaunchApp
static int LaunchApp(Version latestVersion, string partialExePath, string args, bool runAsAdmin)
{
int statusCode = 0;
string completeExePath = Path.Combine(Environment.CurrentDirectory,
latestVersion.ToString(),
partialExePath);
var info = new ProcessStartInfo(completeExePath)
{
WorkingDirectory = Path.Combine(Environment.CurrentDirectory,
latestVersion.ToString()),
Arguments = args
};
if (runAsAdmin)
{
info.Verb = "runas";
info.UseShellExecute = true;
}
try
{
Process.Start(info);
}
catch (Exception e)
{
ShowErrorMessageBox(e.GetType().ToString());
statusCode = 1;
}
return statusCode;
}
示例4: GetVersionInfo
public static HalanVersionInfo GetVersionInfo(string productName, Version currentVersion)
{
BasicHttpBinding_IProductManager p = new BasicHttpBinding_IProductManager();
LatestVersionRequest req = new LatestVersionRequest();
req.ProductName = productName;
req.CurrentProductVersion = currentVersion.ToString(4);
LatestVersionResponse resp = p.GetLatestVersion(req);
if( resp.ProductVersion.IsValid() ) {
HalanVersionInfo r = new HalanVersionInfo();
Version larestVer = new Version(resp.ProductVersion);
r.Product = productName;
r.ReleaseDate = resp.ReleaseDate;
r.Status = ( larestVer <= currentVersion ) ? VersionStatus.Latest : VersionStatus.Old;
r.LatestVersion = larestVer;
r.Features = resp.Features;
r.Url = resp.Url.Default("http://blog.halan.se/page/Service-Bus-MQ-Manager.aspx?update=true&v=" + currentVersion.ToString());
return r;
}
return null;
}
示例5: WriteToolInfo
private void WriteToolInfo(string name, string fileVersion, Version assemblyVersion)
{
_writer.WriteObjectStart("tool");
_writer.Write("name", name);
_writer.Write("version", assemblyVersion.ToString());
_writer.Write("fileVersion", fileVersion);
_writer.Write("semanticVersion", assemblyVersion.ToString(fieldCount: 3));
_writer.WriteObjectEnd();
}
示例6: UpdateForm
public UpdateForm(MLifterUpdateHandler updateHandler, Version newVersion)
{
UpdateHandler = updateHandler;
InitializeComponent();
labelTitle.Text = string.Format(Resources.HEADER, newVersion.ToString(3));
textBoxDescription.Rtf = Resources.DESCRIPTION;
labelDownloadTitle.Text = string.Format(Resources.TITLE, newVersion.ToString(3));
labelDownloadNote.Text = Resources.NOTE;
}
示例7: UpdateConfig
public virtual void UpdateConfig(string assemblyname, Version assemblyVersion, string culture, string publicKeyToken, string codeBaseLocation = null)
{
string invariant = CrmAdoConstants.Invariant;
string name = CrmAdoConstants.Name;
string description = CrmAdoConstants.Description;
string typeName = CrmAdoConstants.DbProviderFactorTypeName;
string fullyQualifiedAssemblyName = string.Format("{0}, Version={1}, Culture={2}, PublicKeyToken={3}", assemblyname, assemblyVersion.ToString(), culture, publicKeyToken);
Utils.RegisterDataProviderInMachineConfig(Utils.GetNET40Version(), invariant, name, description, typeName, fullyQualifiedAssemblyName);
if(!string.IsNullOrEmpty(codeBaseLocation))
{
Utils.RegisterAssemblyCodeBaseInMachineConfig(Utils.GetNET40Version(), assemblyname, publicKeyToken, culture, assemblyVersion.ToString(), codeBaseLocation);
}
}
示例8: Main
internal static int Main(String[] args)
{
// --- Check input ---
if (args.Length != 2)
{
Console.Error.WriteLine("Invalid number of parameters. Expected path to version.txt and output filename.");
return -1;
}
// --- Read in Dapple's major, minor and build numbers from version.txt ---
Version oMajorMinorBuild = new Version(File.ReadAllText(args[0]));
// --- Calculate the Dapple version number by the number of days that have passed since DappleEpoch.
// --- This will overflow in approx. 27.4 years. That should be long enough.
DateTime oNow = DateTime.Now;
int iRevision = (oNow - DappleEpoch).Days;
if (iRevision > 9999)
{
Console.Error.WriteLine("DynamicAssemblyInfo cannot complete the operation: too many days have passed since the epoch. Update DynamicAssemblyInfo's epoch to be newer.");
return -2;
}
Version oVersion = new Version(oMajorMinorBuild.Major, oMajorMinorBuild.Minor, oMajorMinorBuild.Build, (oNow - DappleEpoch).Days);
// --- Generate output file ---
StringBuilder output = new StringBuilder();
output.AppendLine("// -----------------------------------------------------------------------------");
output.AppendLine("// This file has been generated by DynamicAssemblyInfo.exe");
output.AppendLine("// -----------------------------------------------------------------------------");
output.AppendLine();
output.AppendLine("using System.Reflection;");
output.AppendLine("using System.Runtime.InteropServices;");
output.AppendLine();
output.AppendLine("[assembly: AssemblyCompanyAttribute(\"Geosoft Inc.\")]");
output.AppendLine("[assembly: AssemblyProductAttribute(\"Dapple\")]");
output.AppendLine("[assembly: AssemblyCopyrightAttribute(\"Copyright © " + oNow.Year.ToString(CultureInfo.InvariantCulture) + "\")]");
output.AppendLine("[assembly: AssemblyTrademarkAttribute(\"\")]");
output.AppendLine("[assembly: AssemblyVersionAttribute(\"" + oVersion.ToString(4) + "\")]");
output.AppendLine("[assembly: AssemblyFileVersion(\"" + oVersion.ToString(4) + "\")]");
output.AppendLine("[assembly: AssemblyDelaySignAttribute(false)]");
output.AppendLine("[assembly: AssemblyKeyNameAttribute(\"\")]");
output.AppendLine("[assembly: ComVisible(false)]");
File.WriteAllText(args[1], output.ToString());
return 0;
}
示例9: SetEngineVersion
internal static void SetEngineVersion(Version version)
{
if (version != null)
{
engineVersion = version.ToString();
}
}
示例10: GetProductNameAndVersion
internal static string GetProductNameAndVersion()
{
string name = Application.ProductName;
int revision = new Version(Application.ProductVersion).Revision;
string name_and_version = name.Insert(name.IndexOf(')'), ", revision " + revision.ToString());
return name_and_version;
}
示例11: GetVersion
public static string GetVersion(string fileVersionText)
{
var fileVersion = new Version(fileVersionText);
var version = new Version(fileVersion.Major, fileVersion.Minor);
var text = version.ToString();
return text;
}
示例12: GetGacAssemblyPaths
private static IEnumerable<string> GetGacAssemblyPaths(string gacPath, string name, Version version, string publicKeyToken)
{
if (version != null && publicKeyToken != null)
{
yield return Path.Combine(gacPath, name, version + "__" + publicKeyToken, name + ".dll");
yield break;
}
var gacAssemblyRootDir = new DirectoryInfo(Path.Combine(gacPath, name));
if (!gacAssemblyRootDir.Exists)
{
yield break;
}
foreach (var assemblyDir in gacAssemblyRootDir.GetDirectories())
{
if (version != null && !assemblyDir.Name.StartsWith(version.ToString(), StringComparison.Ordinal))
{
continue;
}
if (publicKeyToken != null && !assemblyDir.Name.EndsWith(publicKeyToken, StringComparison.Ordinal))
{
continue;
}
var assemblyPath = Path.Combine(assemblyDir.ToString(), name + ".dll");
if (File.Exists(assemblyPath))
{
yield return assemblyPath;
}
}
}
示例13: HandleMigrations
/// <summary>
/// Handles the migrations by using reflection to grab instances of MigrationBase.
/// </summary>
/// <param name="currentVersion">The current version.</param>
internal static void HandleMigrations(Version currentVersion)
{
LogHelper.Info<MigrationHelper>("Handling migrations based on current version =>" + currentVersion.ToString());
var migrations = typeof(MigrationBase)
.Assembly.GetTypes()
.Where(t => t.IsSubclassOf(typeof(MigrationBase)) && !t.IsAbstract)
.Select(t => (MigrationBase)Activator.CreateInstance(t))
.OrderBy(x => x.TargetVersion);
LogHelper.Info<MigrationHelper>("Total Migrations=>" + migrations.Count());
foreach (var migration in migrations)
{
LogHelper.Info<MigrationHelper>("Examining migration =>" + migration.TargetVersion);
if (migration.TargetVersion > currentVersion)
{
LogHelper.Info<MigrationHelper>("Executing...");
try
{
migration.Excecute();
}
catch (Exception ex)
{
LogHelper.Error<MigrationHelper>("Migration failed: " + migration.GetType() + "\n" + ex.Message, ex);
}
}
else
{
LogHelper.Info<MigrationHelper>("Skipped.");
}
}
}
示例14: GetRToolsPath
public static string GetRToolsPath(Version rToolsVersion)
{
if (Platform.GetPlatform() != System.PlatformID.Win32NT)
return null;
if (rToolsVersion == null)
return null;
string rToolsPath = null;
string programRegKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(programRegKey))
{
foreach (string subKey_name in key.GetSubKeyNames())
{
using (Microsoft.Win32.RegistryKey subKey = key.OpenSubKey(subKey_name))
{
if (subKey.GetValueNames().Contains("DisplayName") && subKey.GetValue("DisplayName").ToString().Contains("Rtools " + rToolsVersion.ToString()))
{
if (subKey.GetValueNames().Contains("InstallLocation"))
rToolsPath = subKey.GetValue("InstallLocation").ToString();
}
}
}
}
return rToolsPath;
}
示例15: CheckVersionForm_Load
private void CheckVersionForm_Load(object sender, EventArgs e)
{
Version serverVer = new Version(1, 0, 0, 0);
ManifestResolver r = new ManifestResolver(Program.UpdateURL, VersionOption.Stable);
try
{
r.Resolve();
serverVer = r.ReleaseManifest.Version;
}
catch
{
}
lblLastest.Text = "最新版本 : " + serverVer;
Version localVersion = new Version("1.0.0.0");
try
{
ReleaseManifest rm = new ReleaseManifest();
rm.Load(Path.Combine(Application.StartupPath, "release.xml"));
localVersion = rm.Version;
}
catch
{
localVersion = MainForm.Version;
}
lblCurrent.Text = "目前版本 : " + localVersion.ToString();
}