Ejemplo n.º 1
0
        public static bool DictionaryEquals(IDictionary dictionary1, IDictionary dictionary2)
        {
            if (dictionary1 == null && dictionary2 == null)
            {
                return(true);
            }
            if (dictionary1 == null)
            {
                return(false);
            }
            if (dictionary2 == null)
            {
                return(false);
            }
            if (dictionary1.Count != dictionary2.Count)
            {
                return(false);
            }

            using (var temp1 = ListPool <DictionaryEntry> .Borrow())
            {
                var list1 = temp1.Item;
                foreach (DictionaryEntry p in dictionary1)
                {
                    list1.Add(p);
                }

                using (var temp2 = ListPool <DictionaryEntry> .Borrow())
                {
                    var list2 = temp2.Item;
                    foreach (DictionaryEntry p in dictionary2)
                    {
                        list2.Add(p);
                    }

                    for (var i = 0; i < list1.Count; i++)
                    {
                        var p1 = list1[i];
                        var p2 = list2[i];
                        if (!EqualsHelper.ObjectEquals(p1.Key, p2.Key))
                        {
                            return(false);
                        }
                        if (!EqualsHelper.ObjectEquals(p1.Value, p2.Value))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
 public static int GetCode(IEnumerable <TObject> objs)
 {
     if (objs == null)
     {
         return(0);
     }
     using (var temp = ListPool <int> .Borrow())
     {
         var list = temp.Item;
         foreach (var obj in objs)
         {
             list.Add(GetCode(obj));
         }
         return(Combine(list));
     }
 }
Ejemplo n.º 3
0
 public void Lock(IEnumerable <IAggregateRoot> roots)
 {
     roots = GetSecuritySequence(roots); //获得安全序列
     using (var temp = ListPool <Type> .Borrow())
     {
         var types = temp.Item;
         using (var temp2 = ListPool <object> .Borrow())
         {
             var ids = temp2.Item;
             foreach (var root in roots)
             {
                 types.Add(((DomainObject)root).ObjectType);
                 ids.Add(root.GetIdentity());
             }
             ExecuteLockSql(types, ids);
         }
     }
 }
        private static decimal[] TokensToDecimalArray(IReadOnlyList <IToken> tokens, bool exceptLast = false)
        {
            var result = DecimalListPool.Borrow();

            for (var i = 0; i < tokens.Count - (exceptLast ? 1 : 0); i++)
            {
                var operand = tokens[i];

                if (operand is ArrayToken arr)
                {
                    for (var j = 0; j < arr.Length; j++)
                    {
                        var innerOperand = arr[j];

                        if (!(innerOperand is NumericToken innerNumeric))
                        {
                            var val = result.ToArray();
                            DecimalListPool.Return(result);
                            return(val.ToArray());
                        }

                        result.Add(innerNumeric.Data);
                    }
                }

                if (!(operand is NumericToken numeric))
                {
                    var val = result.ToArray();
                    DecimalListPool.Return(result);
                    return(val.ToArray());
                }

                result.Add(numeric.Data);
            }

            var returnValue = result.ToArray();

            DecimalListPool.Return(result);
            return(returnValue);
        }