Пример #1
0
 // constructor
 public StatList(IComparer <KeyType> comparer, ICombiner <ValueType> combiner)
 {
     this.keyComparer         = comparer;
     this.rootNode            = null;
     this.valueCombiner       = combiner;
     this.OptimizeForLocality = true;
 }
Пример #2
0
        public void Combine(ICombiner combiner, object other)
        {
            if (other == null)
                return;

            Text = ((CombinableTestClass)other).Text + Text;
        }
Пример #3
0
 public Cipher(
     ITransformer transformer,
     ICombiner combiner)
 {
     this.transformer = transformer;
     this.combiner    = combiner;
 }
Пример #4
0
 public ChildCombiner(ICombiner parent)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     _parent = parent;
 }
Пример #5
0
 public T Combine(ICombiner combiner, T x, T y)
 {
     if (x == null)
     {
         return(y);
     }
     x.Combine(combiner, y);
     return(x);
 }
Пример #6
0
        public void Combine(ICombiner combiner, object other)
        {
            if (other == null)
            {
                return;
            }

            Text = ((CombinableTestClass)other).Text + Text;
        }
Пример #7
0
        public void Combine(ICombiner combiner, ExampleCombineConfig other)
        {
            if (other == null)
            {
                return;
            }

            F = other.F ?? F;
        }
Пример #8
0
        public void Combine(ICombiner combiner, object item)
        {
            var other = item as TestCombinableClass;

            if (other == null)
                return;

            F1 += other.F1;
            F2 += other.F2;
        }
Пример #9
0
        public void Combine(ICombiner combiner, TestGenericCombinableClass other)
        {
            if (other == null)
            {
                return;
            }

            F1 += other.F1;
            F2 += other.F2;
        }
Пример #10
0
        public void Combine(ICombiner combiner, object other)
        {
            if (other == null)
                return;

            var otherText = ((CombinableTestStruct) other).Text;

            if (otherText != null)
                Text = otherText + Text;
        }
Пример #11
0
        public T Combine <T>(ICombiner context, T x, T y)
        {
            object combine;

            if (_funcMap.TryGetValue(typeof(T), out combine))
            {
                return(((ChildCombineDefinition <T>)combine)(new Context(_parent, context), x, y));
            }

            return(_parent.Combine(context, x, y));
        }
Пример #12
0
 internal static T?RecursiveNullableCombine <T>(Predicate <T?> supressValue, ICombiner combiner, T?x, T?y) where T : struct
 {
     if (supressValue(x))
     {
         return(y);
     }
     if (supressValue(y))
     {
         return(x);
     }
     return(combiner.Combine <T>(x.Value, y.Value));
 }
Пример #13
0
        public void Combine(ICombiner combiner, object item)
        {
            var other = item as TestCombinableClass;

            if (other == null)
            {
                return;
            }

            F1 += other.F1;
            F2 += other.F2;
        }
Пример #14
0
        public void Combine(ICombiner combiner, CustomCombinableConfig other)
        {
            if (other == null)
            {
                return;
            }

            if (other.Field1 != null)
            {
                Field1 += other.Field1;
            }
        }
Пример #15
0
        public void Combine(ICombiner combiner, ConnectionConfig other)
        {
            if (other == null)
            {
                return;
            }

            Server     = other.Server ?? Server;
            Database   = other.Database ?? Database;
            User       = other.User ?? User;
            Password   = other.Password ?? Password;
            Additional = other.Additional ?? Additional;
        }
Пример #16
0
        public T[] Combine(ICombiner combiner, T[] x, T[] y)
        {
            if (y == null || y.Length == 0)
            {
                return(x);
            }

            if (x == null || x.Length == 0)
            {
                return(y);
            }

            return(x.Union(y).ToArray());
        }
Пример #17
0
        public ICollection <T> Combine(ICombiner combiner, ICollection <T> x, ICollection <T> y)
        {
            if (y == null || y.Count == 0)
            {
                return(x);
            }

            if (x == null || x.Count == 0)
            {
                return(y);
            }

            return(x.Union(y).ToList());
        }
Пример #18
0
        public void Combine(ICombiner combiner, object other)
        {
            if (other == null)
            {
                return;
            }

            var otherText = ((CombinableTestStruct)other).Text;

            if (otherText != null)
            {
                Text = otherText + Text;
            }
        }
Пример #19
0
        public BayesClassifier(ITokenizer <TTokenType> tokenizer, ICombiner combiner)
        {
            if (tokenizer == null)
            {
                throw new ArgumentNullException("tokenizer");
            }
            if (combiner == null)
            {
                throw new ArgumentNullException("combiner");
            }

            _tokenizer = tokenizer;
            _combiner  = combiner;

            _tags.SystemTag = new TagData <TTokenType>();
            _mustRecache    = true;
        }
Пример #20
0
            public T Combine(ICombiner combiner, T x, T y)
            {
                if (x == null)
                {
                    return(y);
                }
                if (y == null)
                {
                    return(x);
                }

                return(new T()
                {
                    F1 = x.F1 + y.F1,
                    F2 = x.F2 + y.F2
                });
            }
