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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewElement.cs
- EntityViewGenerator.cs
- CredentialCache.cs
- HScrollProperties.cs
- XmlEnumAttribute.cs
- DataTableMapping.cs
- CookieHandler.cs
- ThreadStateException.cs
- XmlNamespaceManager.cs
- RichTextBoxConstants.cs
- WebResourceUtil.cs
- TypeExtension.cs
- DataBinding.cs
- HttpRequestCacheValidator.cs
- StreamResourceInfo.cs
- DayRenderEvent.cs
- PageWrapper.cs
- CommandField.cs
- ProgressBarBrushConverter.cs
- KeyFrames.cs
- OleDbParameterCollection.cs
- KeyValuePairs.cs
- SystemWebSectionGroup.cs
- NumericUpDownAcceleration.cs
- ContentPosition.cs
- SecurityHelper.cs
- WebHttpElement.cs
- FixedDocument.cs
- DecimalKeyFrameCollection.cs
- DataSetUtil.cs
- PersonalizationDictionary.cs
- NativeMethods.cs
- RectangleHotSpot.cs
- DtdParser.cs
- ObjectConverter.cs
- GetKeyedHashRequest.cs
- Geometry3D.cs
- CodeAssignStatement.cs
- XmlCompatibilityReader.cs
- Thread.cs
- SoapInteropTypes.cs
- GridViewUpdateEventArgs.cs
- ParentUndoUnit.cs
- HelpKeywordAttribute.cs
- FtpWebResponse.cs
- UIPermission.cs
- XamlReader.cs
- Stacktrace.cs
- LoadGrammarCompletedEventArgs.cs
- CodeSubDirectory.cs
- FileNotFoundException.cs
- SmiGettersStream.cs
- WorkflowDefinitionDispenser.cs
- ListViewTableRow.cs
- LinqDataSourceSelectEventArgs.cs
- ObservableCollection.cs
- QueryPageSettingsEventArgs.cs
- Encoder.cs
- AliasExpr.cs
- GZipStream.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- XmlSchemaSimpleContent.cs
- ResourcePermissionBaseEntry.cs
- InstanceValue.cs
- columnmapkeybuilder.cs
- ParserHooks.cs
- GenericWebPart.cs
- CombinedGeometry.cs
- DictionaryItemsCollection.cs
- RelativeSource.cs
- SerializationObjectManager.cs
- DetailsViewInsertedEventArgs.cs
- EntityReference.cs
- BooleanExpr.cs
- MimeWriter.cs
- SqlNotificationEventArgs.cs
- TextTabProperties.cs
- ExtensionDataReader.cs
- HostedHttpContext.cs
- CallbackValidatorAttribute.cs
- TemplateControlBuildProvider.cs
- Pkcs9Attribute.cs
- OutputScopeManager.cs
- CharacterString.cs
- SafeUserTokenHandle.cs
- LineProperties.cs
- ScrollItemProviderWrapper.cs
- DataErrorValidationRule.cs
- GestureRecognitionResult.cs
- ReferenceEqualityComparer.cs
- OperatingSystem.cs
- XmlBindingWorker.cs
- AsymmetricKeyExchangeFormatter.cs
- safelink.cs
- AnnotationHighlightLayer.cs
- ListItemViewAttribute.cs
- RegexCapture.cs
- CancellableEnumerable.cs
- OdbcRowUpdatingEvent.cs
- ToolStripCodeDomSerializer.cs