Наследование: IDependencyInspector
        protected void CheckCastleRegisterComponent()
        {
            var log = container.Resolve<ILogger>();

            var host = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
            var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();

            var handlers = diagnostics.Inspect();

            if (handlers.Any())
            {
                var message = new StringBuilder();
                var inspector = new DependencyInspector(message);

                foreach (IExposeDependencyInfo handler in handlers)
                {
                    handler.ObtainDependencyDetails(inspector);
                }

                log.Log(message.ToString(), LogType.Error);
                Console.WriteLine(message.ToString());
            }

            container.Release(log);
        }
        private ValidationResult CheckForPotentiallyMisconfiguredComponents(IWindsorContainer container)
        {
            var host = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
            var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();

            var handlers = diagnostics.Inspect();

            ValidationResult result = new ValidationResult();

            if (handlers.Any())
            {
                var message = new StringBuilder();
                var inspector = new DependencyInspector(message);

                foreach (IExposeDependencyInfo handler in handlers)
                {
                    handler.ObtainDependencyDetails(inspector);
                }

                result.AddMessage(Severity.Error, message.ToString());
                Console.Write(message.ToString());
            }

            return result;
        }
		private string GetStatusDetails(IExposeDependencyInfo info)
		{
			var message = new StringBuilder("Some dependencies of this component could not be statically resolved.");
			if (info == null)
			{
				return message.ToString();
			}
			var inspector = new DependencyInspector(message);
			info.ObtainDependencyDetails(inspector);

			return inspector.Message;
		}
Пример #4
0
        private HandlerException UnresolvableHandlerException()
        {
            var message = new StringBuilder("Can't create component '");

            message.Append(ComponentModel.Name);
            message.AppendLine("' as it has dependencies to be satisfied.");

            var inspector = new DependencyInspector(message);

            ObtainDependencyDetails(inspector);

            return(new HandlerException(inspector.Message, ComponentModel.ComponentName));
        }
Пример #5
0
        protected void AssertNotWaitingForDependency()
        {
            if (CurrentState == HandlerState.WaitingDependency)
            {
                var message = new StringBuilder("Can't create component '");
                message.Append(ComponentModel.Name);
                message.AppendLine("' as it has dependencies to be satisfied.");

                var inspector = new DependencyInspector(message);
                ObtainDependencyDetails(inspector);

                throw new HandlerException(inspector.Message, ComponentModel.ComponentName);
            }
        }
Пример #6
0
		protected void AssertNotWaitingForDependency()
		{
			if (CurrentState == HandlerState.WaitingDependency)
			{
				var message = new StringBuilder("Can't create component '");
				message.Append(ComponentModel.Name);
				message.AppendLine("' as it has dependencies to be satisfied.");

				var inspector = new DependencyInspector(message);
				ObtainDependencyDetails(inspector);

				throw new HandlerException(inspector.Message);
			}
		}
Пример #7
0
        private static void CheckForPotentiallyMisconfiguredComponents(IWindsorContainer container)
        {
            var host = (IDiagnosticsHost)container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
            var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();

            var handlers = diagnostics.Inspect();

            if (handlers.Any())
            {
                var message = new StringBuilder();
                var inspector = new DependencyInspector(message);

                foreach (IExposeDependencyInfo handler in handlers)
                {
                    handler.ObtainDependencyDetails(inspector);
                }

                throw new ApplicationException(message.ToString());
            }
        }
Пример #8
0
        public void ShouldNotHaveAnyMisconfiguredComponents()
        {
            var diagnostic
             = new PotentiallyMisconfiguredComponentsDiagnostic(container.Kernel);

            IHandler[] handlers = diagnostic.Inspect();
            if (handlers != null && handlers.Any())
            {
                var builder = new StringBuilder();

                builder.AppendFormat("Potentially misconfigured components ({0})\r\n", handlers.Count());

                foreach (IHandler handler in handlers)
                {
                    var info = (IExposeDependencyInfo)handler;
                    var inspector = new DependencyInspector(builder);
                    info.ObtainDependencyDetails(inspector);
                }

                Assert.Inconclusive(builder.ToString());
            }
        }
Пример #9
0
        /// <summary>
        /// Checks if there's any misconfigured components in Castle. This helps
        /// detect any type of configuration problems before run-time.
        /// </summary>
        /// <param name="kernel">The Castle kernel that we want to check.</param>
        /// <returns>A List of misconfigured element information as string.</returns>
        public static IEnumerable<string> CheckForPotentiallyMisconfiguredComponents(this IKernel kernel)
        {
            var host = (IDiagnosticsHost)kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
            var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();

            var handlers = diagnostics.Inspect();

            if (!handlers.Any())
            {
                yield break;
            }

            foreach (var handlerRaw in handlers)
            {
                var handler = (IExposeDependencyInfo) handlerRaw;
                var message = new StringBuilder();
                var inspector = new DependencyInspector(message);
                handler.ObtainDependencyDetails(inspector);

                yield return message.ToString();
            }
        }
Пример #10
0
		private HandlerException UnresolvableHandlerException()
		{
			var message = new StringBuilder("Can't create component '");
			message.Append(ComponentModel.Name);
			message.AppendLine("' as it has dependencies to be satisfied.");

			var inspector = new DependencyInspector(message);
			ObtainDependencyDetails(inspector);

			return new HandlerException(inspector.Message, ComponentModel.ComponentName);
		}