Пример #21
0
            public TestAttrClass Combine(ICombiner combiner, TestAttrClass x, TestAttrClass y)
            {
                if (x == null)
                {
                    return(y);
                }
                if (y == null)
                {
                    return(x);
                }

                return(new TestAttrClass()
                {
                    F1 = x.F1 + y.F1,
                    F2 = x.F2 + y.F2
                });
            }
Пример #22
0
        public IEnumerable <T> Combine(ICombiner combiner, IEnumerable <T> x, IEnumerable <T> y)
        {
            if (x != null)
            {
                foreach (var item in x)
                {
                    yield return(item);
                }
            }

            if (y != null)
            {
                foreach (var item in y)
                {
                    yield return(item);
                }
            }
        }
Пример #23
0
        public void Combine(ICombiner combiner, ImageSourcesConfig other)
        {
            var resultGroups = new List <QualityGroupConfig>();

            var groupsByType      = QualityGroups.ToDictionary(_ => _.Name ?? _.Quality);
            var otherGroupsByType = other.QualityGroups.ToDictionary(_ => _.Name ?? _.Quality);

            foreach ((string name, QualityGroupConfig grp) in otherGroupsByType)
            {
                if (groupsByType.TryGetValue(name, out var group))
                {
                    var combined = combiner.Combine(group, grp);
                    resultGroups.Add(combined);
                }
                else
                {
                    resultGroups.Add(grp);
                }
            }

            QualityGroups = resultGroups.ToArray();
        }
Пример #24
0
        internal static T CollectionCombine <T, I>(ICombiner combiner, T x, T y) where T : IEnumerable <I>
        {
            if (x == null)
            {
                return(y);
            }

            if (y == null)
            {
                return(x);
            }

            if (!x.Any())
            {
                return(y);
            }

            if (!y.Any())
            {
                return(x);
            }

            return(y);
        }
Пример #25
0
        public void Combine(ICombiner combiner, ImageSourcesConfig other)
        {
            var resultGroups = new List <QualityGroupConfig>();

            var groupsByType      = QualityGroups.ToDictionary(_ => _.Quality);
            var otherGroupsByType = other.QualityGroups.ToDictionary(_ => _.Quality);

            foreach (var entry in otherGroupsByType)
            {
                var otherGroup = entry.Value;

                if (groupsByType.TryGetValue(entry.Key, out var group))
                {
                    var combined = combiner.Combine(group, otherGroup);
                    resultGroups.Add(combined);
                }
                else
                {
                    resultGroups.Add(otherGroup);
                }
            }

            QualityGroups = resultGroups.ToArray();
        }
Пример #26
0
 public T Combine(ICombiner combiner, T x, T y)
 {
     x.Combine(combiner, y);
     return(x);
 }
Пример #27
0
 public T Combine <T>(ICombiner current, T x, T y)
 {
     return(Parent.Combine(current, x, y));
 }
Пример #28
0
 /// <summary>
 /// Set custom combiner
 /// </summary>
 /// <typeparam name="T">required type</typeparam>
 /// <param name="combiner">combiner</param>
 public ChildCombiner SetCombiner <T>(ICombiner <T> combiner)
 {
     return(SetCombiner <T>((ctx, prev, next) => combiner.Combine(ctx.Current, prev, next)));
 }
Пример #29
0
 internal Context(ICombiner parent, ICombiner current)
 {
     Parent  = parent;
     Current = current;
 }
Пример #30
0
 public static T Combine <T>(this ICombiner combiner, T x, T y)
 {
     return(combiner.Combine <T>(combiner, x, y));
 }
Пример #31
0
 public string Combine(ICombiner combiner, string x, string y)
 {
     return((x ?? "null") + "," + (y ?? "null"));
 }
Пример #32
0
 /// <summary>
 /// Returns a brand new <see cref="Combiner"/> instance including the given
 /// <see cref="Combiner.AllValues"/> and the strongly typed <paramref name="values"/>.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="combiner">Should provide an instance of <see cref="Combiner"/>
 /// seen through the interface by the same name.</param>
 /// <param name="values"></param>
 /// <returns>A brand new Combiner instance with the Combined Arrays.</returns>
 public static Combiner Append <T>(this ICombiner combiner, IEnumerable <T> values)
 => AppendValues(combiner as Combiner, values.OfType <object>().ToArray());
Пример #33
0
 /// <summary>
 /// Returns a brand new <see cref="Combiner"/> instance including the given
 /// <see cref="Combiner.AllValues"/> and weakly typed <paramref name="values"/> and
 /// <paramref name="others"/>.
 /// </summary>
 /// <param name="combiner">Should provide an instance of <see cref="Combiner"/>
 /// seen through the interface by the same name.</param>
 /// <param name="values"></param>
 /// <param name="others"></param>
 /// <returns></returns>
 public static Combiner Append(this ICombiner combiner, IEnumerable <object> values, params IEnumerable <object>[] others)
 => AppendValues(combiner as Combiner, new[] { values.ToArray() }.Concat(others).ToArray());