public static ILogger <TDataItem> Validate <TDataItem>(this ILogger <TDataItem> logger, IKernel kernel) { ILoggerInternal loggerInternal = logger as ILoggerInternal; if (loggerInternal == null) { throw new ArgumentException("logger must implement ILoggerInternal"); } ConfigurationValidationResult result = new ConfigurationValidationResult(); if (!InterceptionEnabled(kernel)) { result.AddError("Castle binding not set. Call BindToWindsor method."); } ConfigurationValidationResult innerValidationResult = ((ILoggerInternal)logger).ValidateConfiguration( new DeclaringTypeMustBeAccessibleForProxyCreating(), new DeclaringTypeCannotBeOpenGeneric(), new DeclaringTypeCannotBeInterface(), new ReturnsSatisfiedIfUnableToCheck( new MethodMustBeVirtualIfDeclaringTypeRegisteredOnlyForItself(kernel)), new DeclaringTypeMustBeRegisteredInContainer(kernel), new ReturnsSatisfiedIfUnableToCheck( new DeclaringNonGenericTypeMustBeRegisteredInContainerAfterLoggerConfigured(kernel))); result.CopyErrorsFrom(innerValidationResult); if (!result.IsValid) { throw new LoggerValidationException(result); } return(logger); }
public static ILogger <TDataItem> BindToWindsor <TDataItem>(this ILogger <TDataItem> logger, IKernel kernel) { ILoggerInternal loggerInternal = logger as ILoggerInternal; if (loggerInternal == null) { throw new ArgumentException("logger must implement ILoggerInternal"); } if (!InterceptionEnabled(kernel)) { EnableInterception(kernel); } ICompositeLoggerInternal compositeLoggerInternal = kernel.Resolve <ICompositeLoggerInternal>(); if (compositeLoggerInternal.Has((ILoggerInternal)logger)) { throw new InvalidOperationException("Logger already bound"); } compositeLoggerInternal.Add((ILoggerInternal)logger); return(logger.SetContainer(new WindsorContainerWrapper(kernel))); }
public void Add(ILoggerInternal loggerInternal) { if (Has(loggerInternal)) { throw new Exception("Logger already added"); } _loggers.Add(loggerInternal); }
public bool Has(ILoggerInternal loggerInternal) { return(_loggers.Contains(loggerInternal)); }