public override object CreateInstance(Type type, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback, IServiceProvider serviceProvider, params Attribute[] attributes) { if (type == null) throw new ArgumentNullException("type"); object result = null; Type builderType = Adaptable.GetBuilderType(type); if (builderType == null) { return Default.CreateInstance(type, values, callback, serviceProvider, attributes); } else { result = Default.CreateInstance(builderType, values, callback, serviceProvider, attributes); MethodInfo mi; result = Adaptable.InvokeBuilder(result, out mi, serviceProvider); InitializeCoreHelper(result, mi.ReturnType, values, callback, serviceProvider); } if (result == null) throw RuntimeFailure.CannotActivateNoConstructorOrBuilder("type", type); else return null; }
public PropertyTreeBinderImpl(IPropertyTreeBinderErrors errors, IPopulateComponentCallback callback) { this.errors = errors; Array.ForEach(Pipeline, t => t.Parent = this); this.directiveFactory = new SerializerDirectiveFactory(this); this.callback = callback; }
internal void InitializeCoreHelper(object result, Type type, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback, IServiceProvider serviceProvider) { Initialize(result, values, callback, serviceProvider); // Apply activation providers ExceptionHandler exceptionHandler = (ExceptionHandler) serviceProvider.GetService(typeof(ExceptionHandler)); ApplyActivationProviders(result, exceptionHandler, type, serviceProvider); ApplyPropertyActivationProviders(result, exceptionHandler, serviceProvider); }
public override object CreateInstance(Type type, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback, IServiceProvider serviceProvider, params Attribute[] attributes) { if (type == null) throw new ArgumentNullException("type"); attributes = attributes ?? Empty<Attribute>.Array; // TODO Implement process and appdomain isolation, reusable if (type.IsProcessIsolated() || attributes.Any(t => t is ProcessIsolatedAttribute)) { } else if (type.IsAppDomainIsolated() || attributes.Any(t => t is AppDomainIsolatedAttribute)) { } if (type.IsReusable() || attributes.Any(t => t is ReusableAttribute)) { } return base.CreateInstance(type, values, callback, serviceProvider, attributes); }
public virtual object CreateInstance(Type type, IEnumerable<KeyValuePair<string, object>> values = null, IPopulateComponentCallback callback = null, IServiceProvider serviceProvider = null, params Attribute[] attributes) { if (type == null) throw new ArgumentNullException("type"); try { ServiceProvider.PushCurrent(serviceProvider); serviceProvider = serviceProvider ?? ServiceProvider.Root; type = GetActivationType(type); object result = ActivateCoreHelper(type, ref values, serviceProvider); if (result == null) throw RuntimeFailure.CannotActivateNoConstructor("type", type); InitializeCoreHelper(result, type, values, callback, serviceProvider); return result; } finally { ServiceProvider.PopCurrent(); } }
internal void InitializeInternal(object component, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback, IServiceProvider serviceProvider) { this.Initialize(component, values, callback, serviceProvider); }
protected virtual void Initialize(object component, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback = null, IServiceProvider serviceProvider = null) { if (component == null) throw new ArgumentNullException("component"); // $NON-NLS-1 if (values == null) return; serviceProvider = serviceProvider ?? ServiceProvider.Null; callback = callback ?? PopulateComponentCallback.Default; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component); foreach (var kvp in values) { PropertyDescriptor pd = properties.Find(kvp.Key, true); if (pd == null) { callback.Missing(serviceProvider, kvp.Key); continue; } object defaultValue = kvp.Value; try { if (defaultValue == null || pd.PropertyType.IsInstanceOfType(defaultValue)) { } else { defaultValue = pd.Converter.ConvertFrom(defaultValue); } pd.SetValue(component, defaultValue); } catch (Exception ex) { callback.ConversionError(serviceProvider, pd, defaultValue, ex); } } }
// IActivationFactory implementation public virtual object CreateInstance( Type type, IEnumerable<KeyValuePair<string, object>> values = null, IPopulateComponentCallback callback = null, IServiceProvider serviceProvider = null, params Attribute[] attributes) { return this.activationFactory.CreateInstance(type, values, callback, ServiceProvider.Compose(serviceProvider, this), attributes); }
public object CreateInstance(Type type, IEnumerable<KeyValuePair<string, object>> values, IPopulateComponentCallback callback, IServiceProvider serviceProvider, params Attribute[] attributes) { return Glob.Anything; }
public override object Activate(IEnumerable<KeyValuePair<string, object>> arguments, IPopulateComponentCallback callback, IServiceProvider services) { return Activation.CreateInstance(type, arguments, callback, services); }
public override object Activate(IEnumerable<KeyValuePair<string, object>> arguments, IPopulateComponentCallback callback, IServiceProvider services) { if (helper == null) helper = new ActivationHelper(method); var instance = helper.CreateInstance(method.ReturnType, arguments, callback, services); return instance; }
public override object Activate(IEnumerable<KeyValuePair<string, object>> arguments, IPopulateComponentCallback callback, IServiceProvider services) { object result = GetValue(); Activation.Initialize(result, arguments, callback, services); return result; }
public abstract object Activate(IEnumerable<KeyValuePair<string, object>> arguments, IPopulateComponentCallback callback, IServiceProvider services);