private void checkState() { if (_detectChanges) { _detectChanges = false; base.ChangeState(Childs.Any(c => c.IsEnabled)); _detectChanges = true; } }
private void CalculateBalance() { IsBalanced = true; TotalWeight = Weight; if (Childs.Any()) { foreach (var c in Childs) { c.CalculateBalance(); } // Disc is balanced if all childs have exactly the same weight, ie 1/nth of their total weight var w = Childs.Select(c => c.TotalWeight).Sum(); TotalWeight += w; IsBalanced = w % Childs.Length == 0 && Childs.All(c => c.TotalWeight == w / Childs.Length); } }
/// <summary> /// Меняет поле в сущностях для обновления. /// </summary> /// <typeparam name="TUpdate">Тип сущности для обновления</typeparam> /// <param name="toReplace">Сущности для замены, значения { oldEntity, newEntity }</param> /// <returns>Обновленные сущности</returns> protected IEnumerable <TUpdate> UpdateInChild <TUpdate>(ISession session, Dictionary <T, T> toReplace) where TUpdate : IEntity { Contract.Requires(Childs.Any()); var selector = GetGetter <TUpdate>(); var setter = GetSetter <TUpdate>(); var olds = toReplace.Keys; var oldIds = olds.Cast <EntityBase <Guid> >().Select(x => x.Id); // http://stackoverflow.com/a/1069820/3009578 // from TUpdate e // where e in olds ParameterExpression p = selector.Parameters.Single(); IEnumerable <Expression> equals = olds.Select(value => (Expression)Expression.Equal(selector.Body, Expression.Constant(value, typeof(T)))); Expression body = equals.Aggregate((accumulate, equal) => Expression.OrElse(accumulate, equal)); var l = Expression.Lambda <Func <TUpdate, bool> >(body, p); var toUpdate = session .Query <TUpdate>() .Where(l) .ToList(); var compiled = selector.Compile(); toUpdate.ForEach(x => setter(x, toReplace[compiled(x)])); return(toUpdate); }
public IEnumerable <string> GetSelect() { return(SelectMembers.Where(x => !Childs.Any(y => y.MemberPath == x.MemberPath) && !x.IsComplexType).Select(x => x.MemberPath)); }
internal bool ContainsMember(string member) { return DirectTrackedTimeRows.Any(x => x.TeamMember == member) || Childs.Any(x => x.ContainsMember(member)); }