public void ParsePropertiesFile_RealFile_Parsed()
        {
            var resource = new EmbeddedResourceReader().GetResource("PropertiesFile.txt");

            // Arrange
            var mockFileSystem = new MockFileSystem();
            var propertiesFile = @"C:\BuildAgent\temp\buildTmp\teamcity.build322130465402584030.properties";

            mockFileSystem.AddFile(propertiesFile, resource);

            var propertiesFileParser = new PropertiesFileParser(mockFileSystem);

            // Act
            var dictionary = propertiesFileParser.ParsePropertiesFile(propertiesFile);

            // Assert
            dictionary["agent.home.dir"].Should().Be(@"C:\BuildAgent");
            dictionary["agent.name"].Should().Be(@"BUILDS8");
            dictionary["agent.ownPort"].Should().Be(@"9090");
            dictionary["agent.work.dir"].Should().Be(@"C:\BuildAgent\work");
            dictionary["build.number"].Should().Be(@"4");
            dictionary["FxCopRoot"].Should()
            .Be(@"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop");
            dictionary["teamcity.agent.dotnet.agent_url"].Should().Be(@"http://*****:*****@"TeamCityBuildId=781682");
        }
    private void CheckForNewVersion(string remoteVersionFileContent)
    {
        Dictionary <string, string> remoteVersionProperties = PropertiesFileParser.ParseText(remoteVersionFileContent);
        Dictionary <string, string> localVersionProperties  = PropertiesFileParser.ParseText(localVersionTextAsset.text);

        remoteVersionProperties.TryGetValue("release", out string remoteRelease);
        if (settings.IgnoredReleases.Contains("all") ||
            settings.IgnoredReleases.Contains(remoteRelease))
        {
            // The user did opt-out for notifications about this release or new releases in general.
            Debug.Log("Ignoring new release: " + remoteRelease);
            return;
        }

        localVersionProperties.TryGetValue("release", out string localRelease);

        try
        {
            if (CompareVersionString(localRelease, remoteRelease) < 0)
            {
                // (localRelease is smaller)
                // or ((localRelease is equal to remoteRelease) and (localBuildTimeStamp is smaller))
                CreateNewVersionAvailableDialog(remoteVersionProperties);
            }
            else
            {
                Debug.Log($"No new release available (localRelease: {localRelease}, remoteRelease: {remoteRelease})");
            }
        }
        catch (CompareVersionException ex)
        {
            Debug.LogException(ex);
        }
    }
示例#3
0
    private void UpdateVersionInfoText()
    {
        Dictionary <string, string> versionProperties = PropertiesFileParser.ParseText(versionPropertiesTextAsset.text);

        // Show the release number (e.g. release date, or some version number)
        versionProperties.TryGetValue("release", out string release);
        versionProperties.TryGetValue("name", out string releaseName);
        string displayName = releaseName.IsNullOrEmpty() ? release : releaseName;

        semanticVersionText.text = "Version: " + displayName;

        // Show the commit hash of the build
        versionProperties.TryGetValue("commit_hash", out string commitHash);
        commitHashText.text = "Commit: " + commitHash;

        // Show the build timestamp only for development builds
        if (Debug.isDebugBuild)
        {
            versionProperties.TryGetValue("build_timestamp", out string buildTimeStamp);
            buildTimeStampText.text = "Build timestamp: " + buildTimeStamp;
        }
        else
        {
            buildTimeStampText.text = "";
        }
    }
示例#4
0
        public void TestParse(string propertyLine, string expectedKey, string expectedValue)
        {
            var result = PropertiesFileParser.ParseLine(propertyLine);

            Assert.AreEqual(expectedKey, result.Item1);
            Assert.AreEqual(expectedValue, result.Item2);
        }
示例#5
0
    private void CheckForNewVersion()
    {
        Dictionary <string, string> remoteVersionProperties = PropertiesFileParser.ParseText(remoteVersionFileContent);
        Dictionary <string, string> localVersionProperties  = PropertiesFileParser.ParseText(localVersionTextAsset.text);

        remoteVersionProperties.TryGetValue("release", out string remoteRelease);
        if (settings.IgnoredReleases.Contains("all") ||
            settings.IgnoredReleases.Contains(remoteRelease))
        {
            // The user did opt-out for notifications about this release or new releases in general.
            Debug.Log("Ignoring new release: " + remoteRelease);
            return;
        }

        localVersionProperties.TryGetValue("release", out string localRelease);

        remoteVersionProperties.TryGetValue("build_timestamp", out string remoteBuildTimeStamp);
        localVersionProperties.TryGetValue("build_timestamp", out string localBuildTimeStamp);

        // Remove all non-digit characters, then compare the resulting numbers
        // This makes it possible to compare version names
        // in multiple formats such as 2020-04-05, 2020-04-05-devbuild, 0.1.5, 2017.04+
        int.TryParse(Regex.Replace(remoteRelease, @"[^\d]", ""), out int remoteReleaseNumber);
        int.TryParse(Regex.Replace(localRelease, @"[^\d]", ""), out int localReleaseNumber);

        int.TryParse(Regex.Replace(remoteBuildTimeStamp, @"[^\d]", ""), out int remoteBuildTimeStampNumber);
        int.TryParse(Regex.Replace(localBuildTimeStamp, @"[^\d]", ""), out int localBuildTimeStampNumber);

        if (localReleaseNumber < remoteReleaseNumber ||
            (localReleaseNumber == remoteReleaseNumber &&
             localBuildTimeStampNumber < remoteBuildTimeStampNumber))
        {
            ShowNewVersionAvailableDialog(remoteVersionProperties);
        }
    }
示例#6
0
文件: Theme.cs 项目: xxxDSSxxx/Play
 private void LoadColorsFromText(string text)
 {
     loadedColorRawStringValues = PropertiesFileParser.ParseText(text);
     loadedColorRawStringValues.ForEach(entry =>
     {
         // Replace reference to other color
         string colorHexValue = ReplaceColorReferences(entry.Value);
         Color32 loadedColor  = Colors.CreateColor(colorHexValue);
         loadedColors.Add(entry.Key, loadedColor);
     });
 }
        public void ParsePropertiesFile_File_Parsed()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var propertiesFile = @"C:\BuildAgent\temp\buildTmp\teamcity.build322130465402584030.properties";

            mockFileSystem.AddFile(propertiesFile, @"#TeamCity build properties without 'system.' prefix
#Sun Nov 01 14:40:00 IST 2015
agent.home.dir=C\:\\BuildAgent
");

            var fileParser = new PropertiesFileParser(mockFileSystem);

            // Act
            var dictionary = fileParser.ParsePropertiesFile(propertiesFile);

            // Assert
            dictionary["agent.home.dir"].Should().Be(@"C:\BuildAgent");
        }
示例#8
0
    void Start()
    {
        Dictionary <string, string> versionProperties = PropertiesFileParser.ParseText(versionPropertiesTextAsset.text);

        // Show the release number (e.g. release date, or some version number)
        versionProperties.TryGetValue("release", out string release);
        releaseUiText.text = "Release: " + release;

        // Show the build timestamp only for development builds
        if (Debug.isDebugBuild)
        {
            versionProperties.TryGetValue("build_timestamp", out string buildTimeStamp);
            buildTimeStampUiText.text = "Build: " + buildTimeStamp;
        }
        else
        {
            buildTimeStampUiText.gameObject.SetActive(false);
        }
    }
示例#9
0
    private void LoadProperties()
    {
        // Load the default properties file
        string path = GetPropertiesFilePath(PropertiesFileName);

        fallbackMessages = PropertiesFileParser.ParseFile(path);

        // Load the properties file of the current language
        string propertiesFileNameWithCountryCode = PropertiesFileName + GetCountryCodeSuffixForPropertiesFile(language);

        path = GetPropertiesFilePath(propertiesFileNameWithCountryCode);
        if (File.Exists(path))
        {
            currentLanguageMessages = PropertiesFileParser.ParseFile(path);
        }
        else
        {
            Debug.LogError("File not found: " + path);
        }
    }
示例#10
0
        public static PropertiesDocument Parse(string input)
        {
            var tokenizer      = new PropertiesFileTokenizer();
            var tokenizeResult = tokenizer.TryTokenize(input);

            if (!tokenizeResult.HasValue)
            {
                // TODO: error handling
                throw new NotImplementedException();
            }

            var parseResult = PropertiesFileParser.Parse(tokenizeResult.Value);

            if (!parseResult.HasValue)
            {
                // TODO: error handling
                throw new NotImplementedException();
            }

            return(parseResult.Value);
        }
    private void UpdateVersionInfoText()
    {
        Dictionary <string, string> versionProperties = PropertiesFileParser.ParseText(versionPropertiesTextAsset.text);

        // Show the release number (e.g. release date, or some version number)
        versionProperties.TryGetValue("release", out string release);
        semanticVersionText.text = TranslationManager.GetTranslation(R.Messages.version, "value", release);

        // Show the commit hash of the build
        versionProperties.TryGetValue("commit_hash", out string commitHash);
        commitHashText.text = TranslationManager.GetTranslation(R.Messages.commit, "value", commitHash);

        // Show the build timestamp only for development builds
        if (Debug.isDebugBuild)
        {
            versionProperties.TryGetValue("build_timestamp", out string buildTimeStamp);
            buildTimeStampText.text = TranslationManager.GetTranslation(R.Messages.buildTimeStamp, "value", buildTimeStamp);
        }
        else
        {
            buildTimeStampText.text = "";
        }
    }
示例#12
0
 private static void LoadPropertiesFromText(string text, Dictionary <string, string> targetDictionary)
 {
     targetDictionary.Clear();
     PropertiesFileParser.ParseText(text).ForEach(entry => targetDictionary.Add(entry.Key, entry.Value));
 }