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
- AccessViolationException.cs
- ConfigurationLoaderException.cs
- QilValidationVisitor.cs
- ReadOnlyHierarchicalDataSourceView.cs
- NetStream.cs
- HTTPNotFoundHandler.cs
- SiteMapNodeItem.cs
- SettingsProviderCollection.cs
- VisualBasicImportReference.cs
- localization.cs
- ConditionCollection.cs
- WebSysDescriptionAttribute.cs
- SHA384Managed.cs
- Relationship.cs
- VerifyHashRequest.cs
- WpfSharedXamlSchemaContext.cs
- CapabilitiesUse.cs
- XslNumber.cs
- VectorValueSerializer.cs
- GenericsNotImplementedException.cs
- DebuggerAttributes.cs
- Operand.cs
- PropertyItem.cs
- ZipIOFileItemStream.cs
- CompletedAsyncResult.cs
- DataGridViewAccessibleObject.cs
- Trace.cs
- ProfilePropertySettingsCollection.cs
- MaskedTextBoxTextEditor.cs
- FileDialog_Vista.cs
- BodyWriter.cs
- InternalTransaction.cs
- QilParameter.cs
- SoapTypeAttribute.cs
- TimeSpanStorage.cs
- TdsParameterSetter.cs
- SafeNativeMethods.cs
- ObjectCloneHelper.cs
- ReflectEventDescriptor.cs
- XPathNodePointer.cs
- EntityDataSourceWrapperCollection.cs
- DetailsViewRow.cs
- HtmlPageAdapter.cs
- MaskDesignerDialog.cs
- UnmanagedMemoryStream.cs
- SchemeSettingElement.cs
- SAPICategories.cs
- HierarchicalDataTemplate.cs
- HybridCollection.cs
- CatalogZoneBase.cs
- BatchParser.cs
- DrawingGroup.cs
- TextPatternIdentifiers.cs
- AbandonedMutexException.cs
- CertificateManager.cs
- CheckedListBox.cs
- EntityTypeBase.cs
- IdnElement.cs
- ColumnProvider.cs
- NativeMethodsCLR.cs
- BindingExpressionUncommonField.cs
- RectangleGeometry.cs
- UntrustedRecipientException.cs
- RtfNavigator.cs
- MimeObjectFactory.cs
- IsolatedStorageFilePermission.cs
- PriorityBinding.cs
- VirtualPath.cs
- EntityCodeGenerator.cs
- GridViewRowPresenterBase.cs
- Size3D.cs
- XmlSerializerSection.cs
- ToolStripItemEventArgs.cs
- ScriptingAuthenticationServiceSection.cs
- URLEditor.cs
- DataGridComponentEditor.cs
- ChannelServices.cs
- XmlSchemaGroupRef.cs
- ConfigurationSection.cs
- ProgressBar.cs
- ZipIOLocalFileBlock.cs
- UTF8Encoding.cs
- ACL.cs
- CheckBoxAutomationPeer.cs
- CodeDomDesignerLoader.cs
- SkewTransform.cs
- Dictionary.cs
- SegmentInfo.cs
- SQLInt64.cs
- XslAstAnalyzer.cs
- SiteMapPath.cs
- Array.cs
- OdbcDataReader.cs
- CSharpCodeProvider.cs
- CodeBlockBuilder.cs
- XmlSecureResolver.cs
- HttpCapabilitiesEvaluator.cs
- XamlStyleSerializer.cs
- WaveHeader.cs
- CustomWebEventKey.cs