/// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        public virtual Instance ReadChildInstance(string name, IPluginFactory graph, Type childType)
        {
            InstanceMemento child = GetChildMemento(name);

            return(child == null ? null : child.ReadInstance(graph, childType));
        }
示例#5
0
        /// <summary>
        /// Returns the named child InstanceMemento
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public InstanceMemento GetChildMemento(string key)
        {
            InstanceMemento returnValue = getChild(key);

            return(returnValue);
        }
示例#6
0
        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;
        }
示例#7
0
 /// <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");
 }
 /// <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");
 }
示例#9
0
        public void ReferenceChild(string name, string instanceKey)
        {
            InstanceMemento child = CreateReferencedInstanceMemento(instanceKey);

            AddChild(name, child);
        }
示例#10
0
 /// <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);
 }
示例#11
0
 /// <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);
 }
 /// <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);
 }