コード例 #1
0
        public bool IsEqual(object first, object second)
        {
            Type type = first.GetType();

            foreach (System.Reflection.PropertyInfo property in type.GetProperties())
            {
                object Object1Value = null;
                object Object2Value = null;

                if (type.GetProperty(property.Name).GetValue(first, null) != null)
                {
                    Object1Value = type.GetProperty(property.Name).GetValue(first, null);
                }

                if (type.GetProperty(property.Name).GetValue(second, null) != null)
                {
                    Object2Value = type.GetProperty(property.Name).GetValue(second, null);
                }

                ICompare compare = FactoryResolver.ResolveComparer(Object1Value);

                if (!compare.IsEqual(Object1Value, Object2Value))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
        public bool IsEqual(object first, object second)
        {
            var lstFirst  = ((IEnumerable)first).Cast <object>().ToList();
            var lstSecond = ((IEnumerable)second).Cast <object>().ToList();

            if (lstFirst.Count != lstSecond.Count)
            {
                return(false);
            }

            for (int iter = 0; iter < lstFirst.Count; iter++)
            {
                ICompare compare = FactoryResolver.ResolveComparer(lstFirst[iter]);

                if (!compare.IsEqual(lstFirst[iter], lstSecond[iter]))
                {
                    return(false);
                }
            }

            //if(!lstFirst.OrderBy(x => x).SequenceEqual(lstSecond))
            //    return false;

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Starts the transaction.
        /// </summary>
        /// <returns>New transaction.</returns>
        public static ITransaction StartTransaction(ITransactionContext innerContext = null)
        {
            var transaction = FactoryResolver.GetTransaction();

            if (innerContext != null)
            {
                transaction.InitTransactionContext(innerContext);
            }
            return(transaction);
        }
コード例 #4
0
        /// <summary>
        /// Starts the unit of work.
        /// </summary>
        /// <returns>New unit of work.</returns>
        public static IUnitOfWork StartUnitOfWork(IUnitOfWorkContext innerContext = null)
        {
            var unitOfWork = FactoryResolver.GetUnitOfWork();

            if (innerContext != null)
            {
                unitOfWork.InitUnitOfWorkContext(innerContext);
            }
            return(unitOfWork);
        }
コード例 #5
0
        /// <summary>
        /// Gets the action (initialize on action is called).
        /// </summary>
        /// <typeparam name="T">Type of action</typeparam>
        /// <returns></returns>
        public static T Action <T>() where T : class, IAction
        {
            var action = FactoryResolver.ResolveAction <T>();

            // initialize if not yet done
            if (!action.Initialized)
            {
                action.Initialize();
            }
            return(action);
        }
コード例 #6
0
        public static bool AreSimilar <T>(T first, T second)
        {
            if (first == null || second == null)
            {
                return(true);
            }

            ICompare compare = FactoryResolver.ResolveComparer(first);

            return(compare.IsEqual(first, second));
        }
コード例 #7
0
 /// <summary>
 /// Gets the BaseRepository.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns>Registered BaseRepository.</returns>
 public static IRepository <T> GetRepository <T>() where T : class
 {
     try
     {
         var repository = FactoryResolver.GetRepository <T>();
         if (repository == null)
         {
             throw new RepositoryNotRegisteredException(typeof(T), null);
         }
         return(repository);
     }
     catch (Exception innerException)
     {
         throw new RepositoryNotRegisteredException(typeof(T), innerException);
     }
 }