public static void RegisterUserTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((NoteEntity uq) => uq.CreatedBy, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <NoteEntity>(typeCondition, uq => uq.CreatedBy.Is(UserEntity.Current)); }
public static void RegisterUserTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((UserQueryEntity uq) => uq.Owner, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <UserQueryEntity>(typeCondition, uq => uq.Owner.RefersTo(UserEntity.Current)); }
public static IQueryable <T> WhereCondition <T>(this IQueryable <T> query, TypeConditionSymbol typeCondition) where T : Entity { Expression <Func <T, bool> > exp = (Expression <Func <T, bool> >)GetCondition(typeof(T), typeCondition); return(query.Where(exp)); }
public static void RegisterRecipientTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((AlertEntity a) => a.Recipient, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <AlertEntity>(typeCondition, a => a.Recipient.Is(UserEntity.Current)); }
public static Func <T, bool>?GetInMemoryCondition <T>(TypeConditionSymbol typeCondition) where T : Entity { var pair = infos.GetOrThrow(typeof(T), "There's no TypeCondition registered for type {0}").GetOrThrow(typeCondition); return((Func <T, bool>?)pair.InMemoryCondition); }
public static void RegisterRoleTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((UserChartEntity uq) => uq.Owner, typeof(RoleEntity)); TypeConditionLogic.RegisterCompile <UserChartEntity>(typeCondition, uq => AuthLogic.CurrentRoles().Contains(uq.Owner) || uq.Owner == null); }
static SqlPreCommand?AuthCache_PreDeleteSqlSync_Condition(Entity arg) { TypeConditionSymbol condition = (TypeConditionSymbol)arg; var command = Administrator.UnsafeDeletePreCommandMList((RuleTypeEntity rt) => rt.Conditions, Database.MListQuery((RuleTypeEntity rt) => rt.Conditions).Where(mle => mle.Element.Condition == condition)); return(command); }
public Expression Expand(Expression?instance, Expression[] arguments, MethodInfo mi) { Expression entity = arguments[0]; TypeConditionSymbol typeCondition = (TypeConditionSymbol)ExpressionEvaluator.Eval(arguments[1]) !; var exp = GetCondition(entity.Type, typeCondition); return(Expression.Invoke(exp, entity)); }
public static void RegisterUserTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((DashboardEntity uq) => uq.Owner, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <DashboardEntity>(typeCondition, uq => uq.Owner.Is(UserEntity.Current)); RegisterPartsTypeCondition(typeCondition); }
public Expression Expand(Expression?instance, Expression[] arguments, MethodInfo mi) { Type type = mi.GetGenericArguments()[0]; Expression query = arguments[0]; TypeConditionSymbol typeCondition = (TypeConditionSymbol)ExpressionEvaluator.Eval(arguments[1]) !; LambdaExpression exp = GetCondition(type, typeCondition); return(Expression.Call(null, miWhere.MakeGenericMethod(type), query, exp)); }
public static void RegisterUserTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { TypeConditionLogic.RegisterCompile <ProcessEntity>(typeCondition, pe => pe.User.RefersTo(UserEntity.Current)); TypeConditionLogic.Register <PackageOperationEntity>(typeCondition, po => Database.Query <ProcessEntity>().WhereCondition(typeCondition).Any(pe => pe.Data == po)); TypeConditionLogic.Register <PackageLineEntity>(typeCondition, pl => ((PackageOperationEntity)pl.Package.Entity).InCondition(typeCondition)); }
public static void RegisterRoleTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((ToolbarEntity t) => t.Owner, typeof(RoleEntity)); TypeConditionLogic.RegisterCompile <ToolbarEntity>(typeCondition, t => AuthLogic.CurrentRoles().Contains(t.Owner)); sb.Schema.Settings.AssertImplementedBy((ToolbarMenuEntity t) => t.Owner, typeof(RoleEntity)); TypeConditionLogic.RegisterCompile <ToolbarMenuEntity>(typeCondition, t => AuthLogic.CurrentRoles().Contains(t.Owner)); }
public static void RegisterUserTypeCondition(SchemaBuilder sb, TypeConditionSymbol typeCondition) { sb.Schema.Settings.AssertImplementedBy((ToolbarEntity t) => t.Owner, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <ToolbarEntity>(typeCondition, t => t.Owner.RefersTo(UserEntity.Current)); sb.Schema.Settings.AssertImplementedBy((ToolbarMenuEntity t) => t.Owner, typeof(UserEntity)); TypeConditionLogic.RegisterCompile <ToolbarMenuEntity>(typeCondition, t => t.Owner.RefersTo(UserEntity.Current)); }
public static LambdaExpression GetCondition(Type type, TypeConditionSymbol typeCondition) { var tempExpr = tempConditions.Value?.TryGetC(type)?.TryGetC(typeCondition); if (tempExpr != null) { return(tempExpr); } var pair = infos.GetOrThrow(type, "There's no TypeCondition registered for type {0}").GetOrThrow(typeCondition); return(pair.Condition); }
public static void RegisterPartsTypeCondition(TypeConditionSymbol typeCondition) { TypeConditionLogic.Register <ValueUserQueryListPartEntity>(typeCondition, cscp => Database.Query <DashboardEntity>().WhereCondition(typeCondition).Any(cp => cp.ContainsContent(cscp))); TypeConditionLogic.Register <LinkListPartEntity>(typeCondition, llp => Database.Query <DashboardEntity>().WhereCondition(typeCondition).Any(cp => cp.ContainsContent(llp))); TypeConditionLogic.Register <UserChartPartEntity>(typeCondition, ucp => Database.Query <DashboardEntity>().WhereCondition(typeCondition).Any(cp => cp.ContainsContent(ucp))); TypeConditionLogic.Register <UserQueryPartEntity>(typeCondition, uqp => Database.Query <DashboardEntity>().WhereCondition(typeCondition).Any(cp => cp.ContainsContent(uqp))); }
public static void Register <T>(TypeConditionSymbol typeCondition, Expression <Func <T, bool> > condition, Func <T, bool>?inMemoryCondition) where T : Entity { if (typeCondition == null) { throw AutoInitAttribute.ArgumentNullException(typeof(TypeConditionSymbol), nameof(typeCondition)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } infos.GetOrCreate(typeof(T))[typeCondition] = new TypeConditionPair(condition, inMemoryCondition); }
public static void Register <T>(TypeConditionSymbol typeCondition, Expression <Func <T, bool> > condition, Func <T, bool>?inMemoryCondition) where T : Entity { if (Schema.Current.IsCompleted) { throw new InvalidOperationException("Schema already completed"); } if (typeCondition == null) { throw AutoInitAttribute.ArgumentNullException(typeof(TypeConditionSymbol), nameof(typeCondition)); } if (condition == null) { throw new ArgumentNullException(nameof(condition)); } infos.GetOrCreate(typeof(T))[typeCondition] = new TypeConditionPair(condition, inMemoryCondition); }
public static IDisposable ReplaceTemporally <T>(TypeConditionSymbol typeAllowed, Expression <Func <T, bool> > condition) where T : Entity { var dic = tempConditions.Value ?? (tempConditions.Value = new Dictionary <Type, Dictionary <TypeConditionSymbol, LambdaExpression> >()); var subDic = dic.GetOrCreate(typeof(T)); subDic.Add(typeAllowed, condition); return(new Disposable(() => { subDic.Remove(typeAllowed); if (subDic.Count == 0) { dic.Remove(typeof(T)); } if (dic.Count == 0) { tempConditions.Value = null; } })); }
internal ConditionDebugData(TypeConditionSymbol typeCondition, bool inGroup, TypeAllowed allowed) { this.TypeCondition = typeCondition; this.InGroup = inGroup; this.Allowed = allowed; }
public TypeConditionRuleBuilder(TypeConditionSymbol typeCondition, TypeAllowed allowed) { this.TypeCondition = typeCondition; this.Allowed = new TypeAllowedBuilder(allowed); }
public TypeAllowedAndConditions WithoutCondition(TypeConditionSymbol typeCondition) { return(new TypeAllowedAndConditions(this.Fallback, this.Conditions.Where(a => !a.TypeCondition.Is(typeCondition)))); }
public TypeConditionRuleEmbedded(TypeConditionSymbol typeCondition, TypeAllowed allowed) { this.TypeCondition = typeCondition; this.Allowed = allowed; }
public static bool InCondition(this Entity entity, TypeConditionSymbol typeCondition) { throw new InvalidProgramException("InCondition is meant to be used in database only"); }
public static void RegisterCompile <T>(TypeConditionSymbol typeCondition, Expression <Func <T, bool> > condition) where T : Entity { Register <T>(typeCondition, condition, condition.Compile()); }
public static bool IsDefined(Type type, TypeConditionSymbol typeCondition) { return(infos.TryGetC(type)?.TryGetC(typeCondition) != null); }