本文整理汇总了C#中Version.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Version.ToString方法的具体用法?C# Version.ToString怎么用?C# Version.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
string projectName = args[0];
string projectNameExe = projectName + ".exe";
string projectFolder = args[1];
string binaryFolder = projectFolder + @"\" + projectName + @"\bin\Release\";
string assemblyPath = binaryFolder + projectNameExe;
FileVersionInfo assemblyInfo = FileVersionInfo.GetVersionInfo(assemblyPath);
Version version = new Version(assemblyInfo.FileVersion);
Console.WriteLine("Project name: " + projectName);
Console.WriteLine("Project folder: " + projectFolder);
Console.WriteLine("Binary folder: " + binaryFolder);
Console.WriteLine("Assembly path: " + assemblyPath);
Console.WriteLine("Version: " + version.ToString());
Console.WriteLine("Manufacturer: " + assemblyInfo.CompanyName);
Project project =
new Project(projectName + "_" + version.ToString(),
new Dir(new Id("INSTALL_DIR"), @"%ProgramFiles%\" + projectName,
new Files(binaryFolder + "*.exe"),
new Files(binaryFolder + "*.exe.config"),
new Files(binaryFolder + "*.dll"),
new Dir(@"%ProgramMenu%\" + projectName,
new ExeFileShortcut(projectName, "[INSTALL_DIR]" + projectNameExe, ""),
new ExeFileShortcut("Uninstall " + projectName, "[System64Folder]msiexec.exe", "/x [ProductCode]")
),
new Dir(@"%Startup%\",
new ExeFileShortcut(projectName, "[INSTALL_DIR]" + projectNameExe, "")
)
)
);
project.Version = version;
project.GUID = new Guid("54f5a0b8-6f60-4a70-a095-43e2b93bc0fe");
//project.SetNetFxPrerequisite("NETFRAMEWORK45 >='#378389'", "Please install .Net 4.5 first");
//project.ControlPanelInfo.ProductIcon = projectFolder + @"\" + projectName + @"\Resources\trafficlights.ico";
project.ControlPanelInfo.NoModify = true;
project.ControlPanelInfo.Manufacturer = assemblyInfo.CompanyName;
project.UI = WUI.WixUI_Common;
var customUI = new CommomDialogsUI();
var prevDialog = Dialogs.WelcomeDlg;
var nextDialog = Dialogs.VerifyReadyDlg;
customUI.UISequence.RemoveAll(x => (x.Dialog == prevDialog && x.Control == Buttons.Next) || (x.Dialog == nextDialog && x.Control == Buttons.Back));
customUI.On(prevDialog, Buttons.Next, new ShowDialog(nextDialog));
customUI.On(nextDialog, Buttons.Back, new ShowDialog(prevDialog));
project.CustomUI = customUI;
Compiler.BuildMsi(project);
}
示例2: CreatePSNegotiationData
internal static CimInstance CreatePSNegotiationData(Version powerShellVersion)
{
CimInstance c = InternalMISerializer.CreateCimInstance("PS_NegotiationData");
CimProperty versionproperty = InternalMISerializer.CreateCimProperty("PSVersion", powerShellVersion.ToString(), Microsoft.Management.Infrastructure.CimType.String);
c.CimInstanceProperties.Add(versionproperty);
return c;
}
示例3: NegTest1
public bool NegTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("NegTest1: ArgumentException is not thrown.");
try
{
Version version = new Version(1, 3, 5);
string str = version.ToString(4);
TestLibrary.TestFramework.LogError("101.1", " ArgumentException is not thrown.");
retVal = false;
}
catch (ArgumentException)
{ }
catch (Exception e)
{
TestLibrary.TestFramework.LogError("101.2", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例4: PosTest1
public bool PosTest1()
{
bool retVal = true;
// Add your scenario description here
TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method ToString(int)");
try
{
int intMajor = TestLibrary.Generator.GetInt32(-55);
int intMinor = TestLibrary.Generator.GetInt32(-55);
int intBuild = TestLibrary.Generator.GetInt32(-55);
int intRevision = TestLibrary.Generator.GetInt32(-55);
Version version= new Version(intMajor, intMinor, intBuild, intRevision);
if ( version.ToString(0) != ""
|| version.ToString(1) != intMajor.ToString()
|| version.ToString(2) != intMajor.ToString() + "." + intMinor.ToString()
|| version.ToString(3) != intMajor.ToString() + "." + intMinor.ToString() + "." + intBuild.ToString()
|| version.ToString(4) != intMajor.ToString() + "." + intMinor.ToString() + "." + intBuild.ToString() + "." + intRevision.ToString())
{
Console.WriteLine("excepted value is :" + version.ToString(0) + " "
+ version.ToString(1) + " "
+ version.ToString(2) + " "
+ version.ToString(3) + " "
+ version.ToString(4));
Console.WriteLine("actual value is :" + intMajor + " " + intMinor + " "
+ intBuild + " " + intRevision);
TestLibrary.TestFramework.LogError("001.1", "ToString() failed!");
retVal = false;
return retVal;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例5: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
String strLoc = "Loc_000oo";
String strValue = String.Empty;
int iCountErrors = 0;
int iCountTestcases = 0;
try
{
Version vTest1 = new Version (5,3);
strLoc = "Loc_100vy";
iCountTestcases++;
if (vTest1.ToString() != "5.3" )
{
++iCountErrors;
printerr( "Error_100aa! Expected==5.3");
}
vTest1 = new Version (10,11,12);
strLoc = "Loc_400vy";
iCountTestcases++;
if (vTest1.ToString() != "10.11.12" )
{
++iCountErrors;
printerr( "Error_400aa! Expected==10.11.12");
}
vTest1 = new Version (550,500,2,7);
strLoc = "Loc_700vy";
iCountTestcases++;
if (vTest1.ToString() != "550.500.2.7" )
{
++iCountErrors;
printerr( "Error_700aa! Expected==550.500.2.7");
}
strLoc = "Loc_110zz";
vTest1 = new Version (Int32.MaxValue,500,0,1);
iCountTestcases++;
if (vTest1.ToString() != Int32.MaxValue.ToString() + ".500.0.1" )
{
++iCountErrors;
printerr( "Error_100xx! Expected==" + Int32.MaxValue.ToString() + ".500.0.1");
}
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例6: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: Ensure ToString() successful.");
Version TestVersion = null;
try
{
for (int i = 0; i < 50; i++)
{
int intMajor = TestLibrary.Generator.GetInt32(-55);
int intMinor = TestLibrary.Generator.GetInt32(-55);
int intBuild = TestLibrary.Generator.GetInt32(-55);
int intRevision = TestLibrary.Generator.GetInt32(-55);
TestVersion = new Version(intMajor, intMinor, intBuild, intRevision);
String VersionString = null;
VersionString = String.Concat(VersionString, intMajor.ToString());
VersionString = String.Concat(VersionString, ".");
VersionString = String.Concat(VersionString, intMinor.ToString());
VersionString = String.Concat(VersionString, ".");
VersionString = String.Concat(VersionString, intBuild.ToString());
VersionString = String.Concat(VersionString, ".");
VersionString = String.Concat(VersionString, intRevision.ToString());
if (TestVersion.ToString() != VersionString)
{
TestLibrary.TestFramework.LogError("P01.1", "ToString() failed!" + TestVersion.ToString());
retVal = false;
return retVal;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("P01.2", "Unexpected exception: " + e + TestVersion.ToString());
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例7: PosTest1
public bool PosTest1()
{
TestLibrary.TestFramework.BeginScenario("PosTest1: check version which set in ctor");
bool retVal = true;
try
{
Version ver = new Version(1,0,0,1);
AssemblyName an = new AssemblyName("aa, Version="+ver.ToString());
if (!an.Version.Equals(ver))
{
TestLibrary.TestFramework.LogError("001.1", "expect Version is " + ver.ToString());
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例8: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: Ensure GetHashCode() successful.");
Version TestVersion = null;
try
{
for (int i = 0; i < 50; i++)
{
int intMajor = TestLibrary.Generator.GetInt32(-55);
int intMinor = TestLibrary.Generator.GetInt32(-55);
int intBuild = TestLibrary.Generator.GetInt32(-55);
int intRevision = TestLibrary.Generator.GetInt32(-55);
TestVersion = new Version(intMajor, intMinor, intBuild, intRevision);
int accumulator = 0;
accumulator |= (TestVersion.Major & 0x0000000F) << 28;
accumulator |= (TestVersion.Minor & 0x000000FF) << 20;
accumulator |= (TestVersion.Build & 0x000000FF) << 12;
accumulator |= (TestVersion.Revision & 0x00000FFF);
if (TestVersion.GetHashCode() != accumulator)
{
TestLibrary.TestFramework.LogError("P01.1", "GetHashCode() failed!" + TestVersion.ToString());
retVal = false;
return retVal;
}
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("P01.2", "Unexpected exception: " + e + TestVersion.ToString());
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例9: PosTest2
public bool PosTest2()
{
TestLibrary.TestFramework.BeginScenario("PosTest2: version in FullName");
bool retVal = true;
try
{
AssemblyName an = new AssemblyName("aa");
Version ver = new Version("10.100.1000.10000");
an.Version = ver;
if (!an.FullName.Contains("Version="+ver.ToString()))
{
TestLibrary.TestFramework.LogError("002.1", "expect an.FullName.Contains " + ver.ToString());
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例10: HttpResponse
public HttpResponse(
Version httpVersion,
HttpStatusCode statusCode,
string body,
string contentType = "text/plain; charset=utf-8")
{
ServerEngineName = "ConsoleWebServer";
;
ProtocolVersion = Version.Parse(httpVersion.ToString().ToLower().Replace("HTTP/".ToLower(), string.Empty));
Headers = new SortedDictionary<string, ICollection<string>>();
Body = body;
StatusCode = statusCode;
AddHeader("Server", ServerEngineName);
AddHeader("Content-Length", body.Length.ToString());
AddHeader("Content-Type", contentType);
}
示例11: UpdateAvailable
public Update UpdateAvailable(Preferences preferences) {
var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
Version latestVersion;
var update = this._repository.Get();
if (DateTime.Now.Subtract(TimeSpan.FromDays(1.0)) > update.LastChecked) {
var request = WebRequest.Create("http://flickrdownloadr.com/build.number");
var response = (HttpWebResponse) request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream())) {
latestVersion = new Version(reader.ReadToEnd());
}
update.LastChecked = DateTime.Now;
update.LatestVersion = latestVersion.ToString();
} else {
latestVersion = new Version(update.LatestVersion);
}
update.Available = latestVersion.CompareTo(currentVersion) > 0;
this._repository.Save(update);
return update;
}
示例12: CreateNuspec
private static void CreateNuspec(
string id,
Version version,
string description,
IEnumerable<File> fileList,
IEnumerable<Dependency> dependencyList,
IEnumerable<string> tags)
{
var nuspec =
N("package").Append(
N("metadata").Append(
N("id", id),
N("version", version.ToString()),
N("authors", Config.Authors),
N("owners", Config.Owners),
N("licenseUrl", "http://getboost.codeplex.com/license"),
N("projectUrl", "http://getboost.codeplex.com/"),
N("requireLicenseAcceptance", "false"),
N("description", description),
N("dependencies").Append(
dependencyList.Select(
d =>
N(
"dependency",
Xml.A("id", d.Id),
Xml.A("version", d.Version)
)
)
),
N("tags", string.Join(" ", tags))
),
N("files").Append(fileList.Select(f => f.N))
);
var nuspecFile = id + ".nuspec";
nuspec.CreateDocument().Save(nuspecFile);
Process.Start(
new ProcessStartInfo(
@"..\..\..\packages\NuGet.CommandLine.2.8.3\tools\nuget.exe",
"pack " + nuspecFile)
{
UseShellExecute = false,
}).WaitForExit();
}
示例13: BuildProject
public static void BuildProject()
{
var version = new Version(PlayerSettings.bundleVersion);
var newVersion = new Version(version.Major, version.Minor, version.Build + 1, version.Revision);
PlayerSettings.bundleVersion = newVersion.ToString();
var dir = string.Format("Game{0}{1}{2}{3}" , newVersion.Major, newVersion.Minor, newVersion.Build,newVersion.Revision) ;
if (System.IO.Directory.Exists("bin/pc/" + dir) == false)
System.IO.Directory.CreateDirectory("bin/pc/" + dir);
var scenenames = _ReadNames();
foreach (var scenename in scenenames)
{
Debug.Log(string.Format("scene [{0}]", scenename));
}
var filename = string.Format("bin/pc/{0}/Play.exe" , dir);
BuildPipeline.BuildPlayer(scenenames, filename, BuildTarget.StandaloneWindows64 , BuildOptions.None);
}
示例14: GetPrimitiveTypes
public static System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> GetPrimitiveTypes(this EdmItemCollection itemCollection, Version edmVersion)
{
if (edmVersion == EntityFrameworkVersionsUtil.Version3)
{
return itemCollection.GetPrimitiveTypes(3.0);
}
else if (edmVersion == EntityFrameworkVersionsUtil.Version2)
{
return itemCollection.GetPrimitiveTypes(2.0);
}
else if (edmVersion == EntityFrameworkVersionsUtil.Version1)
{
return itemCollection.GetPrimitiveTypes(1.0);
}
else if (edmVersion == EntityFrameworkVersionsUtil.EdmVersion1_1)
{
return itemCollection.GetPrimitiveTypes(1.1);
}
else
{
string versionString = edmVersion.ToString(2);
return itemCollection.GetPrimitiveTypes(double.Parse(versionString, CultureInfo.InvariantCulture));
}
}
示例15: PosTest3
public bool PosTest3()
{
TestLibrary.TestFramework.BeginScenario("PosTest3: version set in ctor then set as null");
bool retVal = true;
try
{
Version ver = new Version("10.100.1000.10000");
AssemblyName an = new AssemblyName("aa, Version="+ver.ToString());
if (!an.Version.Equals(ver))
{
TestLibrary.TestFramework.LogError("003.1", "expect Version is " + ver.ToString());
retVal = false;
}
an.Version = null;
if (an.Version != null)
{
TestLibrary.TestFramework.LogError("003.2", "expect Version is " + ver.ToString());
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("003.3", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}