I'm using reflection as a way of implementing a factory pattern:
Type type = GetProviderType(vendor);
ConstructorInfo constructorInfo = type.GetConstructor(new Type[] { typeof(NameValueCollection) });
ExternalSourceProvider vendorSourceProvider = (ExternalSourceProvider)constructorInfo.Invoke(new Object[] { requestData });
I can ensure that a member of the fabricated object is invoked by adding this code:
_externalSiteId = vendorSourceProvider.ExternalId;
_app = vendorSourceProvider.App;
This is smelly - I shouldn't need to 'touch' the member to ensure it's invoked. Any ideas on how to ensure invocation of the member? The reason I want to invoke these members is that I need to 'bootstrap' the fabricated 'vendorSourceProvider' object (and touching the member allows me to do this in the {get} of the member). Any ideas on how to achieve what I'm trying to do without needlessly 'touching' the member?
new
. You already have a lot of smell; what significant difference will "touching your member" make? [insert Saturday Night Live joke here]