Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / Util / DictionaryCustomTypeDescriptor.cs / 1305376 / DictionaryCustomTypeDescriptor.cs
namespace System.Web.DynamicData.Util { using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; internal class DictionaryCustomTypeDescriptor : CustomTypeDescriptor { private IDictionary_values; private PropertyDescriptorCollection _properties; public DictionaryCustomTypeDescriptor(IDictionary values) { if (values == null) { throw new ArgumentNullException("values"); } _values = values; } public object GetValue(string name) { object value; if (_values.TryGetValue(name, out value)) { return value; } return null; } public override PropertyDescriptorCollection GetProperties() { if (_properties == null) { var dictionaryProps = _values.Keys.Select(propName => new DictionaryPropertyDescriptor(propName)); _properties = new PropertyDescriptorCollection(dictionaryProps.ToArray()); } return _properties; } } internal class DictionaryPropertyDescriptor : PropertyDescriptor { public DictionaryPropertyDescriptor(string name) : base(name, null /* attrs */) { } public override bool CanResetValue(object component) { throw new NotSupportedException(); } public override Type ComponentType { get { throw new NotSupportedException(); } } public override object GetValue(object component) { // Try to cast the component to a DictionaryCustomTypeDescriptor and get the value in the dictonary // that corresponds to this property DictionaryCustomTypeDescriptor typeDescriptor = component as DictionaryCustomTypeDescriptor; if (typeDescriptor == null) { return null; } return typeDescriptor.GetValue(Name); } public override bool IsReadOnly { get { throw new NotSupportedException(); } } public override Type PropertyType { get { throw new NotSupportedException(); } } public override void ResetValue(object component) { throw new NotSupportedException(); } public override void SetValue(object component, object value) { throw new NotSupportedException(); } public override bool ShouldSerializeValue(object component) { throw new NotSupportedException(); } } } // 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
- OleDbConnectionInternal.cs
- StandardOleMarshalObject.cs
- WindowShowOrOpenTracker.cs
- EncodingDataItem.cs
- ClientConvert.cs
- WebPartConnectionCollection.cs
- DateTimeStorage.cs
- PropertyEntry.cs
- HierarchicalDataSourceControl.cs
- EventItfInfo.cs
- DataRecordObjectView.cs
- ResizeGrip.cs
- _DomainName.cs
- ManualResetEventSlim.cs
- SqlBuilder.cs
- TokenBasedSet.cs
- XmlTextReader.cs
- FrameworkElementAutomationPeer.cs
- TextDecorationLocationValidation.cs
- RadioButton.cs
- DefaultDiscoveryServiceExtension.cs
- Rfc2898DeriveBytes.cs
- CaseKeyBox.xaml.cs
- AnnotationResourceChangedEventArgs.cs
- ControlPropertyNameConverter.cs
- XmlBindingWorker.cs
- ProviderConnectionPoint.cs
- IdentitySection.cs
- MiniAssembly.cs
- CallbackValidator.cs
- CodeSnippetStatement.cs
- HandlerFactoryCache.cs
- RsaSecurityKey.cs
- Queue.cs
- SoapExtensionReflector.cs
- RolePrincipal.cs
- WinCategoryAttribute.cs
- HtmlInputCheckBox.cs
- Dispatcher.cs
- InstanceNotReadyException.cs
- XmlLangPropertyAttribute.cs
- TableStyle.cs
- DataGridViewControlCollection.cs
- XmlnsCompatibleWithAttribute.cs
- MDIClient.cs
- JsonStringDataContract.cs
- ConstructorNeedsTagAttribute.cs
- HttpStreamXmlDictionaryWriter.cs
- PointLightBase.cs
- DriveInfo.cs
- CookieParameter.cs
- ResourceDisplayNameAttribute.cs
- HttpChannelListener.cs
- X509Certificate2Collection.cs
- BaseValidator.cs
- XamlSerializationHelper.cs
- Accessible.cs
- FolderNameEditor.cs
- Slider.cs
- DataGridViewComboBoxColumn.cs
- TextAnchor.cs
- TypefaceMap.cs
- Misc.cs
- SmtpLoginAuthenticationModule.cs
- DataListCommandEventArgs.cs
- ViewBase.cs
- SchemaConstraints.cs
- BitmapFrameEncode.cs
- ToolstripProfessionalRenderer.cs
- QueryTreeBuilder.cs
- UnsettableComboBox.cs
- PageThemeBuildProvider.cs
- SecurityTraceRecordHelper.cs
- SvcMapFileSerializer.cs
- InkCanvasSelectionAdorner.cs
- StrongNameHelpers.cs
- ZipFileInfoCollection.cs
- Message.cs
- DetailsViewUpdateEventArgs.cs
- Parameter.cs
- HtmlInputHidden.cs
- DataViewListener.cs
- DoubleConverter.cs
- Addressing.cs
- COM2ExtendedBrowsingHandler.cs
- StringDictionaryCodeDomSerializer.cs
- DragEvent.cs
- RoleManagerEventArgs.cs
- PermissionAttributes.cs
- ExtendedPropertyCollection.cs
- GiveFeedbackEvent.cs
- DateTimeConverter2.cs
- DataGridItemEventArgs.cs
- GridSplitter.cs
- ViewPort3D.cs
- TemplateColumn.cs
- InlineObject.cs
- UiaCoreProviderApi.cs
- Int64Animation.cs
- ConnectionStringsExpressionBuilder.cs