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
- TimeStampChecker.cs
- Floater.cs
- IIS7WorkerRequest.cs
- URI.cs
- TitleStyle.cs
- AutoCompleteStringCollection.cs
- OutputCacheSettings.cs
- EntityDataSourceChangedEventArgs.cs
- CheckoutException.cs
- RegistrationContext.cs
- Image.cs
- ElementProxy.cs
- MDIControlStrip.cs
- RestrictedTransactionalPackage.cs
- ListViewUpdatedEventArgs.cs
- State.cs
- CheckBox.cs
- ListBindableAttribute.cs
- UnsafeNativeMethods.cs
- WebPageTraceListener.cs
- NativeMethods.cs
- WebPartConnectionsConfigureVerb.cs
- Attributes.cs
- MetafileHeader.cs
- ResolveDuplex11AsyncResult.cs
- SelectionHighlightInfo.cs
- StaticSiteMapProvider.cs
- SystemBrushes.cs
- EntryWrittenEventArgs.cs
- Bookmark.cs
- JsonReader.cs
- QueryOperator.cs
- MatrixAnimationBase.cs
- PolicyStatement.cs
- FormViewPageEventArgs.cs
- EpmContentDeSerializer.cs
- PropertyConverter.cs
- CompiledAction.cs
- WebReferencesBuildProvider.cs
- WorkerRequest.cs
- EntityContainerEmitter.cs
- ItemDragEvent.cs
- NumberAction.cs
- RIPEMD160.cs
- ContextBase.cs
- CodeParameterDeclarationExpression.cs
- CultureData.cs
- ToolStripRenderEventArgs.cs
- CounterCreationDataCollection.cs
- BuildManagerHost.cs
- ApplicationServiceHelper.cs
- SemanticValue.cs
- RegexCompiler.cs
- SqlExpressionNullability.cs
- SubclassTypeValidatorAttribute.cs
- CustomErrorCollection.cs
- OutOfMemoryException.cs
- XamlStyleSerializer.cs
- XamlSerializer.cs
- MinimizableAttributeTypeConverter.cs
- ArithmeticException.cs
- NCryptNative.cs
- AlternateView.cs
- PrimitiveRenderer.cs
- ExtensionFile.cs
- ServerValidateEventArgs.cs
- BackEase.cs
- HyperLinkField.cs
- ReflectionUtil.cs
- TransformCryptoHandle.cs
- StateValidator.cs
- infer.cs
- ThreadStateException.cs
- BCLDebug.cs
- DetailsViewInsertedEventArgs.cs
- RightNameExpirationInfoPair.cs
- ContentIterators.cs
- XamlTemplateSerializer.cs
- DefaultMergeHelper.cs
- QueryInterceptorAttribute.cs
- XsltQilFactory.cs
- LabelEditEvent.cs
- AppSettingsReader.cs
- DelegateSerializationHolder.cs
- LinkDescriptor.cs
- XmlNodeChangedEventArgs.cs
- PrivilegedConfigurationManager.cs
- AddInController.cs
- PageCodeDomTreeGenerator.cs
- Ops.cs
- AttachmentService.cs
- XmlNamespaceManager.cs
- HashMembershipCondition.cs
- Quaternion.cs
- StrokeNodeData.cs
- DataControlCommands.cs
- _UncName.cs
- PeerEndPoint.cs
- XhtmlConformanceSection.cs
- FormsAuthenticationEventArgs.cs