Exemplo n.º 1
0
 /// <summary>
 /// Is the handler valid for the given action
 /// </summary>
 public static bool IsValidAction(this HandlerConfigPair handlerAndConfig, HandlerActions action)
 {
     if (action.IsValidAction(handlerAndConfig.Settings.Actions))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// What group is the handler configured to be in
        /// </summary>
        /// <remarks>
        /// Gets the group from config or returns the default group for the selected handler
        /// </remarks>
        public static string GetConfigGroup(this HandlerConfigPair handlerConfigPair)
        {
            if (!string.IsNullOrWhiteSpace(handlerConfigPair.Settings.Group))
            {
                return(handlerConfigPair.Settings.Group);
            }

            return(handlerConfigPair.Handler.Group);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the icon for the group the handler belongs to
        /// </summary>
        public static string GetGroupIcon(this HandlerConfigPair handlerConfigPair)
        {
            var group = GetConfigGroup(handlerConfigPair);

            if (uSyncConstants.Groups.Icons.ContainsKey(group))
            {
                return(uSyncConstants.Groups.Icons[group]);
            }

            return(handlerConfigPair.Handler.Icon);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Is the handler valid for the given group?
        /// </summary>
        public static bool IsValidGroup(this HandlerConfigPair handlerAndConfig, string group)
        {
            // empty means all as does 'all'
            if (string.IsNullOrWhiteSpace(group) || group.InvariantEquals("all"))
            {
                return(true);
            }

            var handlerGroup = handlerAndConfig.Handler.Group;

            if (!string.IsNullOrWhiteSpace(handlerAndConfig.Settings.Group))
            {
                handlerGroup = handlerAndConfig.Settings.Group;
            }

            return(group.InvariantContains(handlerGroup));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Is the handler enabled
 /// </summary>
 public static bool IsEnabled(this HandlerConfigPair handlerAndConfig)
 => handlerAndConfig.Handler.Enabled && handlerAndConfig.Settings.Enabled;
Exemplo n.º 6
0
 /// <summary>
 ///  is this config pair valid for the settings we have for it.
 /// </summary>
 private bool IsValidHandler(HandlerConfigPair handlerConfigPair, HandlerActions actions, string group)
 => handlerConfigPair.IsEnabled() && handlerConfigPair.IsValidAction(actions) && handlerConfigPair.IsValidGroup(group);