Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / DesignBindingPropertyDescriptor.cs / 1 / DesignBindingPropertyDescriptor.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Design { using System; using System.ComponentModel; ////// /// internal class DesignBindingPropertyDescriptor : PropertyDescriptor { private static TypeConverter designBindingConverter = new DesignBindingConverter(); private PropertyDescriptor property; private bool readOnly; // base.AttributeArray ends up calling the virtual FillAttributes, but we do not override it, so we should be okay. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] internal DesignBindingPropertyDescriptor(PropertyDescriptor property, Attribute[] attrs, bool readOnly) : base(property.Name, attrs) { this.property = property; this.readOnly = readOnly; if (base.AttributeArray != null && base.AttributeArray.Length > 0) { Attribute[] newAttrs = new Attribute[AttributeArray.Length + 2]; AttributeArray.CopyTo(newAttrs, 0); newAttrs[AttributeArray.Length-1] = NotifyParentPropertyAttribute.Yes; newAttrs[AttributeArray.Length] = RefreshPropertiesAttribute.Repaint; base.AttributeArray = newAttrs; } else { base.AttributeArray = new Attribute[]{NotifyParentPropertyAttribute.Yes, RefreshPropertiesAttribute.Repaint}; } } ///Provides a property descriptor for design time data binding properties. ////// /// public override Type ComponentType { get { return typeof(ControlBindingsCollection); } } ///Gets or sets the type of the component that owns the property. ////// /// public override TypeConverter Converter { get { return designBindingConverter; } } ///Gets or sets the type converter. ////// /// public override bool IsReadOnly { get { return readOnly; } } ///Indicates whether the property is read-only. ////// /// public override Type PropertyType { get { return typeof(DesignBinding); } } ///Gets or sets the type of the property. ////// /// public override bool CanResetValue(object component) { return !GetBinding((ControlBindingsCollection)component, property).IsNull; } ///Gets a value indicating whether the specified component can reset the value /// of the property. ////// /// public override object GetValue(object component) { return GetBinding((ControlBindingsCollection)component, property); } ///Gets a value from the specified component. ////// /// public override void ResetValue(object component) { SetBinding((ControlBindingsCollection)component, property, DesignBinding.Null); } ///Resets the value of the specified component. ////// /// public override void SetValue(object component, object value) { SetBinding((ControlBindingsCollection)component, property, (DesignBinding)value); OnValueChanged(component, EventArgs.Empty); } ///Sets the specified value for the specified component. ////// /// public override bool ShouldSerializeValue(object component) { return false; } private static void SetBinding(ControlBindingsCollection bindings, PropertyDescriptor property, DesignBinding designBinding) { // this means it couldn't be parsed. if (designBinding == null) return; Binding listBinding = bindings[property.Name]; if (listBinding != null) { bindings.Remove(listBinding); } if (!designBinding.IsNull) { bindings.Add(property.Name, designBinding.DataSource, designBinding.DataMember); } } private static DesignBinding GetBinding(ControlBindingsCollection bindings, PropertyDescriptor property) { Binding listBinding = bindings[property.Name]; if (listBinding == null) return DesignBinding.Null; else return new DesignBinding(listBinding.DataSource, listBinding.BindingMemberInfo.BindingMember); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.Indicates whether the specified component should persist the value. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PaperSource.cs
- ConfigViewGenerator.cs
- WorkflowInlining.cs
- AppDomainUnloadedException.cs
- AppDomainEvidenceFactory.cs
- WarningException.cs
- ProcessThreadCollection.cs
- BooleanStorage.cs
- EncryptedKeyIdentifierClause.cs
- BackgroundFormatInfo.cs
- EntityContainerEmitter.cs
- EmulateRecognizeCompletedEventArgs.cs
- ThreadAbortException.cs
- SpellerError.cs
- DataServiceBehavior.cs
- DataControlFieldHeaderCell.cs
- XmlBoundElement.cs
- TypeToStringValueConverter.cs
- DoWorkEventArgs.cs
- ArrayConverter.cs
- XmlUrlEditor.cs
- MessageRpc.cs
- SoapDocumentServiceAttribute.cs
- Unit.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- ItemMap.cs
- PersistenceParticipant.cs
- documentsequencetextview.cs
- HijriCalendar.cs
- FrameworkElement.cs
- WebPartRestoreVerb.cs
- DiscriminatorMap.cs
- XmlNullResolver.cs
- EntityDataSourceChangingEventArgs.cs
- XmlExceptionHelper.cs
- UnsafeNativeMethods.cs
- Vector3D.cs
- FreezableDefaultValueFactory.cs
- X509Certificate.cs
- InternalDispatchObject.cs
- TreeView.cs
- ComEventsSink.cs
- InvalidDataException.cs
- AccessDataSourceWizardForm.cs
- RegisteredDisposeScript.cs
- DataSourceSelectArguments.cs
- Tablet.cs
- XamlSerializerUtil.cs
- RoutedPropertyChangedEventArgs.cs
- ToolBarOverflowPanel.cs
- ObjectDataSourceSelectingEventArgs.cs
- NamedPipeTransportSecurityElement.cs
- IUnknownConstantAttribute.cs
- GuidConverter.cs
- DataGridViewRowPostPaintEventArgs.cs
- FixedSOMPageElement.cs
- TableLayoutCellPaintEventArgs.cs
- TdsParserHelperClasses.cs
- PeerName.cs
- DirectoryInfo.cs
- PersistenceTypeAttribute.cs
- ConnectionManagementSection.cs
- ConversionContext.cs
- OptimalBreakSession.cs
- BaseInfoTable.cs
- DriveInfo.cs
- Calendar.cs
- Point3DCollectionValueSerializer.cs
- MappingItemCollection.cs
- TypeSystemProvider.cs
- NullableDecimalAverageAggregationOperator.cs
- XmlSchemaDatatype.cs
- HwndHostAutomationPeer.cs
- GeneratedContractType.cs
- ScalarConstant.cs
- ToolStripDropDownItem.cs
- ClusterSafeNativeMethods.cs
- EntityDescriptor.cs
- SimpleBitVector32.cs
- KeyedPriorityQueue.cs
- OdbcFactory.cs
- CultureInfoConverter.cs
- GridViewDeleteEventArgs.cs
- FileUtil.cs
- ManagedWndProcTracker.cs
- ReferencedAssembly.cs
- LogEntryHeaderDeserializer.cs
- FigureParagraph.cs
- Select.cs
- ThicknessAnimationUsingKeyFrames.cs
- RangeBaseAutomationPeer.cs
- StringUtil.cs
- SamlConstants.cs
- SafeRightsManagementHandle.cs
- XmlSchemaObjectTable.cs
- EventManager.cs
- TableColumnCollectionInternal.cs
- MergePropertyDescriptor.cs
- DrawingServices.cs
- UrlMapping.cs