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); }
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); }
/// <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); }
/// <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); }
/// <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); }
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)); }
/// <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); } }