Exemplo n.º 1
0
        private IList<Actions.Action> BuildActionsForWatcher(StatusWatcher watcher, WatcherSection configWatcher)
        {
            var result = new List<Actions.Action>();
            IList<object> listOfParameters;
            IList<PropertyInfo> properties;

            for (int j = 0; j < configWatcher.ContingenceActions.Count; j++)
            {
                var contingenceActionFromConfig = configWatcher.ContingenceActions[j];

                var type = Type.GetType(contingenceActionFromConfig.Type);
                var constructorInformation = type.GetConstructors().FirstOrDefault();

                listOfParameters = new List<object>();
                listOfParameters.Add(watcher);

                properties = contingenceActionFromConfig.GetType().GetProperties();
                foreach (var parameter in constructorInformation.GetParameters())
                {
                    if (parameter.Name.ToLower() != "statuswatcher")
                        listOfParameters.Add(
                            Convert.ChangeType(
                            properties.FirstOrDefault(x => x.Name.ToLower() == parameter.Name.ToLower()).GetValue(contingenceActionFromConfig),
                            parameter.ParameterType,
                            CultureInfo.InvariantCulture)
                            );
                }

                Actions.Action action = Activator.CreateInstance(type, listOfParameters.ToArray()) as Actions.Action;
                result.Add(action);
            }
            return result;
        }
Exemplo n.º 2
0
 public ConsoleAction(StatusWatcher statusWatcher, string messageLayout, Status triggerWhen, string name = "ConsoleAction")
     : base(statusWatcher, triggerWhen, name)
 {
     _messageLayout = messageLayout;
 }
Exemplo n.º 3
0
 public LogFileAction(StatusWatcher statusWatcher, string fileName, string messageLayout, Status triggerWhen, string name = "LogFileAction")
     : base(statusWatcher, triggerWhen, name)
 {
     _fileName = fileName;
     _messageLayout = messageLayout;
 }