/// <summary>Prints request with all its parents to string.</summary> <returns>The string.</returns> public override string ToString() { if (IsEmpty) { return("{empty}"); } var s = new StringBuilder(); if (FactoryType != FactoryType.Service) { s.Append(FactoryType.ToString().ToLower()).Append(' '); } if (ImplementationType != null && ImplementationType != ServiceType) { s.Append(ImplementationType).Append(": "); } s.Append(ServiceType); if (RequiredServiceType != null) { s.Append(" with RequiredServiceType=").Append(RequiredServiceType); } if (ServiceKey != null) { s.Append(" with ServiceKey=").Append('{').Append(ServiceKey).Append('}'); } if (MetadataKey != null || Metadata != null) { s.Append(" with Metadata=").Append(new KeyValuePair <string, object>(MetadataKey, Metadata)); } if (IfUnresolved != IfUnresolved.Throw) { s.Append(" if unresolved ").Append(Enum.GetName(typeof(IfUnresolved), IfUnresolved)); } if (ReuseLifespan != 0) { s.Append(" with ReuseLifespan=").Append(ReuseLifespan); } if (!DirectParent.IsEmpty) { s.AppendLine().Append(" in ").Append(DirectParent); } return(s.ToString()); }
public static AbstractFactory GetFactory(FactoryType type) { switch (type) { case FactoryType.FACTORY1: return(new ConcreteFactory1()); case FactoryType.FACTORY2: return(new ConcreteFactory2()); default: throw new ArgumentException("Invalid type factory", type.ToString()); } }
/// <summary>Prints request with all its parents to string.</summary> <returns>The string.</returns> public override string ToString() { if (IsEmpty) { return("{empty}"); } var s = new StringBuilder(); if (FactoryType != FactoryType.Service) { s.Append(FactoryType.ToString().ToLower()).Append(' '); } if (ImplementationType != null && ImplementationType != ServiceType) { s.Append(ImplementationType).Append(": "); } s.Append(ServiceType); if (RequiredServiceType != null) { s.Append(" with RequiredServiceType=").Append(RequiredServiceType); } if (ServiceKey != null) { s.Append(" with ServiceKey=").Append('{').Append(ServiceKey).Append('}'); } if (IfUnresolved != IfUnresolved.Throw) { s.Append(" if unresolved ").Append(Enum.GetName(typeof(IfUnresolved), IfUnresolved)); } if (ReuseLifespan != 0) { s.Append(" with ReuseLifespan=").Append(ReuseLifespan); } if (!ParentOrWrapper.IsEmpty) { s.AppendLine().Append(" in ").Append(ParentOrWrapper); } return(s.ToString()); }