Exemplo n.º 1
0
        private static string GetProblemDetail(IExposeDependencyInfo problem)
        {
            var problemDetail = new StringBuilder();

            problem.ObtainDependencyDetails(new DependencyInspector(problemDetail));
            return(problemDetail.ToString());
        }
		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;
		}
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public static string Diagnose(IWindsorContainer container)
        {
            IHandler[] potentiallyMisconfiguredHandlers = Diagnostics.GetPotentiallyMisconfigured(container);

            StringBuilder       diagnosisReportBuilder = new StringBuilder();
            DependencyInspector diagnosisInspector     = new DependencyInspector(diagnosisReportBuilder);

            bool isAnyPotentiallyMisconfiguredHandler = false;

            foreach (IHandler handler in potentiallyMisconfiguredHandlers)
            {
                isAnyPotentiallyMisconfiguredHandler = true;

                IExposeDependencyInfo potentiallyMisconfiguredHandler = (IExposeDependencyInfo)handler;
                potentiallyMisconfiguredHandler.ObtainDependencyDetails(diagnosisInspector);
            }

            return(isAnyPotentiallyMisconfiguredHandler ? diagnosisReportBuilder.ToString() : null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns human readable list of dependencies
        /// this handler is waiting for.
        /// </summary>
        /// <returns></returns>
        public String ObtainDependencyDetails()
        {
            if (this.CurrentState == HandlerState.Valid)
            {
                return(String.Empty);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("\r\n{0} is waiting for the following dependencies: \r\n", ComponentModel.Name);

            if (DependenciesByService.Count != 0)
            {
                sb.Append("\r\nServices: \r\n");

                foreach (Type type in DependenciesByService)
                {
                    IHandler handler = Kernel.GetHandler(type);

                    if (handler == null)
                    {
                        sb.AppendFormat("- {0} which was not registered. \r\n", type.FullName);
                    }
                    else
                    {
                        sb.AppendFormat("- {0} which was registered but is also waiting for dependencies. \r\n", type.FullName);

                        IExposeDependencyInfo info = handler as IExposeDependencyInfo;

                        if (info != null)
                        {
                            sb.Append(info.ObtainDependencyDetails());
                        }
                    }
                }
            }

            if (DependenciesByKey.Count != 0)
            {
                sb.Append("\r\nKeys (components with specific keys)\r\n");

                foreach (String key in DependenciesByKey)
                {
                    IHandler handler = Kernel.GetHandler(key);

                    if (handler == null)
                    {
                        sb.AppendFormat("- {0} which was not registered. \r\n", key);
                    }
                    else
                    {
                        sb.AppendFormat("- {0} which was registered but is also waiting for dependencies. \r\n", key);

                        IExposeDependencyInfo info = handler as IExposeDependencyInfo;

                        if (info != null)
                        {
                            sb.Append(info.ObtainDependencyDetails());
                        }
                    }
                }
            }

            return(sb.ToString());
        }