J'essaie de comprendre comment configurer StructureMap (en utilisant un fichier de configuration XML). Une classe a un constructeur avec une liste contenant les instances d'une 2e classe:StructureMap Liste des types non primitifs
public interface ITestDocType { }
class TestDocType : ITestDocType
{
public List<AttributeRef> AttrRefs { get; set; }
public TestDocType(List<AttributeRef> attrRefs)
{
AttrRefs = attrRefs;
}
}
public class AttributeRef
{
public AttributeRef(string name, string xpath, string value)
{
Name = name;
Xpath = xpath;
Value = value;
}
public string Name { get; set; }
public string Xpath { get; set; }
public string Value { get; set; }
}
J'espérais pouvoir inline les instances de AttributeRef dans mon fichier de configuration, mais pas tout à fait sûr de savoir comment son fait (ou si son possible).
<DefaultInstance PluginType="ITestDocType" PluggedType="TestDocType">
<attrRefs>
// Would like to specify one to many AttributeRef instances inline here
</attrRefs>
</DefaultInstance>
ok, donc cela ne fonctionne pas de la façon dont il est censé ... Lorsque l'instance parent est récupérée, le paramètre "attrRefs" contient une liste vide ... Retour à la planche à dessin. –