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


C# Version.ToString方法代码示例

本文整理汇总了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);
    }
开发者ID:mchudinov,项目名称:PackagingMSI,代码行数:53,代码来源:Script.cs

示例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;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:PSNegotiationData.cs

示例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;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:25,代码来源:versiontostring2.cs

示例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;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:44,代码来源:versiontostring2.cs

示例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;
     }
   }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:56,代码来源:co7042tostring.cs

示例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;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:41,代码来源:versiontostring1.cs

示例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;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:22,代码来源:assemblynameversion.cs

示例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;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:38,代码来源:versiongethashcode.cs

示例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;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:23,代码来源:assemblynameversion.cs

示例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);
 }
开发者ID:kidroca,项目名称:high-quality-code-2015-homeworks,代码行数:16,代码来源:HR.cs

示例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;
 }
开发者ID:qinhongwei,项目名称:flickr-downloadr-gtk,代码行数:19,代码来源:UpdateCheckLogic.cs

示例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();
 }
开发者ID:AndreGleichner,项目名称:getboost,代码行数:43,代码来源:Nuspec.cs

示例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);
    }
开发者ID:jiowchern,项目名称:ItIsNotAGame-FrontEnd,代码行数:20,代码来源:Builder.cs

示例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));
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:24,代码来源:MetadataExtensionMethods.cs

示例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;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:29,代码来源:assemblynameversion.cs


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