Streamlining the Xml Configuration Proposal

136 views
Skip to first unread message

Jeremy Miller

unread,
Jan 31, 2013, 9:20:34 AM1/31/13
to structure...@googlegroups.com
The permanent issue/feature in GitHub is at https://github.com/structuremap/structuremap/issues/52.

There's a fair amount of cruft in StructureMap's Xml configuration support that I think should be cleaned out for the 3.0 release.  As several people have suggested, I think I would like to at least consider moving the Xml configuration into a separate library/nuget as an add-on.  That being said, here's what I'm thinking to keep and change:

Keep:
<StructureMap>  <!-- Eliminating the old @MementoStyle attribute.  Only the terser "attribute normalized" style will be supported from here on out

  <!-- Was "<AddInstance>", equivalent to Registry.For(plugin type).Add(type) -->
  <Add PluginType="assembly qualified name" Type="assembly qualified name" CtorArg1="" CtorArg2="" />

  <!-- Was "<DefaultInstance>", equivalent to Registry.For(plugin type).Use(type)
  <Use PluginType="assembly qualified name" Type="assembly qualified name" CtorArg1="" CtorArg2="" />

  <Profile Name="profile">
    <Add ..... />
    <Use ..... />
  </Profile>

  <!-- loads a Registry by type -->
  <Registry Type="assembly qualified name" />

</StructureMap>

What goes

Everything else should go.  The <PluginFamily>/<Plugin>/<Instance> structure especially needs to go because it bleeds StructureMap internals right into a user's face.  The <Machine> node goes.  <Assembly> node goes.

Loading Xml

From the expression to initialize a Container, I vote for leaving this unchanged:

var container = new Container(x => {
    x.IncludeConfigurationFromConfigFile = true/false; // unchanged from 2.6
    x.AddConfigurationFromXmlFile(string file)
    x.AddConfigurationFromNode(XmlNode); //gives you the ability to add Xml in any possible way you'd like
});

However, I'm voting that we kill off the old "StructureMap.config" file options in:

ObjectFactory.Initialize(x => {
    x.UseDefaultStructureMapConfigFile = true/false;
    x.IgnoreStructureMapConfig();
    x.PullConfigurationFromAppConfig();

});

Moving forward I'm thinking that the initialization for ObjectFactory and Container is the same thing, and ObjectFactory.Initialize(nested closure) is essentially:

ObjectFactory.Container = new Container(nested closure)



Thoughts?

Gleb Chermennov

unread,
Feb 3, 2013, 6:07:04 AM2/3/13
to structure...@googlegroups.com
Although I have never used xml to configure StructureMap, I think that we should leave minimum abilities that allows to wire dependencies through config files. Conventions rock. 

четверг, 31 января 2013 г., 18:20:34 UTC+4 пользователь Jeremy Miller написал:

Frank L. Quednau

unread,
Feb 8, 2013, 11:54:07 AM2/8/13
to structure...@googlegroups.com
Plus 1 on all accounts.

very minor point: the syntax could be
<For PluginType=".." Use=".."

for reasons of having the same words as in the Registry.
Reply all
Reply to author
Forward
0 new messages