private void BuildFilterSet(Principal p, string[] propertySet, QbeFilterDescription qbeFilterDescription) { foreach (string propertyName in propertySet) { if (p.GetChangeStatusForProperty(propertyName)) { // Property has changed. Add it to the filter set. object value = p.GetValueForProperty(propertyName); GlobalDebug.WriteLineIf( GlobalDebug.Info, "StoreCtx", "BuildFilterSet: type={0}, property name={1}, property value={2} of type {3}", p.GetType().ToString(), propertyName, value.ToString(), value.GetType().ToString()); // Build the right filter based on type of the property value if (value is PrincipalValueCollection <string> ) { PrincipalValueCollection <string> trackingList = (PrincipalValueCollection <string>)value; foreach (string s in trackingList.Inserted) { object filter = FilterFactory.CreateFilter(propertyName); ((FilterBase)filter).Value = (string)s; qbeFilterDescription.FiltersToApply.Add(filter); } } else if (value is X509Certificate2Collection) { // Since QBE filter objects are always unpersisted, any certs in the collection // must have been inserted by the application. X509Certificate2Collection certCollection = (X509Certificate2Collection)value; foreach (X509Certificate2 cert in certCollection) { object filter = FilterFactory.CreateFilter(propertyName); ((FilterBase)filter).Value = (X509Certificate2)cert; qbeFilterDescription.FiltersToApply.Add(filter); } } else { // It's not one of the multivalued cases. Try the scalar cases. object filter = FilterFactory.CreateFilter(propertyName); if (value == null) { ((FilterBase)filter).Value = null; } else if (value is bool) { ((FilterBase)filter).Value = (bool)value; } else if (value is string) { ((FilterBase)filter).Value = (string)value; } else if (value is GroupScope) { ((FilterBase)filter).Value = (GroupScope)value; } else if (value is byte[]) { ((FilterBase)filter).Value = (byte[])value; } else if (value is Nullable <DateTime> ) { ((FilterBase)filter).Value = (Nullable <DateTime>)value; } else if (value is ExtensionCache) { ((FilterBase)filter).Value = (ExtensionCache)value; } else if (value is QbeMatchType) { ((FilterBase)filter).Value = (QbeMatchType)value; } else { // Internal error. Didn't match either the known multivalued or scalar cases. Debug.Fail(String.Format( CultureInfo.CurrentCulture, "StoreCtx.BuildFilterSet: fell off end looking for {0} of type {1}", propertyName, value.GetType().ToString() )); } qbeFilterDescription.FiltersToApply.Add(filter); } } } }
private void BuildFilterSet(Principal p, string[] propertySet, QbeFilterDescription qbeFilterDescription) { string[] strArrays = propertySet; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; if (p.GetChangeStatusForProperty(str)) { object valueForProperty = p.GetValueForProperty(str); if (valueForProperty as PrincipalValueCollection <string> == null) { if (valueForProperty as X509Certificate2Collection == null) { object obj = FilterFactory.CreateFilter(str); if (valueForProperty != null) { if (!valueForProperty as bool) { if (valueForProperty as string == null) { if (valueForProperty as GroupScope == GroupScope.Local) { if (valueForProperty as byte[] == null) { if (valueForProperty as DateTime? == null) { if (valueForProperty as ExtensionCache == null) { if (valueForProperty as QbeMatchType != null) { ((FilterBase)obj).Value = (QbeMatchType)valueForProperty; } } else { ((FilterBase)obj).Value = (ExtensionCache)valueForProperty; } } else { ((FilterBase)obj).Value = (DateTime?)valueForProperty; } } else { ((FilterBase)obj).Value = (byte[])valueForProperty; } } else { ((FilterBase)obj).Value = (GroupScope)valueForProperty; } } else { ((FilterBase)obj).Value = (string)valueForProperty; } } else { ((FilterBase)obj).Value = (bool)valueForProperty; } } else { ((FilterBase)obj).Value = null; } qbeFilterDescription.FiltersToApply.Add(obj); } else { X509Certificate2Collection x509Certificate2Collection = (X509Certificate2Collection)valueForProperty; X509Certificate2Enumerator enumerator = x509Certificate2Collection.GetEnumerator(); while (enumerator.MoveNext()) { X509Certificate2 current = enumerator.Current; object obj1 = FilterFactory.CreateFilter(str); ((FilterBase)obj1).Value = current; qbeFilterDescription.FiltersToApply.Add(obj1); } } } else { PrincipalValueCollection <string> strs = (PrincipalValueCollection <string>)valueForProperty; foreach (string inserted in strs.Inserted) { object obj2 = FilterFactory.CreateFilter(str); ((FilterBase)obj2).Value = inserted; qbeFilterDescription.FiltersToApply.Add(obj2); } } } } }