Exemplo n.º 1
0
        /// <summary>
        ///  get the handler groups and their icons
        /// </summary>
        /// <remarks>
        ///  if we don't have a defined icon for a group, the icon from the first handler in the group
        ///  will be used.
        /// </remarks>
        public IDictionary <string, string> GetValidHandlerGroupsAndIcons(SyncHandlerOptions options = null)
        {
            var handlers = GetValidHandlers(options);

            return(handlers.Select(x => new { group = x.GetConfigGroup(), icon = x.GetGroupIcon() })
                   .SafeDistinctBy(x => x.group)
                   .ToDictionary(k => k.group, v => v.icon));
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Get the valid (by config) handler groups avalible to this setup
        /// </summary>
        public IEnumerable <string> GetValidGroups(SyncHandlerOptions options = null)
        {
            var handlers = GetValidHandlers(options);
            var groups   = handlers
                           .Select(x => x.GetConfigGroup())
                           .ToList();

            groups.AddRange(handlers.Where(x => !string.IsNullOrWhiteSpace(x.Settings.Group))
                            .Select(x => x.Settings.Group));

            return(groups.Distinct());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all valid (by configuration) handlers that fufill the criteria set out in the passed SyncHandlerOptions
        /// </summary>
        public IEnumerable <HandlerConfigPair> GetValidHandlers(SyncHandlerOptions options = null)
        {
            if (options == null)
            {
                options = new SyncHandlerOptions();
            }

            var configs = new List <HandlerConfigPair>();

            var handlerSetSettings = GetSetSettings(options.Set);

            foreach (var handler in _syncHandlers.Handlers.Where(x => options.IncludeDisabled || x.Enabled))
            {
                if (!options.IncludeDisabled && handlerSetSettings.DisabledHandlers.InvariantContains(handler.Alias))
                {
                    _logger.LogDebug("Handler {hadler} is in the disabled handler list", handler.Alias);
                    continue;
                }

                var config = LoadHandlerConfig(handler, handlerSetSettings);

                // check its valid for the passed group and action.
                if (handler != null && IsValidHandler(config, options.Action, options.Group))
                {
                    configs.Add(config);
                }
                else
                {
                    _logger.LogDebug("No Handler with {alias} has been loaded", handler.Alias);
                    // only log if we are doing the default 'everything' group
                    // because weh nfoing groups we choose not to load things.
                    if (string.IsNullOrWhiteSpace(options.Group))
                    {
                        _logger.LogWarning("No Handler with {alias} has been loaded", handler.Alias);
                    }
                }
            }

            return(configs.OrderBy(x => x.Handler.Priority));
        }
Exemplo n.º 4
0
 /// <summary>
 ///  get a collection of valid handlers that match the list of aliases
 /// </summary>
 public IEnumerable <HandlerConfigPair> GetValidHandlers(string[] aliases, SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .Where(x => aliases.InvariantContains(x.Handler.Alias));
Exemplo n.º 5
0
 /// <summary>
 ///  Get a all valid handlers (based on config) that can handle a given entityType
 /// </summary>
 public IEnumerable <HandlerConfigPair> GetValidHandlersByEntityType(IEnumerable <string> entityTypes, SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .Where(x => entityTypes.InvariantContains(x.Handler.EntityType));
Exemplo n.º 6
0
 /// <summary>
 ///  Get a valid handler (based on config) by options
 /// </summary>
 public HandlerConfigPair GetValidHander <TObject>(SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .Where(x => x.Handler.ItemType == typeof(TObject).Name)
 .FirstOrDefault();
Exemplo n.º 7
0
 /// <summary>
 ///  Get a valid handler (based on config) by Umbraco Entity Type and options
 /// </summary>
 public HandlerConfigPair GetValidHandlerByEntityType(string entityType, SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .Where(x => x.Handler.EntityType.InvariantEquals(entityType))
 .FirstOrDefault();
Exemplo n.º 8
0
 /// <summary>
 ///  Get a valid handler (based on config) by ItemType and options
 /// </summary>
 public HandlerConfigPair GetValidHandlerByTypeName(string itemType, SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .Where(x => itemType.InvariantEquals(x.Handler.TypeName))
 .FirstOrDefault();
Exemplo n.º 9
0
 /// <summary>
 ///  Get a valid handler (based on config) by alias and options
 /// </summary>
 public HandlerConfigPair GetValidHandler(string alias, SyncHandlerOptions options = null)
 => GetValidHandlers(options)
 .FirstOrDefault(x => x.Handler.Alias.InvariantEquals(alias));