Code:
/ 4.0 / 4.0 / 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. 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
- ToolStripMenuItem.cs
- SymDocumentType.cs
- DataGridViewCheckBoxColumn.cs
- ProcessHost.cs
- NotificationContext.cs
- ConfigurationConverterBase.cs
- ServerType.cs
- CrossAppDomainChannel.cs
- DesignerDataParameter.cs
- WebEventTraceProvider.cs
- RandomNumberGenerator.cs
- GeometryCollection.cs
- SerializableAttribute.cs
- MultiPageTextView.cs
- Stylesheet.cs
- DES.cs
- MeshGeometry3D.cs
- XMLSyntaxException.cs
- StretchValidation.cs
- CodeAttributeArgument.cs
- SchemaNotation.cs
- SignedXml.cs
- WebSysDisplayNameAttribute.cs
- FocusTracker.cs
- Rotation3DAnimationBase.cs
- ExpressionVisitor.cs
- OperationContext.cs
- SortQueryOperator.cs
- FieldMetadata.cs
- DataGridViewButtonCell.cs
- SimpleWebHandlerParser.cs
- PixelFormatConverter.cs
- Int16Animation.cs
- Stroke2.cs
- SoapAttributeOverrides.cs
- UITypeEditor.cs
- Span.cs
- ZipIOExtraFieldElement.cs
- DataPagerFieldCollection.cs
- RemotingServices.cs
- Pair.cs
- webclient.cs
- DataContractAttribute.cs
- CodePrimitiveExpression.cs
- ConfigurationManagerHelper.cs
- TypeDescriptionProvider.cs
- CodeGenHelper.cs
- SearchForVirtualItemEventArgs.cs
- Rect.cs
- SubclassTypeValidatorAttribute.cs
- XmlCompatibilityReader.cs
- BitmapEffectInputData.cs
- CodeLabeledStatement.cs
- BitmapFrameEncode.cs
- SqlMethodAttribute.cs
- DataSet.cs
- UndoEngine.cs
- MobileFormsAuthentication.cs
- DrawingAttributesDefaultValueFactory.cs
- ContextStack.cs
- FreeFormDesigner.cs
- XmlSchemaComplexContent.cs
- TextEffect.cs
- WmlLiteralTextAdapter.cs
- TemplateField.cs
- SystemBrushes.cs
- XmlSequenceWriter.cs
- SuppressedPackageProperties.cs
- NativeMethodsOther.cs
- Marshal.cs
- URIFormatException.cs
- TitleStyle.cs
- MailAddress.cs
- SQLRoleProvider.cs
- XmlBoundElement.cs
- MsmqDiagnostics.cs
- CatalogZoneBase.cs
- XmlArrayItemAttributes.cs
- SystemIcmpV4Statistics.cs
- PositiveTimeSpanValidator.cs
- EventItfInfo.cs
- WorkflowDebuggerSteppingAttribute.cs
- RangeBaseAutomationPeer.cs
- InternalDuplexBindingElement.cs
- SelectionRangeConverter.cs
- PageParserFilter.cs
- _TimerThread.cs
- ColumnMapProcessor.cs
- DecimalConstantAttribute.cs
- XmlNodeWriter.cs
- BrushValueSerializer.cs
- CodeSubDirectoriesCollection.cs
- XmlSchemaObjectTable.cs
- StaticFileHandler.cs
- ClientFormsIdentity.cs
- ListViewGroupItemCollection.cs
- EnterpriseServicesHelper.cs
- InternalCache.cs
- Renderer.cs
- HMACMD5.cs