示例#1
0
 internal bool Contains(ItemPolicy policy)
 {
     for (PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode policyNode = this; policyNode != null; policyNode = policyNode._next)
     {
         if (policyNode._policy == policy)
         {
             return(true);
         }
     }
     return(false);
 }
示例#2
0
 internal static bool Remove(ref PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode root, ItemPolicy policy)
 {
     PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode policyNode1 = (PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode)null;
     for (PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode policyNode2 = root; policyNode2 != null; policyNode2 = policyNode2._next)
     {
         if (policyNode2._policy == policy)
         {
             if (policyNode1 != null)
             {
                 policyNode1._next = policyNode2._next;
                 return(true);
             }
             root = policyNode2._next;
             return(true);
         }
         policyNode1 = policyNode2;
     }
     return(false);
 }
示例#3
0
        private void OnPolicyItemsChanged(object sender, PolicyItemsChangedEventArgs e)
        {
            Dictionary <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> > dictionary1 = this._removes;
            Dictionary <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> > dictionary2 = this._adds;

            this._removes = this._adds = (Dictionary <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> >)null;
            if (dictionary1 == null)
            {
                dictionary1 = new Dictionary <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> >();
            }
            else
            {
                dictionary1.Clear();
            }
            if (dictionary2 == null)
            {
                dictionary2 = new Dictionary <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> >();
            }
            else
            {
                dictionary2.Clear();
            }
            foreach (ModelItem key in e.ItemsRemoved)
            {
                List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> list;
                if (!this._featureProviders.TryGetValue(key, out list))
                {
                    list = new List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData>();
                }
                bool flag = false;
                foreach (PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData providerData in list)
                {
                    if (PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode.Remove(ref providerData.AssociatedPolicies, e.Policy))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    dictionary1[key] = list;
                }
            }
            foreach (ModelItem key in e.ItemsAdded)
            {
                List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> dataList;
                if (!this._featureProviders.TryGetValue(key, out dataList))
                {
                    dataList = new List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData>();
                }
                bool flag = false;
                foreach (TFeatureProviderType featureProviderType in (IEnumerable <TFeatureProviderType>) this.CreateFeatureProviders(key, e.Policy, dataList))
                {
                    PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData providerData = new PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData();

                    providerData.Provider           = featureProviderType;
                    providerData.AssociatedPolicies = new PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode(e.Policy, providerData.AssociatedPolicies);

                    providerData.IsValid = this.IsValidProvider((FeatureProvider)featureProviderType);
                    dataList.Add(providerData);
                    flag = true;
                }
                if (flag)
                {
                    dictionary2[key] = dataList;
                }
            }
            List <TFeatureProviderType> list1 = (List <TFeatureProviderType>)null;

            foreach (KeyValuePair <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> > keyValuePair in dictionary1)
            {
                ModelItem key = keyValuePair.Key;
                if (list1 != null)
                {
                    list1.Clear();
                }
                for (int index = 0; index < keyValuePair.Value.Count; ++index)
                {
                    PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData providerData = keyValuePair.Value[index];
                    if (providerData.AssociatedPolicies == null)
                    {
                        if (providerData.IsValid)
                        {
                            if (list1 == null)
                            {
                                list1 = new List <TFeatureProviderType>();
                            }
                            list1.Add(providerData.Provider);
                        }
                        keyValuePair.Value.RemoveAt(index);
                        --index;
                    }
                }
                if (keyValuePair.Value.Count == 0)
                {
                    this._featureProviders.Remove(key);
                }
                if (list1 != null && list1.Count > 0)
                {
                    this.FeatureProvidersRemoved(key, (IEnumerable <TFeatureProviderType>)list1);
                }
            }
            foreach (KeyValuePair <ModelItem, List <PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData> > keyValuePair in dictionary2)
            {
                ModelItem key = keyValuePair.Key;
                if (list1 != null)
                {
                    list1.Clear();
                }
                for (int index = 0; index < keyValuePair.Value.Count; ++index)
                {
                    PolicyDrivenFeatureConnector <TFeatureProviderType> .ProviderData providerData = keyValuePair.Value[index];
                    if (providerData.AssociatedPolicies != null && !providerData.AssociatedPolicies.HasMultiple && (providerData.AssociatedPolicies.Contains(e.Policy) && providerData.IsValid))
                    {
                        if (list1 == null)
                        {
                            list1 = new List <TFeatureProviderType>();
                        }
                        list1.Add(providerData.Provider);
                    }
                }
                this._featureProviders[key] = keyValuePair.Value;
                if (list1 != null && list1.Count > 0)
                {
                    this.FeatureProvidersAdded(key, (IEnumerable <TFeatureProviderType>)list1);
                }
            }
            dictionary1.Clear();
            dictionary2.Clear();
            this._removes = dictionary1;
            this._adds    = dictionary2;
        }
示例#4
0
 internal PolicyNode(ItemPolicy policy, PolicyDrivenFeatureConnector <TFeatureProviderType> .PolicyNode next)
 {
     this._policy = policy;
     this._next   = next;
 }