private IDictionary <string, string> CompareDic(AssemblyInfoFileDictionary d1, AssemblyInfoFileDictionary d2)
        {
            var d = new Dictionary <string, string>();

            // existing
            foreach (var pair in d1)
            {
                var d2pair = d2.FirstOrDefault(x => x.Key == pair.Key);
                if (d2pair.Value != null && pair.Value != d2pair.Value)
                {
                    // compare
                    d.Add($"{pair.Key}==>{pair.Value}", $"{d2pair.Key}==>{d2pair.Value}");
                }
            }

            // new
            var d1Keys = d1.Select(z => z.Key).ToArray();
            var d2New  = d2.Where(x => !d1Keys.Contains(x.Key));

            foreach (var newD2Pair in d2New)
            {
                var key = newD2Pair.Key;
                d.Add("", $"{key}==>{newD2Pair.Value}");
            }

            return(d);
        }
        // Get update result but dont actually update files
        public UpdateFileResult GetUpdateResult(string file, IDictionary <string, string> updateItems)
        {
            var asmInfoDic = new AssemblyInfoFileDictionary(file);
            var newDic     = UpdateItems(asmInfoDic, updateItems);
            var cmp        = CompareDic(asmInfoDic, newDic);

            return(new UpdateFileResult()
            {
                File = file,
                UpdatedFromTo = cmp,
                AssemblyInfoDictionary = newDic
            });
        }
        private AssemblyInfoFileDictionary UpdateItems(AssemblyInfoFileDictionary dic, IDictionary <string, string> updateItems)
        {
            var          dic2     = (AssemblyInfoFileDictionary)dic.Clone();
            const string regexTpl = @"{{([^}]*)}}";

            string getReplaceValue(string value)
            {
                value.Replace("{{Date}}", DateTime.Now.ToString());
                var matches = Regex.Matches(value, regexTpl);

                foreach (var m in matches)
                {
                    //m.Dump();
                }

                return(value);
            }

            foreach (var di in updateItems)
            {
                dic2[di.Key] = getReplaceValue(di.Value);
            }
            return(dic2);
        }
        public object Clone()
        {
            var d = new AssemblyInfoFileDictionary(dic, "unknown");

            return(d);
        }