1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
7 using System.Collections.Generic;
8 using System.Activities.Presentation.Internal.PropertyEditing;
13 EditingContext context;
15 HashSet<Type> initializedTypes;
17 public FeatureManager(EditingContext context)
19 this.context = context;
20 initializedTypes = new HashSet<Type>();
23 public void InitializeFeature(Type modelType)
25 Fx.Assert(modelType != null, "Why would anyone initialize a feature that is not associated with a type");
27 if (!initializedTypes.Contains(modelType))
29 initializedTypes.Add(modelType);
30 foreach (FeatureAttribute featureAttribute in ExtensibilityAccessor.GetAttributes<FeatureAttribute>(modelType))
32 if (typeof(Feature).IsAssignableFrom(featureAttribute.Type))
34 Feature feature = (Feature)Activator.CreateInstance(featureAttribute.Type);
37 feature.Initialize(this.context, modelType);
41 if (modelType.IsGenericType)
43 InitializeFeature(modelType.GetGenericTypeDefinition());