Here is my patch for ExposeConfiguration, please have a look.

On Wed, Feb 18, 2009 at 10:12 AM, Karron Qiu <[email protected]> wrote:
> Sorry for my bad English, that confused you.
>
> I have two reasons here.
>
> 1. ExposeConfiguration method can't be called many times. It's an
> delegate , not a list that contains delegates. If I call this method
> many times, only the last one will be executed. Because I have some
> plugins for nh initialization, I don't know how many are them at
> runtime, so I can't mix them in one method. I think that
> ExposeConfiguration supports many calls will be very helpful. The
> codes may looks like below.
>
>
> private IList<Action<Configuration>> configAlterations = new
> List<Action<Configuration>>();
> public FluentConfiguration ExposeConfiguration(Action<Configuration> config)
>        {
>            if(config != null)
>                  configAlterations.Add(config);
>            return this;
>        }
>
>
> public ISessionFactory BuildSessionFactory()
>        {
>            try
>            {
>                mappingCfg.Apply(Configuration);
>
>                foreach (var configAlteration in configAlterations )
>                    configAlteration(Configuration);
>
>                return Configuration.BuildSessionFactory();
>            }
>            catch (Exception ex)
>            {
>                throw CreateConfigurationException(ex);
>            }
>        }
>
> 2. Yes, I want to use the Configuration object later.  The James's
> patch solved my problem. thank you.
>
>
>
> On Tue, Feb 17, 2009 at 8:00 PM, James Gregory <[email protected]> 
> wrote:
>>
>> Calm it Kermit. I'm not against having a constructor overload, I'll do
>> that next time I'm in there.
>>
>> As for exposing the property, I'd prefer not to because it's polluting
>> the API, but I'm not that fussed. All I wanted to know was why he said
>> he couldn't use the ExposeConfiguration; not didn't want to, or felt
>> it was unintuitive, but can't use it.
>>
>> On 2/17/09, Paul Batum <[email protected]> wrote:
>>> Just wanted to add that I recognise you can get a reference to it using
>>> Tuna's trick with the closure but I think its highly unintuitive.
>>>
>>> On Tue, Feb 17, 2009 at 9:34 PM, Paul Batum <[email protected]> wrote:
>>>
>>>> James, is there a reason you don't want to expose the Configuration? What
>>>> if someone wants to do something with it after the session factory is
>>>> built?
>>>> It seems perfectly reasonable to me for the getter to be public.
>>>>
>>>> Also, I wanted to add an overload to Fluently.Configure that takes an
>>>> existing Configuration object, there was one user that said this would
>>>> make
>>>> life much easier for him. Do you have a problem with this?
>>>>
>>>>
>>>> On Tue, Feb 17, 2009 at 9:23 PM, James Gregory
>>>> <[email protected]>wrote:
>>>>
>>>>> Why can't you use the ExposeConfiguration method? Some explanation would
>>>>> help.
>>>>>
>>>>>
>>>>> On Tue, Feb 17, 2009 at 7:33 AM, Karron Qiu <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>> On Tue, Feb 17, 2009 at 3:28 PM, Tuna Toksoz <[email protected]> wrote:
>>>>>> >             Configuration cfg;
>>>>>> >             var fconfig=Fluently.Configure().ExposeConfiguration(x =>
>>>>>> cfg =
>>>>>> > x);
>>>>>> >             PlayWithCfgHere
>>>>>> >             var sf = fconfig.BuildSessionFactory();
>>>>>> >
>>>>>> >
>>>>>> > Or simple call ExposeConfiguration(Action<NHConfig>) to
>>>>>> modify/dowhatever
>>>>>> > using a delegate.
>>>>>> >
>>>>>> > Tuna Toksöz
>>>>>> > http://tunatoksoz.com
>>>>>> > http://turkiyealt.net
>>>>>> > http://twitter.com/tehlike
>>>>>> >
>>>>>> > Typos included to enhance the readers attention!
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > On Tue, Feb 17, 2009 at 9:22 AM, Karron Qiu <[email protected]>
>>>>>> wrote:
>>>>>> >>
>>>>>> >> I just want to get the Configuration object from
>>>>>> >> Fluently.Configure().
>>>>>> >> Or can I pass a Configuration object to Fluently.Configure() ?
>>>>>> >>
>>>>>> >> Thanks
>>>>>> >>
>>>>>> >> On Tue, Feb 17, 2009 at 3:15 PM, Tuna Toksoz <[email protected]>
>>>>>> wrote:
>>>>>> >> > Fluently.Configure()
>>>>>> >> >   .Database(/* your database settings */)
>>>>>> >> >   .Mappings(/* your mappings */)
>>>>>> >> >   .ExposeConfiguration(/* alter Configuration */) // optional
>>>>>> >> >   .BuildSessionFactory();
>>>>>> >> >
>>>>>> >> > says the post on James blog?
>>>>>> >> >
>>>>>> >> > Tuna Toksöz
>>>>>> >> > http://tunatoksoz.com
>>>>>> >> > http://turkiyealt.net
>>>>>> >> > http://twitter.com/tehlike
>>>>>> >> >
>>>>>> >> > Typos included to enhance the readers attention!
>>>>>> >> >
>>>>>> >> >
>>>>>> >> >
>>>>>> >> > On Tue, Feb 17, 2009 at 9:11 AM, Karron Qiu <[email protected]>
>>>>>> wrote:
>>>>>> >> >>
>>>>>> >> >> There is a property in FluentConfiguration, but it is internal...
>>>>>>  I
>>>>>> >> >> want to hold the Configuration in my application because of some
>>>>>> >> >> reasons. I can't use the ExposeConfiguration method.
>>>>>> >> >>
>>>>>> >> >> --
>>>>>> >> >> Regards,
>>>>>> >> >> Karron
>>>>>> >> >>
>>>>>> >> >>
>>>>>> >> >
>>>>>> >> >
>>>>>> >> > >
>>>>>> >> >
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >> --
>>>>>> >> Regards,
>>>>>> >> Karron
>>>>>> >>
>>>>>> >>
>>>>>> >
>>>>>> >
>>>>>> > >
>>>>>> >
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Karron
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> >>
>>>>>
>>>>
>>>
>>> >
>>>
>>
>> >>
>>
>
>
>
> --
> Regards,
> Karron
>



-- 
Regards,
Karron

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: ExposeConfiguration.patch
Description: Binary data

Reply via email to