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

            return(child == null ? null : child.ReadInstance(graph, childType));
        }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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");
 }
Esempio n. 9
0
        public void ReferenceChild(string name, string instanceKey)
        {
            InstanceMemento child = CreateReferencedInstanceMemento(instanceKey);

            AddChild(name, child);
        }
Esempio n. 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);
 }
Esempio n. 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);
 }