示例#1
0
        internal TRules GetMergerRulesForWithDefault <TRules>(Type type, IAlgorithmRules ignore)
            where TRules : class, IAlgorithmRules
        {
            TRules ret = this.GetMergerRulesFor <TRules>(type, ignore);

            if (ret != null)
            {
                return(ret);
            }

            if (this.aRulesNotFoundFallback != null)
            {
                ret = RulesNotFoundFallbackMembers.RulesNotFoundFallback(typeof(TRules), type)
                      .Invoke(this.aRulesNotFoundFallback, new object[] { new MergerRulesLocator(this) }) as TRules;
            }

            if (ret == null)
            {
                ret = this.GuessRules <TRules>(type);
            }

            ret?.Initialize(this);

            return(ret);
        }
示例#2
0
        internal TRules GetMergerRulesFor <TRules>(Type type, IAlgorithmRules ignore)
            where TRules : class, IAlgorithmRules
        {
            foreach (IClassMergerDefinition definition in this.GetDefinitionFor(type))
            {
                TRules rules = definition.GetRules <TRules>(ignore);

                if (rules != null)
                {
                    return(rules);
                }
            }

            for (Type tmp = type.BaseType; tmp != null; tmp = tmp.BaseType)
            {
                foreach (IClassMergerDefinition definition in this.GetDefinitionFor(tmp))
                {
                    foreach (TRules rules in definition.GetAllRules <TRules>())
                    {
                        if (rules is IInheritableAlgorithmRules inheritable)
                        {
                            if (inheritable.IsInheritable)
                            {
                                return(rules);
                            }
                        }
                    }
                }
            }

            return(null);
        }
        private IAlgorithmRules GetAncestor <TRules>(Type type)
            where TRules : class, IAlgorithmRules <TClass>
        {
            Type tmp = type;

            while (tmp.BaseType != null)
            {
                tmp = tmp.BaseType;

                foreach (IClassMergerDefinition def in this.aDefinitions)
                {
                    if (def.DefinedFor == tmp)
                    {
                        IAlgorithmRules rules = def.GetRules(typeof(TRules));
                        if (rules is IInheritableAlgorithmRules inheritable)
                        {
                            if (inheritable.IsInheritable)
                            {
                                return(rules);
                            }
                        }
                    }
                }
            }

            return(null);
        }
示例#4
0
 public ApplyValuePatch(MergerImplementation mergerImplementation, IAlgorithmRules rules)
 {
     this.aMergerImplementation = mergerImplementation;
     this.aRules = rules;
     this.aTypes = new Dictionary <Type, IApplyPatchAlgorithm>();
 }
 TRules IClassMergerDefinition.GetRules <TRules>(IAlgorithmRules ignore)
 {
     return(this.aRules.OfType <TRules>().FirstOrDefault(x => x != ignore));
 }
示例#6
0
 public MergeValueDiffs(MergerImplementation mergerImplementation, IAlgorithmRules rules)
 {
     this.aMergerImplementation = mergerImplementation;
     this.aRules = rules;
 }