Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Tools / ManagedExtensions / ManagementExtensions / Default / MDynamicSupportFactory.cs
blobe5e716c2af1cde77134e09f574aafff6c33bde82
1 // Copyright 2003-2004 DigitalCraftsmen - http://www.digitalcraftsmen.com.br/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.Configuration;
20 /// <summary>
21 /// Summary description for MDynamicSupportFactory.
22 /// </summary>
23 public sealed class MDynamicSupportFactory
25 private static InvokerStrategy invokerStrategy;
27 private static Object locker = new Object();
29 private MDynamicSupportFactory()
33 /// <summary>
34 /// TODO: Summary
35 /// </summary>
36 /// <param name="instance"></param>
37 /// <returns></returns>
38 public static MDynamicSupport Create(Object instance)
40 lock(locker)
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);