Code:
/ 4.0 / 4.0 / 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. 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
- DataColumnMapping.cs
- ComponentDispatcherThread.cs
- DatePickerDateValidationErrorEventArgs.cs
- OdbcFactory.cs
- ContentHostHelper.cs
- OptimisticConcurrencyException.cs
- XsltInput.cs
- OdbcPermission.cs
- UshortList2.cs
- WebPartConnectionsCloseVerb.cs
- LineGeometry.cs
- DocComment.cs
- DocumentPageTextView.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- MsmqQueue.cs
- StorageInfo.cs
- FilteredDataSetHelper.cs
- TableLayoutPanelCellPosition.cs
- StrokeNode.cs
- FileChangesMonitor.cs
- EnumerableWrapperWeakToStrong.cs
- followingsibling.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- CultureMapper.cs
- XNameConverter.cs
- JsonMessageEncoderFactory.cs
- DataGridViewRow.cs
- TrackingLocation.cs
- RequestTimeoutManager.cs
- NetMsmqSecurityElement.cs
- ArrayElementGridEntry.cs
- Debug.cs
- Marshal.cs
- OrderByBuilder.cs
- AttachedAnnotationChangedEventArgs.cs
- PersistenceTypeAttribute.cs
- KeyGestureConverter.cs
- SQLInt32Storage.cs
- Avt.cs
- ValidationHelpers.cs
- DefaultPropertyAttribute.cs
- DrawingDrawingContext.cs
- RepeatInfo.cs
- TextRange.cs
- CounterCreationData.cs
- InheritanceUI.cs
- TraceContext.cs
- RelatedImageListAttribute.cs
- HtmlTextArea.cs
- SQLCharsStorage.cs
- IsolatedStorage.cs
- SecurityElement.cs
- QualifiedCellIdBoolean.cs
- VideoDrawing.cs
- ImagingCache.cs
- ItemsPanelTemplate.cs
- SqlDataSourceSelectingEventArgs.cs
- ServiceThrottlingBehavior.cs
- InkPresenter.cs
- BindingExpressionUncommonField.cs
- PropertyGridView.cs
- TreeNodeStyleCollection.cs
- SapiRecognizer.cs
- ClrPerspective.cs
- ImageBrush.cs
- GlyphRunDrawing.cs
- DBSchemaTable.cs
- RoleProviderPrincipal.cs
- ProviderSettings.cs
- Baml2006ReaderSettings.cs
- EmbeddedMailObjectsCollection.cs
- ClientRoleProvider.cs
- PageBuildProvider.cs
- FieldBuilder.cs
- TdsParameterSetter.cs
- FontFamilyValueSerializer.cs
- DependencyPropertyKey.cs
- DataServices.cs
- BindMarkupExtensionSerializer.cs
- HtmlInputPassword.cs
- ObservableDictionary.cs
- DataFormat.cs
- SerializationInfo.cs
- ThrowHelper.cs
- CounterSetInstance.cs
- ObjectStorage.cs
- ListControl.cs
- TextChange.cs
- ReadOnlyDataSource.cs
- CalendarDay.cs
- PngBitmapEncoder.cs
- KeyConstraint.cs
- DateTimeConverter2.cs
- ItemDragEvent.cs
- ClientType.cs
- GetPageNumberCompletedEventArgs.cs
- XmlEventCache.cs
- DynamicContractTypeBuilder.cs
- StringFunctions.cs
- EntityDataSourceValidationException.cs