/// <summary> /// Retrieves the named InstanceMemento /// </summary> /// <param name="instanceKey">The instanceKey of the requested InstanceMemento</param> /// <returns></returns> public InstanceMemento GetMemento(string instanceKey) { InstanceMemento returnValue = null; if (_externalMementos.ContainsKey(instanceKey)) { returnValue = _externalMementos[instanceKey]; } else if (containsKey(instanceKey)) { try { returnValue = retrieveMemento(instanceKey); } catch (StructureMapException) { throw; } catch (Exception ex) { throw new StructureMapException(203, ex, instanceKey); } } // A null returnvalue is valid return(returnValue); }
public virtual InstanceMemento ResolveMemento(InstanceMemento memento) { InstanceMemento returnValue = memento; if (memento.IsDefault) { if (_defaultMemento == null) { string pluginTypeName = Family == null ? "UNKNOWN" : Family.PluginType.AssemblyQualifiedName; throw new StructureMapException(202, pluginTypeName); } returnValue = _defaultMemento; } else if (memento.IsReference) { returnValue = GetMemento(memento.ReferenceKey); if (returnValue == null) { throw new StructureMapException(200, memento.ReferenceKey, Family.PluginType.AssemblyQualifiedName); } } return(returnValue); }
/// <summary> /// Returns the named child InstanceMemento /// </summary> /// <param name="Key"></param> /// <returns></returns> public InstanceMemento GetChildMemento(string Key) { _lastKey = Key; InstanceMemento returnValue = getChild(Key); return(returnValue); }
public virtual Instance ReadChildInstance(string name, IPluginFactory graph, Type childType) { InstanceMemento child = GetChildMemento(name); return(child == null ? null : child.ReadInstance(graph, childType)); }
/// <summary> /// Returns the named child InstanceMemento /// </summary> /// <param name="key"></param> /// <returns></returns> public InstanceMemento GetChildMemento(string key) { InstanceMemento returnValue = getChild(key); return(returnValue); }
public virtual InstanceMemento ResolveMemento(InstanceMemento memento) { InstanceMemento returnValue = memento; if (memento.IsDefault) { if (_defaultMemento == null) { string pluginTypeName = Family == null ? "UNKNOWN" : Family.PluginType.AssemblyQualifiedName; throw new StructureMapException(202, pluginTypeName); } returnValue = _defaultMemento; } else if (memento.IsReference) { returnValue = GetMemento(memento.ReferenceKey); if (returnValue == null) { throw new StructureMapException(200, memento.ReferenceKey, Family.PluginType.AssemblyQualifiedName); } } return returnValue; }
/// <summary> /// Used to create a templated InstanceMemento /// </summary> /// <param name="memento"></param> /// <returns></returns> public virtual InstanceMemento Substitute(InstanceMemento memento) { throw new NotSupportedException("This type of InstanceMemento does not support the Substitute() Method"); }
public void ReferenceChild(string name, string instanceKey) { InstanceMemento child = CreateReferencedInstanceMemento(instanceKey); AddChild(name, child); }
/// <summary> /// Links a child InstanceMemento as a named property /// </summary> /// <param name="name"></param> /// <param name="Memento"></param> public void AddChild(string name, InstanceMemento Memento) { _children.Add(name, Memento); }
/// <summary> /// Links a child InstanceMemento as a named property /// </summary> public void AddChild(string name, InstanceMemento memento) { _children.Add(name, new[] { memento }); }
/// <summary> /// Links an array of InstanceMemento's to a named array property /// </summary> /// <param name="name"></param> /// <param name="childMementos"></param> public void AddChildArray(string name, InstanceMemento[] childMementos) { _children.Add(name, childMementos); }