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
- CellCreator.cs
- AdditionalEntityFunctions.cs
- AncestorChangedEventArgs.cs
- WebPartZoneDesigner.cs
- ReadOnlyMetadataCollection.cs
- SynchronizedDispatch.cs
- DataStorage.cs
- Int16KeyFrameCollection.cs
- Authorization.cs
- SpeechRecognitionEngine.cs
- BindingNavigator.cs
- X509SecurityTokenAuthenticator.cs
- XmlStringTable.cs
- SystemBrushes.cs
- ProfileSettings.cs
- returneventsaver.cs
- SortedList.cs
- TextDecorationLocationValidation.cs
- SafePointer.cs
- SortedDictionary.cs
- ConfigUtil.cs
- QilCloneVisitor.cs
- ProxyWebPartManager.cs
- TypeGeneratedEventArgs.cs
- ListItemConverter.cs
- BlockUIContainer.cs
- ConfigXmlReader.cs
- SQLMoneyStorage.cs
- EntryWrittenEventArgs.cs
- StylusPointCollection.cs
- SecurityContext.cs
- RSAOAEPKeyExchangeFormatter.cs
- Journaling.cs
- SelectedDatesCollection.cs
- ExternalException.cs
- ScriptRef.cs
- BitmapImage.cs
- ExceptionHandlerDesigner.cs
- SqlSupersetValidator.cs
- ADMembershipProvider.cs
- TargetInvocationException.cs
- InternalPermissions.cs
- KeyConstraint.cs
- XmlSchemaImport.cs
- XslTransform.cs
- SortFieldComparer.cs
- TextOptionsInternal.cs
- TemplatedMailWebEventProvider.cs
- RegexCode.cs
- NumericUpDownAccelerationCollection.cs
- DisplayMemberTemplateSelector.cs
- KnowledgeBase.cs
- GridToolTip.cs
- ObjectViewQueryResultData.cs
- Random.cs
- ElementProxy.cs
- ImageField.cs
- MessageSecurityOverTcpElement.cs
- TrustSection.cs
- XMLDiffLoader.cs
- PointHitTestResult.cs
- TemplateFactory.cs
- CharEnumerator.cs
- ACE.cs
- ParagraphVisual.cs
- Region.cs
- DependencyPropertyDescriptor.cs
- AuditLog.cs
- LinkLabelLinkClickedEvent.cs
- Lease.cs
- FrameworkContentElementAutomationPeer.cs
- ProfilePropertySettings.cs
- PropertyTabAttribute.cs
- Encoder.cs
- SqlInternalConnectionSmi.cs
- WindowsIdentity.cs
- SmiMetaDataProperty.cs
- HttpBrowserCapabilitiesWrapper.cs
- AsyncOperation.cs
- AdornerLayer.cs
- NonClientArea.cs
- TableCellCollection.cs
- DataBinding.cs
- ConnectionsZone.cs
- XmlNodeReader.cs
- CounterSampleCalculator.cs
- EventLog.cs
- EventToken.cs
- Rights.cs
- AnonymousIdentificationModule.cs
- WebServiceAttribute.cs
- TransformerTypeCollection.cs
- LabelDesigner.cs
- CapabilitiesState.cs
- SessionStateSection.cs
- PageContentCollection.cs
- CapabilitiesAssignment.cs
- CustomValidator.cs
- DocumentCollection.cs
- IFormattable.cs