Beispiel #1
0
        public static ResolvedReplacer GetReplacer(IFieldReplacer replacer)
        {
            if (replacers.TryGetValue(replacer, out var resolved))
            {
                return(resolved);
            }
            var newreplacer = ResolvedReplacer.Resolve(replacer);

            replacers.Add(replacer, newreplacer);
            return(newreplacer);
        }
Beispiel #2
0
        public static ResolvedReplacer Resolve(IFieldReplacer replacer)
        {
            ResolvedReplacer rep = new ResolvedReplacer();

            rep.InstanceInfo = ResolvedInstance.Resolve(replacer.InstanceInfo);
            if (replacer.FieldReplacements == null)
            {
                throw new Exception("No replacements found!");
            }
            foreach (var v in replacer.FieldReplacements)
            {
                if (!v.TryResolveTarget(out var field1) || !v.TryResolveSource(out var field2))
                {
                    throw new Exception($"Unable to resolve field!");
                }
                rep.FieldToField.Add(field1, field2);
            }

            return(rep);
        }