I think the approach I will take will follow the com moniker pattern. >From a string like "uri![constructor-string]" I will just create a factory object with the object uri and then have it create a new instance from the constructor string. This is somewhat oversimplified compared to the COM moniker, but I can deal with it for now. I have no immediate need for anything other than simple naming of ojbects with constructor strings.
It would be nice if there were the equivilent of the DCOM moniker interfaces for parsing object names, composing monikers, and creating objects. I miss IMoniker. Doug > -----Original Message----- > From: Jérôme Grelier [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 19, 2003 12:54 PM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Constructing Objects From Strings in > dotnet > > > What about one of these method of Activator: > > public static ObjectHandle CreateInstance( > string assemblyName, > string typeName, > object[] activationAttributes > ); > > or > > public static object CreateInstance( > Type type, > object[] args > ); > > where the array let you pass arguments to the constructor of > the object you > want to instantiate. > > I you use the second one, you can first get the Type by > reflection based on > the name of the class expressed as a string (with the method > GetType of the > Assembly class). > > Would that be useful for what you want to do? > > Jerome > > > -----Message d'origine----- > > De : Moderated discussion of advanced .NET topics. [mailto:ADVANCED- > > [EMAIL PROTECTED] De la part de Doug Ransom > > Envoyé : mardi 17 juin 2003 00:03 > > À : [EMAIL PROTECTED] > > Objet : [ADVANCED-DOTNET] Constructing Objects From Strings > in dotnet > > > > The COM platform provided the moniker mechanism to create > objects in a > > certain fashion and initialize those objects a certain way. > This was > > quite convenient when representing the object specification > as a string. > > > > If I want a user to be able to configure a .net object > construction, how > > would I go about this. > > > > For example the string "object:foo.bar!r=6" is equivelent > to the C# code: > > > > int r=6; > > new foo.bar(r); > > > > and I would like to create or get a reference to the object > by calling > > something analagous to > > GetObject("object:foo.bar!r=6"); > > > > > > Creating the class dynamically doesn't seem to be a problem with the > > Activator methods, but what can be used to turn the > intializer string into > > constructor arguments? > > > > > > > > Doug Ransom > > Software Interoperability Architect > > Power Measurement > > 2195 Keating X Road > > Saanichton, BC, Canada V8M 2A5 > > Tel: 1-(250) 652-7100 > > E-Mail: <mailto:[EMAIL PROTECTED]> > > Website: <http://www.pwrm.com/> > > > > ION(r) smart energy everywhere(tm) >