示例#1
0
        /// <summary>
        /// Constructor for injecting anything marked with IDependency
        /// </summary>
        /// <param name="dependencies"></param>
        protected CfgNode(params IDependency[] dependencies) {
            if (dependencies != null) {
                foreach (var dependency in dependencies.Where(dependency => dependency != null)) {
                    if (dependency is IReader) {
                        Reader = dependency as IReader;
                    } else if (dependency is IParser) {
                        Parser = dependency as IParser;
                    } else if (dependency is ISerializer) {
                        Serializer = dependency as ISerializer;
                    } else if (dependency is ILogger) {
                        var composite = new DefaultLogger(new MemoryLogger(), dependency as ILogger);
                        if (Events == null) {
                            Events = new CfgEvents(composite);
                        } else {
                            Events.Logger = composite;
                        }
                    } else if (dependency is IValidators) {
                        foreach (var pair in dependency as IValidators) {
                            Validators[pair.Key] = pair.Value;
                        }
                    }
                }
            }

            Type = GetType();
        }
示例#2
0
 public CfgEvents(DefaultLogger logger) {
     Logger = logger;
 }