Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / AttachedProperty.cs / 1305376 / AttachedProperty.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Activities.Presentation.Model; using System.Runtime; using System.Diagnostics.CodeAnalysis; public abstract class AttachedProperty { Type ownerType = typeof(object); [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "By design.")] public abstract Type Type { get; } public abstract bool IsReadOnly { get; } public bool IsBrowsable { get; set; } public string Name { get; set; } public Type OwnerType { get { return this.ownerType; } set { this.ownerType = value; } } public abstract object GetValue(ModelItem modelItem); public abstract void SetValue(ModelItem modelItem, object value); public abstract void ResetValue(ModelItem modelItem); public void NotifyPropertyChanged(ModelItem modelItem) { if (null != modelItem) { ((IModelTreeItem)modelItem).OnPropertyChanged(this.Name); } } } public class AttachedProperty: AttachedProperty { [Fx.Tag.KnownXamlExternal] public Func Getter { get; set; } [Fx.Tag.KnownXamlExternal] public Action Setter { get; set; } public override Type Type { get { return typeof(T); } } public override bool IsReadOnly { get { return (this.Setter == null); } } public override object GetValue(ModelItem modelItem) { return this.Getter(modelItem); } public override void SetValue(ModelItem modelItem, object Value) { if (this.IsReadOnly) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.PropertyIsReadOnly)); } this.Setter(modelItem, (T)Value); this.NotifyPropertyChanged(modelItem); } public override void ResetValue(ModelItem modelItem) { SetValue(modelItem, default(T)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Activities.Presentation.Model; using System.Runtime; using System.Diagnostics.CodeAnalysis; public abstract class AttachedProperty { Type ownerType = typeof(object); [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "By design.")] public abstract Type Type { get; } public abstract bool IsReadOnly { get; } public bool IsBrowsable { get; set; } public string Name { get; set; } public Type OwnerType { get { return this.ownerType; } set { this.ownerType = value; } } public abstract object GetValue(ModelItem modelItem); public abstract void SetValue(ModelItem modelItem, object value); public abstract void ResetValue(ModelItem modelItem); public void NotifyPropertyChanged(ModelItem modelItem) { if (null != modelItem) { ((IModelTreeItem)modelItem).OnPropertyChanged(this.Name); } } } public class AttachedProperty : AttachedProperty { [Fx.Tag.KnownXamlExternal] public Func Getter { get; set; } [Fx.Tag.KnownXamlExternal] public Action Setter { get; set; } public override Type Type { get { return typeof(T); } } public override bool IsReadOnly { get { return (this.Setter == null); } } public override object GetValue(ModelItem modelItem) { return this.Getter(modelItem); } public override void SetValue(ModelItem modelItem, object Value) { if (this.IsReadOnly) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.PropertyIsReadOnly)); } this.Setter(modelItem, (T)Value); this.NotifyPropertyChanged(modelItem); } public override void ResetValue(ModelItem modelItem) { SetValue(modelItem, default(T)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientConfigurationHost.cs
- DataGridViewImageColumn.cs
- DependencySource.cs
- DataAdapter.cs
- LostFocusEventManager.cs
- CustomPeerResolverService.cs
- DataControlFieldsEditor.cs
- PopupEventArgs.cs
- HWStack.cs
- MetaChildrenColumn.cs
- InheritanceContextHelper.cs
- DocumentReference.cs
- KeyValueSerializer.cs
- SystemIPv6InterfaceProperties.cs
- ActiveDesignSurfaceEvent.cs
- XmlSchemaGroupRef.cs
- COM2PropertyDescriptor.cs
- IEnumerable.cs
- HttpProfileBase.cs
- ValueConversionAttribute.cs
- FeatureSupport.cs
- Image.cs
- SingleResultAttribute.cs
- GridViewCancelEditEventArgs.cs
- IdentityNotMappedException.cs
- MarkupCompilePass1.cs
- PolyBezierSegmentFigureLogic.cs
- BamlLocalizationDictionary.cs
- behaviorssection.cs
- AlphabeticalEnumConverter.cs
- PlatformCulture.cs
- AspProxy.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- NullableDecimalAverageAggregationOperator.cs
- StoragePropertyMapping.cs
- EasingQuaternionKeyFrame.cs
- XMLUtil.cs
- Substitution.cs
- SafeBitVector32.cs
- MetafileHeader.cs
- PkcsMisc.cs
- CompilerState.cs
- WindowsIPAddress.cs
- ThreadSafeList.cs
- DefaultCommandConverter.cs
- UnsafeNativeMethods.cs
- XmlIncludeAttribute.cs
- NeutralResourcesLanguageAttribute.cs
- RadioButton.cs
- Queue.cs
- AutomationEvent.cs
- Funcletizer.cs
- GridSplitterAutomationPeer.cs
- XmlSchemaAnnotated.cs
- SystemSounds.cs
- InfoCardPolicy.cs
- ContentValidator.cs
- WpfSharedXamlSchemaContext.cs
- NotifyCollectionChangedEventArgs.cs
- DataGridViewAutoSizeModeEventArgs.cs
- TripleDES.cs
- MenuCommands.cs
- PagedControl.cs
- EdmTypeAttribute.cs
- SerTrace.cs
- DataBinder.cs
- GroupBox.cs
- MouseWheelEventArgs.cs
- TileBrush.cs
- QilStrConcatenator.cs
- TransformPatternIdentifiers.cs
- FacetDescriptionElement.cs
- EDesignUtil.cs
- ModuleElement.cs
- EmbeddedMailObjectsCollection.cs
- MatrixTransform.cs
- CodeDomLoader.cs
- OleDbConnectionInternal.cs
- MarkupObject.cs
- DataControlField.cs
- TextLineResult.cs
- ServiceDescriptionImporter.cs
- _FtpDataStream.cs
- Literal.cs
- SiteMapNodeItem.cs
- EntityDesignerDataSourceView.cs
- Row.cs
- ClientRuntimeConfig.cs
- DrawingAttributesDefaultValueFactory.cs
- EngineSiteSapi.cs
- followingquery.cs
- SelectionPattern.cs
- IdentifierService.cs
- StringOutput.cs
- ChannelServices.cs
- TitleStyle.cs
- AnnotationResourceCollection.cs
- SerializationInfoEnumerator.cs
- ObfuscationAttribute.cs
- DeferredTextReference.cs