Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Base / Core / PropertyEditing / PropertyFilter.cs / 1305376 / PropertyFilter.cs
namespace System.Activities.Presentation.PropertyEditing {
using System;
using System.Collections.Generic;
using System.Runtime;
using System.Activities.Presentation;
///
/// This class is used as part of the searching/filtering functionality that may provided
/// by the property editing host. It contains a list of predicates (i.e. strings to match against)
///
[Fx.Tag.XamlVisible(false)]
public class PropertyFilter
{
private List _predicates = new List();
///
/// Creates a PropertyFilter.
///
/// String representation of predicates, space delimited
public PropertyFilter(string filterText)
{
SetPredicates(filterText);
}
///
/// Creates a PropertyFilter.
///
/// IEnumerable collection of predicates
public PropertyFilter(IEnumerable predicates) {
SetPredicates(predicates);
}
///
/// Readonly property that returns true if this PropertyFilter does not have any predicates
///
public bool IsEmpty {
get { return this._predicates == null || this._predicates.Count == 0; }
}
private void SetPredicates(string filterText) {
if (string.IsNullOrEmpty(filterText))
return;
string[] filterParts = filterText.Split(' ');
for (int i=0; i < filterParts.Length; i++) {
if (!string.IsNullOrEmpty(filterParts[i])) {
_predicates.Add(new PropertyFilterPredicate(filterParts[i]));
}
}
}
private void SetPredicates(IEnumerable predicates) {
if (predicates == null)
return;
foreach (PropertyFilterPredicate predicate in predicates) {
if (predicate != null) {
_predicates.Add(predicate);
}
}
}
///
/// Matches this filter against a particular filter target. The
/// filter returns true if there are no predicates or if one or more
/// predicates match the filter target.
///
/// Target to attempt matching
/// True if there are no predicates or if one or more
/// predicates match the filter target, false otherwise
/// If target is null.
public bool Match(IPropertyFilterTarget target) {
if (target == null)
throw FxTrace.Exception.ArgumentNull("target");
if (this.IsEmpty)
return true;
// Perform an OR over all predicates
for (int i = 0; i < this._predicates.Count; i++) {
if (target.MatchesPredicate(_predicates[i]))
return true;
}
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- COM2IPerPropertyBrowsingHandler.cs
- Roles.cs
- CultureSpecificStringDictionary.cs
- ListBoxItemAutomationPeer.cs
- DeleteHelper.cs
- Model3DGroup.cs
- ThrowHelper.cs
- LinkedResourceCollection.cs
- SkinBuilder.cs
- MultiSelectRootGridEntry.cs
- CreateUserWizard.cs
- VolatileEnlistmentState.cs
- HandleExceptionArgs.cs
- BitmapMetadataEnumerator.cs
- PositiveTimeSpanValidator.cs
- TogglePatternIdentifiers.cs
- AnnotationComponentChooser.cs
- FormViewUpdatedEventArgs.cs
- UTF32Encoding.cs
- RoleService.cs
- FactoryMaker.cs
- MediaElement.cs
- login.cs
- NetworkInterface.cs
- CommonObjectSecurity.cs
- CorrelationManager.cs
- PropertyKey.cs
- DefaultWorkflowSchedulerService.cs
- ExceptionUtility.cs
- SqlParameterCollection.cs
- ConfigurationException.cs
- UIServiceHelper.cs
- DefaultValueTypeConverter.cs
- EventLogPermissionHolder.cs
- RegexGroup.cs
- DashStyle.cs
- WebPartTransformerCollection.cs
- PinnedBufferMemoryStream.cs
- EntityDataSourceView.cs
- ResourceManagerWrapper.cs
- CodeExpressionRuleDeclaration.cs
- FileDialogCustomPlace.cs
- QuadraticBezierSegment.cs
- SpellerHighlightLayer.cs
- BaseInfoTable.cs
- FlowLayoutSettings.cs
- SmtpCommands.cs
- mda.cs
- StrokeRenderer.cs
- StringUtil.cs
- ComponentDispatcherThread.cs
- ExpandableObjectConverter.cs
- DataGridViewCellConverter.cs
- InvokePattern.cs
- BuildResultCache.cs
- AnonymousIdentificationModule.cs
- FormViewInsertedEventArgs.cs
- PasswordBox.cs
- GridProviderWrapper.cs
- TempEnvironment.cs
- HtmlTextArea.cs
- ItemCheckEvent.cs
- WindowsButton.cs
- FixedSOMImage.cs
- WindowInteractionStateTracker.cs
- ConfigurationElementCollection.cs
- ProcessThreadDesigner.cs
- WebPartMenuStyle.cs
- NullReferenceException.cs
- EventHandlersDesigner.cs
- LicenseManager.cs
- ChangeConflicts.cs
- CustomErrorsSectionWrapper.cs
- SqlDataSourceSummaryPanel.cs
- CompositeCollectionView.cs
- MenuItem.cs
- ThreadExceptionEvent.cs
- Aggregates.cs
- HttpCapabilitiesBase.cs
- LocalFileSettingsProvider.cs
- SmtpTransport.cs
- OledbConnectionStringbuilder.cs
- sqlmetadatafactory.cs
- SizeConverter.cs
- WindowsFont.cs
- XamlValidatingReader.cs
- BuildProviderAppliesToAttribute.cs
- HierarchicalDataSourceControl.cs
- OutputCacheSettings.cs
- TextServicesCompartmentContext.cs
- Model3DGroup.cs
- DatagridviewDisplayedBandsData.cs
- MetaModel.cs
- LinqDataSourceUpdateEventArgs.cs
- SerializationInfoEnumerator.cs
- X509Certificate2.cs
- TemplateField.cs
- TextParagraphCache.cs
- Wrapper.cs
- GroupQuery.cs