Example #1
0
 public void InitializeFeatures(Type type)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type.IsPrimitive || type == typeof(string))
     {
         return;
     }
     if (this._initializedTypes == null)
     {
         this._initializedTypes = new HashSet <Type>();
     }
     if (this._initializedTypes.Contains(type))
     {
         return;
     }
     this._initializedTypes.Add(type);
     foreach (Attribute attribute1 in this.GetFeatureAttributesForType(type))
     {
         FeatureAttribute featureAttribute = attribute1 as FeatureAttribute;
         if (featureAttribute != null)
         {
             Type featureProviderType = featureAttribute.FeatureProviderType;
             if (!this._initializedTypes.Contains(featureProviderType))
             {
                 this._initializedTypes.Add(featureProviderType);
                 foreach (Attribute attribute2 in this.GetFeatureConnectorAttributesForType(featureProviderType))
                 {
                     FeatureConnectorAttribute connectorAttribute = attribute2 as FeatureConnectorAttribute;
                     if (connectorAttribute != null)
                     {
                         Type featureConnectorType = connectorAttribute.FeatureConnectorType;
                         if (!this._featureConnectors.ContainsKey(featureConnectorType))
                         {
                             FeatureManager.FeatureConnectorEntry featureConnectorEntry = new FeatureManager.FeatureConnectorEntry(featureConnectorType, this);
                             this._featureConnectors.Add(featureConnectorType, featureConnectorEntry);
                             featureConnectorEntry.AttemptActivate();
                         }
                     }
                 }
             }
             if (this._knownFeatureProviders == null)
             {
                 this._knownFeatureProviders = new HashSet <Type>();
             }
             if (!this._knownFeatureProviders.Contains(featureProviderType))
             {
                 this._knownFeatureProviders.Add(featureProviderType);
                 if (this.FeatureAvailable != null)
                 {
                     this.OnFeatureAvailable(new FeatureAvailableEventArgs(featureProviderType));
                 }
             }
         }
     }
 }
Example #2
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            FeatureAttribute featureAttribute = obj as FeatureAttribute;

            if (featureAttribute != null)
            {
                return(featureAttribute._featureProviderType == this._featureProviderType);
            }
            return(false);
        }
Example #3
0
 private static IEnumerable <FeatureProvider> CreateFeatureProviders(Type featureProviderType, IEnumerable <object> attrs, Predicate <Type> match)
 {
     foreach (Attribute attribute in attrs)
     {
         FeatureAttribute fAttrib = attribute as FeatureAttribute;
         if (fAttrib != null)
         {
             Type fType = fAttrib.FeatureProviderType;
             if (featureProviderType.IsAssignableFrom(fType) && match(fType))
             {
                 FeatureProvider featureProvider = FeatureManager.CreateFeatureProvider(fType);
                 if (featureProvider != null)
                 {
                     yield return(featureProvider);
                 }
             }
         }
     }
 }