Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / ModelUtilities.cs / 1305376 / ModelUtilities.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities.Presentation.Model
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Markup;
// This class provides useful shared utility functions that are
// needed by our ModelItemImpl class implementations.
internal static class ModelUtilities
{
// Returns a wrapped type converter for the given item.
internal static TypeConverter GetConverter(IModelTreeItem item)
{
return GetConverter(item.ModelTreeManager, item.ModelItem);
}
// Returns a wrapped converter for the given item.
internal static TypeConverter GetConverter(ModelTreeManager modelTreeManager, ModelItem item)
{
return new ModelTypeConverter(modelTreeManager, XamlUtilities.GetConverter(item.ItemType));
}
// Returns the default property on the item, or null if the item has
internal static PropertyDescriptor GetDefaultProperty(ModelItem item)
{
DefaultPropertyAttribute propAttr = TypeDescriptor.GetAttributes(item.ItemType)[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;
if (propAttr != null && !string.IsNullOrEmpty(propAttr.Name))
{
ModelProperty prop = item.Properties.Find(propAttr.Name);
if (prop != null)
{
return new ModelPropertyDescriptor(prop);
}
}
return null;
}
// Wraps an item's properties in PropertyDescriptors and returns a
// collection of them.
internal static PropertyDescriptorCollection WrapProperties(ModelItem item)
{
List descriptors = new List();
foreach (ModelProperty prop in item.Properties)
{
descriptors.Add(new ModelPropertyDescriptor(prop));
}
return new PropertyDescriptorCollection(descriptors.ToArray(), true);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Activities.Presentation.Model
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Markup;
// This class provides useful shared utility functions that are
// needed by our ModelItemImpl class implementations.
internal static class ModelUtilities
{
// Returns a wrapped type converter for the given item.
internal static TypeConverter GetConverter(IModelTreeItem item)
{
return GetConverter(item.ModelTreeManager, item.ModelItem);
}
// Returns a wrapped converter for the given item.
internal static TypeConverter GetConverter(ModelTreeManager modelTreeManager, ModelItem item)
{
return new ModelTypeConverter(modelTreeManager, XamlUtilities.GetConverter(item.ItemType));
}
// Returns the default property on the item, or null if the item has
internal static PropertyDescriptor GetDefaultProperty(ModelItem item)
{
DefaultPropertyAttribute propAttr = TypeDescriptor.GetAttributes(item.ItemType)[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;
if (propAttr != null && !string.IsNullOrEmpty(propAttr.Name))
{
ModelProperty prop = item.Properties.Find(propAttr.Name);
if (prop != null)
{
return new ModelPropertyDescriptor(prop);
}
}
return null;
}
// Wraps an item's properties in PropertyDescriptors and returns a
// collection of them.
internal static PropertyDescriptorCollection WrapProperties(ModelItem item)
{
List descriptors = new List();
foreach (ModelProperty prop in item.Properties)
{
descriptors.Add(new ModelPropertyDescriptor(prop));
}
return new PropertyDescriptorCollection(descriptors.ToArray(), true);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DynamicPropertyReader.cs
- DataControlButton.cs
- ConnectivityStatus.cs
- AnnouncementInnerClientCD1.cs
- TypeFieldSchema.cs
- ClientTargetCollection.cs
- SystemIPInterfaceStatistics.cs
- _FtpDataStream.cs
- DynamicDiscoSearcher.cs
- WindowsClientElement.cs
- MarkupExtensionParser.cs
- RijndaelCryptoServiceProvider.cs
- Panel.cs
- PeerCollaboration.cs
- TripleDES.cs
- TablePattern.cs
- TrackBarRenderer.cs
- DelegateSerializationHolder.cs
- Codec.cs
- TemplateBindingExpression.cs
- AssemblyInfo.cs
- PrivateFontCollection.cs
- CheckBox.cs
- ScopedMessagePartSpecification.cs
- XmlAttribute.cs
- FlowLayoutPanelDesigner.cs
- CfgSemanticTag.cs
- QueuedDeliveryRequirementsMode.cs
- SynchronizedInputPattern.cs
- BadImageFormatException.cs
- WebSysDefaultValueAttribute.cs
- Thread.cs
- QueryException.cs
- Unit.cs
- RoutedEventValueSerializer.cs
- ExportOptions.cs
- HttpChannelHelper.cs
- QueryOutputWriter.cs
- SelectedPathEditor.cs
- SchemaDeclBase.cs
- AssociationSet.cs
- _FtpControlStream.cs
- OdbcConnectionFactory.cs
- EdmComplexTypeAttribute.cs
- CacheHelper.cs
- TemplateBindingExpressionConverter.cs
- XmlReturnWriter.cs
- DataService.cs
- Tuple.cs
- HWStack.cs
- NumericUpDownAcceleration.cs
- BaseCAMarshaler.cs
- LassoSelectionBehavior.cs
- DynamicResourceExtension.cs
- SoapInteropTypes.cs
- SqlNotificationRequest.cs
- PhonemeConverter.cs
- GeneralTransformCollection.cs
- SmiContext.cs
- ActiveXHelper.cs
- SuppressIldasmAttribute.cs
- TypeDelegator.cs
- MenuCommandService.cs
- DecoderBestFitFallback.cs
- KeyedHashAlgorithm.cs
- TypeInitializationException.cs
- SoapAttributeAttribute.cs
- Compiler.cs
- UniqueIdentifierService.cs
- SiteMapDataSource.cs
- DescendantBaseQuery.cs
- WebPartUtil.cs
- PropertyChangingEventArgs.cs
- tooltip.cs
- IndicShape.cs
- SqlRecordBuffer.cs
- RenderingBiasValidation.cs
- SystemIPInterfaceStatistics.cs
- ColumnMapTranslator.cs
- StandardToolWindows.cs
- TypeUtil.cs
- CalendarDay.cs
- SchemaContext.cs
- TextRunCacheImp.cs
- ListControlConvertEventArgs.cs
- Parameter.cs
- LinqMaximalSubtreeNominator.cs
- SiteOfOriginPart.cs
- RSAOAEPKeyExchangeDeformatter.cs
- SelectedGridItemChangedEvent.cs
- InvalidateEvent.cs
- OleDbCommandBuilder.cs
- KeySplineConverter.cs
- _NestedSingleAsyncResult.cs
- Pool.cs
- TreeNodeStyleCollection.cs
- DesigntimeLicenseContextSerializer.cs
- MetadataImporterQuotas.cs
- TreeViewItemAutomationPeer.cs
- ClientEventManager.cs