Пример #1
0
        /// <summary>
        /// Try replacing existing version with incoming version
        /// </summary>
        private void InsertVersion(string typePath, Func <string, string, int, T> candidateFunc, int major, BuildVersion minorVersion)
        {
            var versionName = major + "_" + minorVersion.ToUnderscoreString();

            // TODO: close and dispose any old or rejected candidates
            var candidate = candidateFunc(typePath, versionName, major);

            lock (VersionLock)
            {
                if (versionTable.ContainsKey(major))
                {
                    var kvp = versionTable[major];
                    if (kvp.Key == minorVersion)
                    {
                        return;
                    }
                    if (kvp.Key < minorVersion)
                    {
                        // found a newer minor version
                        if (kvp.Value is IDisposable old)
                        {
                            old.Dispose();
                        }
                        versionTable[major] = new KeyValuePair <BuildVersion, T>(minorVersion, candidate);
                    }
                }
                else
                {
                    // first copy of this major version
                    versionTable.Add(major, new KeyValuePair <BuildVersion, T>(minorVersion, candidate));
                }
                _versionNames      = versionTable.Select(kvp => kvp.Key + "-" + kvp.Value.Key).ToList();
                _versionsAvailable = string.Join(", ", VersionNames());
            }
        }
Пример #2
0
 public static bool TryParse(string str, out BuildVersion vers)
 {
     vers = new BuildVersion();
     return(TryFill(str, vers));
 }