Exemplo n.º 1
0
 internal static Step GetFilterStepOrNone(this IGraphElementModel model, Type type,
                                          FilterLabelsVerbosity verbosity, Func <string[], Step> stepFactory)
 {
     return(model
            .TryGetFilterLabels(type, verbosity)
            .Map(stepFactory)
            .IfNone(NoneStep.Instance));
 }
Exemplo n.º 2
0
        public static ImmutableArray <string>?TryGetFilterLabels(this IGraphElementModel model, Type type, FilterLabelsVerbosity verbosity)
        {
            var labels = DerivedLabels
                         .GetOrCreateValue(model)
                         .GetOrAdd(
                type,
                (closureType, closureModel) =>
            {
                return(closureModel.Metadata
                       .Where(kvp => !kvp.Key.IsAbstract && closureType.IsAssignableFrom(kvp.Key))
                       .Select(kvp => kvp.Value.Label)
                       .OrderBy(x => x)
                       .ToImmutableArray());
            },
                model);

            return(labels.IsEmpty
                ? default(ImmutableArray <string>?)
                : labels.Length == model.Metadata.Count && verbosity == FilterLabelsVerbosity.Minimum
                    ? ImmutableArray <string> .Empty
                    : labels);
        }
Exemplo n.º 3
0
 internal static ImmutableArray <string> GetFilterLabelsOrDefault(this IGraphElementModel model, Type type, FilterLabelsVerbosity verbosity)
 {
     return(model
            .TryGetFilterLabels(type, verbosity) ?? ImmutableArray.Create(type.Name));
 }
Exemplo n.º 4
0
        public static Option <string[]> TryGetFilterLabels(this IGraphElementModel model, Type type, FilterLabelsVerbosity filterLabelsVerbosity)
        {
            var labels = DerivedLabels
                         .GetOrCreateValue(model)
                         .GetOrAdd(
                type,
                closureType =>
            {
                return(model.Metadata
                       .Where(kvp => !kvp.Key.IsAbstract && closureType.IsAssignableFrom(kvp.Key))
                       .Select(kvp => kvp.Value.Label)
                       .OrderBy(x => x)
                       .ToArray());
            });


            return(labels.Length == 0
                ? default(Option <string[]>)
                : labels.Length == model.Metadata.Count && filterLabelsVerbosity == FilterLabelsVerbosity.Minimum
                    ? Array.Empty <string>()
                    : labels);
        }
Exemplo n.º 5
0
        public static ImmutableArray <string>?TryGetFilterLabels(this IGraphElementModel model, Type type, FilterLabelsVerbosity verbosity)
        {
            var labels = model.GetCache().GetDerivedLabels(type);

            return(labels.IsEmpty
                ? default(ImmutableArray <string>?)
                : labels.Length == model.Metadata.Count && verbosity == FilterLabelsVerbosity.Minimum
                    ? ImmutableArray <string> .Empty
                    : labels);
        }