private void btnExploreNotes_Click(object sender, RoutedEventArgs e) { var func = CustomFilter.TryGetValue(DataContext.GetType()); var eo = new ExploreOptions(typeof(NoteEntity)) { ShowFilters = false, SearchOnLoad = true, FilterOptions = { func != null ? func((Entity)DataContext) : new FilterOption("Target", DataContext) { Frozen = true }, }, OrderOptions = { new OrderOption("CreationDate", OrderType.Ascending) }, Closed = (_, __) => Dispatcher.Invoke(() => ReloadNotes()) }; if (func == null) { eo.ColumnOptions = new List <ColumnOption> { new ColumnOption("Target") }; eo.ColumnOptionsMode = ColumnOptionsMode.Remove; } Finder.Explore(eo); }
public static IOperation FindOperation(Type type, OperationSymbol operationSymbol) { IOperation result = operations.TryGetValue(type)?.TryGetC(operationSymbol); if (result == null) { throw new InvalidOperationException("Operation '{0}' not found for type {1}".FormatWith(operationSymbol, type)); } return(result); }
public static void TaskSetLabelText(FrameworkElement fe, string route, PropertyRoute context) { DependencyProperty labelText = LabelPropertySelector.TryGetValue(fe.GetType()); if (labelText != null && fe.NotSet(labelText)) { fe.SetValue(labelText, context.PropertyInfo.NiceName()); } }
public static void TaskSetTypeProperty(FrameworkElement fe, string route, PropertyRoute context) { DependencyProperty typeProperty = TypePropertySelector.TryGetValue(fe.GetType()); if (typeProperty != null && fe.NotSet(typeProperty)) { fe.SetValue(typeProperty, context.Type); } }
internal Expression BuildExtension(Type parentType, string key, Expression parentExpression) { var extensionInfo = CompatibleTypes(parentType) .Select(t => RegisteredExtensions.TryGetValue(t)?.TryGetC(key)) .NotNull() .FirstEx(() => $"No Extension found for '{parentType.TypeName()}' and key '{key}'"); var lambda = extensionInfo.Lambda; var targetType = lambda.Parameters[0].Type; var pe = targetType.IsAssignableFrom(parentExpression.Type) ? parentExpression : targetType.IsAssignableFrom(parentExpression.Type.CleanType()) ? parentExpression.ExtractEntity(false) : targetType.IsAssignableFrom(parentExpression.Type.BuildLite()) ? parentExpression.BuildLite() : targetType == parentExpression.Type.Nullify() ? parentExpression.Nullify() : targetType == parentExpression.Type.UnNullify() ? parentExpression.UnNullify() : parentExpression; return(ExpressionReplacer.Replace(Expression.Invoke(extensionInfo.Lambda, pe))); }
void CountAlerts(Entity entity) { var func = CustomFilter.TryGetValue(DataContext.GetType()); DynamicQueryServer.QueryGroupBatch(new QueryGroupOptions(typeof(AlertEntity)) { FilterOptions = new List <FilterOption> { func != null ? func((Entity)DataContext) : new FilterOption("Target", DataContext) { Frozen = true }, }, ColumnOptions = new List <ColumnOption> { new ColumnOption("Entity.CurrentState"), new ColumnOption("Count") }, OrderOptions = new List <OrderOption> { new OrderOption("Entity.CurrentState"), } }, resultTable => { if (resultTable.Rows.Length == 0) { icAlerts.Visibility = Visibility.Collapsed; } else { icAlerts.Visibility = Visibility.Visible; icAlerts.ItemsSource = resultTable.Rows; tbAlerts.FontWeight = FontWeights.Bold; ForceShow?.Invoke(); } }, () => { }); }
public IEnumerable <QueryToken> GetExtensions(QueryToken parent) { var parentType = parent.Type.CleanType().UnNullify(); var dic = RegisteredExtensions.TryGetValue(parentType); if (dic == null) { return(Enumerable.Empty <QueryToken>()); } return(dic.Values.Where(a => a.Inherit || a.SourceType == parentType).Select(v => v.CreateToken(parent))); }
public OS GetSettings <OS>(Type type, OperationSymbol operation) where OS : OperationSettings { OperationSettings settings = Settings.TryGetValue(type)?.TryGetC(operation); if (settings != null) { var result = settings as OS; if (result == null) { throw new InvalidOperationException("{0}({1}) should be a {2}".FormatWith(settings.GetType().TypeName(), operation.Key, typeof(OS).TypeName())); } return(result); } return(null); }
public IEnumerable <QueryToken> GetExtensions(QueryToken parent) { var parentType = parent.Type.CleanType().UnNullify(); var dic = RegisteredExtensions.TryGetValue(parentType); IEnumerable <QueryToken> extensionsTokens = dic == null?Enumerable.Empty <QueryToken>() : dic.Values.Where(ei => ei.Inherit || ei.SourceType == parentType).Select(v => v.CreateToken(parent)); var pr = parentType.IsEntity() && !parentType.IsAbstract ? PropertyRoute.Root(parentType) : parentType.IsEmbeddedEntity() ? parent.GetPropertyRoute() : null; var edi = pr == null ? null : RegisteredExtensionsDictionaries.TryGetC(pr); IEnumerable <QueryToken> dicExtensionsTokens = edi == null?Enumerable.Empty <QueryToken>() : edi.GetAllTokens(parent); return(extensionsTokens.Concat(dicExtensionsTokens)); }
public static ObservableCollection <QuickLink> GetForEntity(Lite <Entity> ident, Control control) { ObservableCollection <QuickLink> links = new ObservableCollection <QuickLink>(); var func = EntityLinks.TryGetValue(ident.EntityType); if (func != null) { foreach (var item in func.GetInvocationListTyped()) { var array = item(ident, control); if (array != null) { links.AddRange(array.NotNull().Where(l => l.IsVisible)); } } } return(links); }
public static List <QuickLink> GetForEntity(Lite <Entity> ident, string partialViewName, string prefix, object queryName, UrlHelper url) { List <QuickLink> links = new List <QuickLink>(); QuickLinkContext ctx = new QuickLinkContext { PartialViewName = partialViewName, Prefix = prefix, QueryName = queryName, Url = url }; var func = EntityLinks.TryGetValue(ident.EntityType); if (func != null) { foreach (var item in func.GetInvocationListTyped()) { var array = item(ident, ctx); if (array != null) { links.AddRange(array.NotNull().Where(l => l.IsVisible)); } } } return(links); }
public static IOperation TryFindOperation(Type type, OperationSymbol operationSymbol) { return(operations.TryGetValue(type.CleanType())?.TryGetC(operationSymbol)); }