Example #1
0
        public IFreeDocument MappingDocument(IFreeDocument doc)
        {
            if (doc == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(MappingSet))
            {
                return(doc);
            }
            var newdoc = new FreeDocument();

            doc.DictCopyTo(newdoc);
            foreach (var item  in MappingSet.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var kv = item.Split(':');
                if (kv.Length != 2)
                {
                    continue;
                }
                if (kv[0] == kv[1])
                {
                    continue;
                }
                if (newdoc.Keys.Contains(kv[0]))
                {
                    newdoc[kv[1]] = newdoc[kv[0]];
                    newdoc.Remove(kv[0]);
                }
            }
            return(newdoc);
        }