1 // Copyright 2003-2004 DigitalCraftsmen - http://www.digitalcraftsmen.com.br/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ManagementExtensions
.Default
18 using System
.Configuration
;
21 /// Summary description for MDynamicSupportFactory.
23 public sealed class MDynamicSupportFactory
25 private static InvokerStrategy invokerStrategy
;
27 private static Object locker
= new Object();
29 private MDynamicSupportFactory()
36 /// <param name="instance"></param>
37 /// <returns></returns>
38 public static MDynamicSupport
Create(Object instance
)
42 if (invokerStrategy
== null)
44 String invokerStrategyName
=
45 ConfigurationSettings
.AppSettings
[MConstants
.INVOKER_STRATEGY_CONFIG_KEY
];
47 if (invokerStrategyName
== null || invokerStrategyName
.Length
== 0)
49 invokerStrategyName
= typeof(Strategy
.ReflectionInvokerStrategy
).FullName
;
52 Type invokerType
= Type
.GetType(invokerStrategyName
);
54 invokerStrategy
= (InvokerStrategy
) AppDomain
.CurrentDomain
.CreateInstanceAndUnwrap(
55 invokerType
.Assembly
.FullName
,
56 invokerType
.FullName
);
60 return invokerStrategy
.Create(instance
);