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
- ComponentManagerBroker.cs
- PlanCompiler.cs
- RegexWorker.cs
- ListItemParagraph.cs
- MsmqMessage.cs
- XmlSchemaComplexContent.cs
- SharedUtils.cs
- PageSettings.cs
- CalendarAutoFormatDialog.cs
- OciHandle.cs
- TypedRowGenerator.cs
- WebConvert.cs
- CodeMemberProperty.cs
- Vector3DCollectionValueSerializer.cs
- SafeFileMapViewHandle.cs
- TemplateBuilder.cs
- cryptoapiTransform.cs
- MemberAssignmentAnalysis.cs
- ExpressionParser.cs
- XmlAnyElementAttribute.cs
- LongTypeConverter.cs
- TimerEventSubscription.cs
- DataGridAutomationPeer.cs
- OdbcUtils.cs
- RowVisual.cs
- GroupJoinQueryOperator.cs
- ProviderConnectionPoint.cs
- XmlWrappingWriter.cs
- ActivityStatusChangeEventArgs.cs
- ClientScriptManagerWrapper.cs
- DesignerActionKeyboardBehavior.cs
- TimerElapsedEvenArgs.cs
- DynamicILGenerator.cs
- Typeface.cs
- StateRuntime.cs
- Message.cs
- ellipse.cs
- Utils.cs
- ConfigXmlSignificantWhitespace.cs
- ObfuscationAttribute.cs
- Simplifier.cs
- Sql8ConformanceChecker.cs
- AlternateView.cs
- SystemInfo.cs
- SettingsProperty.cs
- TreeViewEvent.cs
- AutomationElementIdentifiers.cs
- CompoundFileStreamReference.cs
- CompModSwitches.cs
- DSACryptoServiceProvider.cs
- _LazyAsyncResult.cs
- PassportIdentity.cs
- PrinterSettings.cs
- DynamicRendererThreadManager.cs
- NavigatorInput.cs
- DtrList.cs
- OrthographicCamera.cs
- EntityWrapperFactory.cs
- RequiredAttributeAttribute.cs
- GPRECTF.cs
- XsltInput.cs
- TextSelection.cs
- SystemTcpConnection.cs
- CqlBlock.cs
- ViewManager.cs
- NextPreviousPagerField.cs
- HostedHttpRequestAsyncResult.cs
- AttachedPropertyMethodSelector.cs
- StorageConditionPropertyMapping.cs
- AdRotator.cs
- CodeAccessSecurityEngine.cs
- UnsafeNativeMethods.cs
- InstanceContextMode.cs
- VersionedStream.cs
- XPathDocument.cs
- InfoCardSchemas.cs
- coordinatorscratchpad.cs
- IncrementalReadDecoders.cs
- DataGridViewColumnTypePicker.cs
- DropShadowEffect.cs
- UnicodeEncoding.cs
- DeploymentExceptionMapper.cs
- SynchronizationScope.cs
- RenderDataDrawingContext.cs
- PropVariant.cs
- SchemaMapping.cs
- ReadOnlyDataSourceView.cs
- CodeMemberField.cs
- ProxyWebPart.cs
- KeyBinding.cs
- KnownIds.cs
- SplashScreen.cs
- MarginCollapsingState.cs
- XmlTextReader.cs
- SmiConnection.cs
- AttributeAction.cs
- PropertyCondition.cs
- ImageButton.cs
- DataSourceCache.cs
- ControlBuilder.cs