public void WriteConstructionLog(ConstructionLogContext context)
 {
     context.WriteIndent();
     if (ContainerService != null)
     {
         context.UsedFromDependency = this;
         ContainerService.WriteConstructionLog(context);
         return;
     }
     if (Status != ServiceStatus.Ok)
     {
         context.Writer.WriteMeta("!");
     }
     context.Writer.WriteName(Name);
     if (Comment != null && Status != ServiceStatus.Error)
     {
         context.Writer.WriteMeta(" - ");
         context.Writer.WriteMeta(Comment);
     }
     if (Status == ServiceStatus.Ok && constantKind.HasValue)
     {
         if (constantKind == ConstantKind.Value)
         {
             ValueFormatter.WriteValue(context, Value, true);
         }
         if (constantKind == ConstantKind.Resource)
         {
             context.Writer.WriteMeta(string.Format(" resource [{0}]", resourceName));
         }
     }
     if (Status == ServiceStatus.Error)
     {
         context.Writer.WriteMeta(" <---------------");
     }
     context.Writer.WriteNewLine();
 }
Exemplo n.º 2
0
        public void WriteConstructionLog(ConstructionLogContext context)
        {
            var usedContracts     = UsedContracts;
            var attentionRequired = Status.IsBad() ||
                                    Status == ServiceStatus.NotResolved && (context.UsedFromDependency == null ||
                                                                            context.UsedFromDependency.Status ==
                                                                            ServiceStatus.NotResolved);

            if (attentionRequired)
            {
                context.Writer.WriteMeta("!");
            }
            var formattedName = context.UsedFromDependency == null?Type.FormatName() : context.UsedFromDependency.Name;

            context.Writer.WriteName(formattedName);
            if (usedContracts != null && usedContracts.Length > 0)
            {
                context.Writer.WriteUsedContract(InternalHelpers.FormatContractsKey(usedContracts));
            }
            var name = new ServiceName(Type, usedContracts);

            if (!context.Seen.Add(name))
            {
                if (context.UsedFromService != null && context.UsedFromService.Name.Equals(name) &&
                    context.UsedFromDependency != null && context.UsedFromDependency.Comment != null)
                {
                    context.Writer.WriteMeta(" - ");
                    context.Writer.WriteMeta(context.UsedFromDependency.Comment);
                }
                context.Writer.WriteNewLine();
                return;
            }
            if (Instances.Length > 1)
            {
                context.Writer.WriteMeta("++");
            }
            if (Status == ServiceStatus.Error)
            {
                context.Writer.WriteMeta(" <---------------");
            }
            else
            {
                var logComment = comment;
                if (logComment == null && context.UsedFromDependency != null &&
                    context.UsedFromDependency.Status != ServiceStatus.Error)
                {
                    logComment = context.UsedFromDependency.Comment;
                }
                if (logComment != null)
                {
                    context.Writer.WriteMeta(" - ");
                    context.Writer.WriteMeta(logComment);
                }
            }
            if (context.UsedFromDependency != null && context.UsedFromDependency.Status == ServiceStatus.Ok &&
                (context.UsedFromDependency.Value == null || context.UsedFromDependency.Value.GetType().IsSimpleType()))
            {
                context.Writer.WriteMeta(" -> " + InternalHelpers.DumpValue(context.UsedFromDependency.Value));
            }
            else if (Instances.Length == 1 && Instances[0].IsConstant)
            {
                ValueFormatter.WriteValue(context, Instances[0].Instance, true);
            }
            if (initializing)
            {
                context.Writer.WriteMeta(", initializing ...");
            }
            else if (disposing)
            {
                context.Writer.WriteMeta(", disposing ...");
            }
            context.Writer.WriteNewLine();
            if (dependencies != null)
            {
                foreach (var d in dependencies)
                {
                    context.Indent++;
                    context.UsedFromService = this;
                    d.WriteConstructionLog(context);
                    context.Indent--;
                }
            }
        }