/// <summary> /// Source: http://www.symbolsource.org/Public/Metadata/NuGet/Project/Castle.Windsor/3.0.0.3001/Release/.NETFramework,Version%3Dv4.0,Profile%3DClient/Castle.Windsor/Castle.Windsor/MicroKernel/ComponentActivator/DefaultComponentActivator.cs?ImageName=Castle.Windsor /// </summary> /// <param name="context"></param> /// <param name="property"></param> /// <param name="resolver"></param> /// <returns></returns> private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver) { if (property.Dependency.IsOptional == false || resolver.CanResolve(context, context.Handler, Model, property.Dependency)) { try { return resolver.Resolve(context, context.Handler, Model, property.Dependency); } catch (Exception ex) { //trondr: Do not silently ignore exceptions when resolving property depencies. //if (property.Dependency.IsOptional == false) //{ // throw; //} //trondr: Rethrow the exception throw new ComponentActivatorException("Failed to resolve property: " + property.Property.Name , ex, Model); } } return null; }
private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver) { if (property.Dependency.IsOptional == false || resolver.CanResolve(context, context.Handler, Model, property.Dependency)) { try { return resolver.Resolve(context, context.Handler, Model, property.Dependency); } catch (Exception) { if (property.Dependency.IsOptional == false) { throw; } } } return null; }
/// <summary> /// Adds the specified property. /// </summary> /// <param name="property">The property.</param> public void Add(PropertySet property) { InnerList.Add(property); }
private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver) { using (new DependencyTrackingScope(context, Model, property.Property, property.Dependency)) { if (property.Dependency.IsOptional == false || resolver.CanResolve(context, context.Handler, Model, property.Dependency)) { return ObtainPropertyValueCore(context, property, resolver); } } return null; }
private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver) { if (property.Dependency.IsOptional == false || resolver.CanResolve(context, context.Handler, Model, property.Dependency)) { try { return resolver.Resolve(context, context.Handler, Model, property.Dependency); } catch (Exception e) { if (property.Dependency.IsOptional == false) { throw; } Kernel.Logger.Warn(string.Format("Exception when resolving optional dependency {0} on component {1}.", property.Dependency, Model.Name), e); } } return null; }