public ConstructorInstance ToInstance(IPluginFactory factory, Type pluginType) { var plugin = factory.PluginFor(PluggedType()); var instance = new ConstructorInstance(plugin); if (InstanceKey.IsNotEmpty()) { instance.Name = InstanceKey; } var reader = new InstanceMementoPropertyReader(instance, this, factory); plugin.VisitArguments(reader); return(instance); }
public void ForMemento(InstanceMemento memento, Action<Registry, Instance> callback) { ForType(memento.PluggedType, concreteType => { // TODO -- gotta catch errors here _log.Try(() => { var instance = new ConstructorInstance(concreteType); instance.Name = memento.InstanceKey; // TEMPORARY Plugin plugin = PluginCache.GetPlugin(concreteType); var reader = new InstanceMementoPropertyReader(instance, memento, this); plugin.VisitArguments(reader); callback(_registry, instance); }).AndLogAnyErrors(); }); }