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
- CancelEventArgs.cs
- StrokeIntersection.cs
- ResourceDescriptionAttribute.cs
- SQLSingle.cs
- ComponentManagerBroker.cs
- FileDialog_Vista.cs
- AutoGeneratedFieldProperties.cs
- ThemeConfigurationDialog.cs
- AbandonedMutexException.cs
- MD5Cng.cs
- SqlGenerator.cs
- StickyNoteHelper.cs
- CryptoConfig.cs
- SiteMapNodeItem.cs
- ExpressionNode.cs
- DesigntimeLicenseContextSerializer.cs
- DesignerTransactionCloseEvent.cs
- OfTypeExpression.cs
- EdmComplexPropertyAttribute.cs
- Normalization.cs
- PopupEventArgs.cs
- WebPartEditorOkVerb.cs
- SymmetricKeyWrap.cs
- ErrorHandler.cs
- TemplateBuilder.cs
- Mapping.cs
- Speller.cs
- DataServiceHostFactory.cs
- ControlIdConverter.cs
- TextParagraphProperties.cs
- ClientType.cs
- StylusPointPropertyInfoDefaults.cs
- SourceFileBuildProvider.cs
- CultureTableRecord.cs
- RoleManagerModule.cs
- FloaterBaseParagraph.cs
- FormViewRow.cs
- TextTreeTextBlock.cs
- SafeReversePInvokeHandle.cs
- UserControl.cs
- LeaseManager.cs
- FontCacheUtil.cs
- ZoneButton.cs
- CodeArrayCreateExpression.cs
- UnaryNode.cs
- AmbiguousMatchException.cs
- ApplicationBuildProvider.cs
- infer.cs
- embossbitmapeffect.cs
- ReadOnlyDictionary.cs
- AudioLevelUpdatedEventArgs.cs
- StatusBarPanelClickEvent.cs
- SoapWriter.cs
- BufferedGraphics.cs
- NavigationEventArgs.cs
- BindingsCollection.cs
- CodeParameterDeclarationExpressionCollection.cs
- MembershipUser.cs
- EmptyCollection.cs
- NameValueSectionHandler.cs
- ClientScriptManager.cs
- PageWrapper.cs
- Terminate.cs
- WorkflowItemsPresenter.cs
- XmlAggregates.cs
- DeobfuscatingStream.cs
- RawUIStateInputReport.cs
- CodeTypeReference.cs
- CultureSpecificStringDictionary.cs
- ToolStripMenuItem.cs
- OdbcRowUpdatingEvent.cs
- CrossContextChannel.cs
- MaterialGroup.cs
- returneventsaver.cs
- ProxyHwnd.cs
- LinqDataSource.cs
- ReceiveCompletedEventArgs.cs
- XmlMessageFormatter.cs
- AttachmentService.cs
- RelationshipConverter.cs
- XappLauncher.cs
- AppSecurityManager.cs
- Polyline.cs
- BrushValueSerializer.cs
- TextSelection.cs
- FrameworkTextComposition.cs
- FormattedTextSymbols.cs
- ToolStripProgressBar.cs
- TokenDescriptor.cs
- AddInStore.cs
- iisPickupDirectory.cs
- Style.cs
- ClientBuildManager.cs
- PageParserFilter.cs
- ConfigurationConverterBase.cs
- SelectedDatesCollection.cs
- AppDomain.cs
- COM2ColorConverter.cs
- PartDesigner.cs
- CommentAction.cs