예제 #1
0
        public static Dictionary <string, List <string> > GetMacroDictAndRemove(string input, out string output)
        {
            MatchCollection mc = Regex.Matches(input, macroReg);

            output = Regex.Replace(input, macroReg, "");
            Dictionary <string, List <string> > dl = new Dictionary <string, List <string> >();

            foreach (Match m in mc)
            {
                string key   = m.Groups[1].Value;
                string value = m.Groups[2].Value;
                try
                {
                    DictionaryFunctions.GetValueOrThrowException("", dl, m.Groups[1].Value);
                    dl[key].Add(value);
                }
                catch
                {
                    dl.Add(key, new List <string>()
                    {
                        value
                    });
                }
            }

            return(dl);
        }
예제 #2
0
        protected override void FillContent(Dictionary <string, string> source, ref CompInfoTemp output)
        {
            string v;
            string name = output.rname;

            if (output.contents.Count == 0)
            {
                output.contents.Add(source);
            }
            output.contents = (from dict in output.contents
                               let t = dict.TryGetValue(KeyWordDef.AN, out v) ? v :
                                       DictionaryFunctions.GetValueOrThrowException(name, source, KeyWordDef.AN)
                                       from n in t.Split(',').Select(i => int.Parse(i))
                                       let ndict = new Dictionary <string, string>(dict)
                                                   group ndict by n into gdict orderby gdict.Key
                                                   let rdict = AggregateDicts(gdict).Concat(source)
                                                               .GroupBy(d => d.Key)
                                                               .ToDictionary(d => d.Key, d => d.First().Value)
                                                               select rdict).ToList();
            output.content = output.contents[0];
        }