Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Location.cs / 1305376 / Location.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Runtime; using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; using System.Runtime; using System.Collections.Specialized; [DataContract] [DebuggerDisplay("{Value}")] public abstract class Location { [DataMember(EmitDefaultValue = false)] TemporaryResolutionData temporaryResolutionData; protected Location() { } public abstract Type LocationType { get; } public object Value { get { return this.ValueCore; } set { this.ValueCore = value; } } internal virtual bool CanBeMapped { get { return false; } } // When we are resolving an expression that resolves to a // reference to a location we need some way of notifying the // LocationEnvironment that it should extract the inner location // and throw away the outer one. OutArgument and InOutArgument // create these TemporaryResolutionLocations if their expression // resolution goes async and LocationEnvironment gets rid of them // in CollapseTemporaryResolutionLocations(). internal LocationEnvironment TemporaryResolutionEnvironment { get { return this.temporaryResolutionData.TemporaryResolutionEnvironment; } } internal bool BufferGetsOnCollapse { get { return this.temporaryResolutionData.BufferGetsOnCollapse; } } protected abstract object ValueCore { get; set; } internal void SetTemporaryResolutionData(LocationEnvironment resolutionEnvironment, bool bufferGetsOnCollapse) { this.temporaryResolutionData = new TemporaryResolutionData { TemporaryResolutionEnvironment = resolutionEnvironment, BufferGetsOnCollapse = bufferGetsOnCollapse }; } internal virtual Location CreateReference(bool bufferGets) { if (this.CanBeMapped || bufferGets) { return new ReferenceLocation(this, bufferGets); } return this; } internal virtual object CreateDefaultValue() { Fx.Assert("We should only call this on Location"); return null; } [DataContract] struct TemporaryResolutionData { [DataMember(EmitDefaultValue = false)] public LocationEnvironment TemporaryResolutionEnvironment { get; set; } [DataMember(EmitDefaultValue = false)] public bool BufferGetsOnCollapse { get; set; } } [DataContract] class ReferenceLocation : Location { [DataMember] Location innerLocation; [DataMember(EmitDefaultValue = false)] bool bufferGets; [DataMember(EmitDefaultValue = false)] object bufferedValue; public ReferenceLocation(Location innerLocation, bool bufferGets) { this.innerLocation = innerLocation; this.bufferGets = bufferGets; } public override Type LocationType { get { return this.innerLocation.LocationType; } } protected override object ValueCore { get { if (this.bufferGets) { return this.bufferedValue; } else { return this.innerLocation.Value; } } set { this.innerLocation.Value = value; this.bufferedValue = value; } } public override string ToString() { if (bufferGets) { return base.ToString(); } else { return this.innerLocation.ToString(); } } } } [DataContract] public class Location : Location { [DataMember(EmitDefaultValue = false)] T value; public Location() : base() { } public override Type LocationType { get { return typeof(T); } } public virtual new T Value { get { return this.value; } set { this.value = value; } } internal T TypedValue { get { return this.Value; } set { this.Value = value; } } protected override sealed object ValueCore { get { return this.Value; } set { this.Value = TypeHelper.Convert (value); } } internal override Location CreateReference(bool bufferGets) { if (this.CanBeMapped || bufferGets) { return new ReferenceLocation(this, bufferGets); } return this; } internal override object CreateDefaultValue() { Fx.Assert(typeof(T).GetGenericTypeDefinition() == typeof(Location<>), "We should only be calling this with location subclasses."); return Activator.CreateInstance (); } public override string ToString() { return this.value != null ? this.value.ToString() : " "; } [DataContract] class ReferenceLocation : Location { [DataMember] Location innerLocation; [DataMember(EmitDefaultValue = false)] bool bufferGets; public ReferenceLocation(Location innerLocation, bool bufferGets) { this.innerLocation = innerLocation; this.bufferGets = bufferGets; } public override T Value { get { if (this.bufferGets) { return this.value; } else { return this.innerLocation.Value; } } set { this.innerLocation.Value = value; if (this.bufferGets) { this.value = value; } } } public override string ToString() { if (this.bufferGets) { return base.ToString(); } else { return this.innerLocation.ToString(); } } } } } // 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
- SBCSCodePageEncoding.cs
- VBCodeProvider.cs
- GroupQuery.cs
- TextElementEditingBehaviorAttribute.cs
- SecurityTokenSerializer.cs
- DataSetUtil.cs
- OptimizedTemplateContentHelper.cs
- _SslSessionsCache.cs
- SymbolMethod.cs
- PolicyLevel.cs
- AllMembershipCondition.cs
- PermissionToken.cs
- HuffmanTree.cs
- DateTimePickerDesigner.cs
- RotateTransform3D.cs
- TabletDevice.cs
- Validator.cs
- SpotLight.cs
- RowToParametersTransformer.cs
- InProcStateClientManager.cs
- SecurityTokenException.cs
- GridViewSortEventArgs.cs
- StylusPointCollection.cs
- BitmapFrameDecode.cs
- GeneratedContractType.cs
- Profiler.cs
- TextFormatterHost.cs
- UnmanagedBitmapWrapper.cs
- EntityContainerEmitter.cs
- EventProviderBase.cs
- RtfControlWordInfo.cs
- HelpOperationInvoker.cs
- ColorMap.cs
- URI.cs
- ExtensionWindowHeader.cs
- FieldCollectionEditor.cs
- ButtonBaseAdapter.cs
- SerializationFieldInfo.cs
- Int64.cs
- Vector3D.cs
- updateconfighost.cs
- TypeName.cs
- ToolBar.cs
- BamlTreeNode.cs
- RadioButtonStandardAdapter.cs
- ExpressionBuilder.cs
- List.cs
- MimeMapping.cs
- ListSortDescriptionCollection.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- StandardBindingOptionalReliableSessionElement.cs
- User.cs
- CustomLineCap.cs
- SoapReflectionImporter.cs
- WebPartVerbCollection.cs
- TextDecorationLocationValidation.cs
- HtmlInputSubmit.cs
- PenThreadWorker.cs
- ApplicationId.cs
- Constants.cs
- InvalidDataException.cs
- HtmlFormWrapper.cs
- TagPrefixAttribute.cs
- DetailsViewPagerRow.cs
- ParameterCollection.cs
- PolicyValidationException.cs
- Touch.cs
- CookielessHelper.cs
- WebPartHeaderCloseVerb.cs
- DataTransferEventArgs.cs
- WebEncodingValidator.cs
- XmlAttributeCollection.cs
- EventSetter.cs
- WindowInteropHelper.cs
- HostingEnvironmentException.cs
- ManagementOptions.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- TextBounds.cs
- DatatypeImplementation.cs
- NativeCompoundFileAPIs.cs
- EasingKeyFrames.cs
- OdbcConnectionString.cs
- Property.cs
- xmlfixedPageInfo.cs
- ModelProperty.cs
- OptionalMessageQuery.cs
- RuntimeConfigurationRecord.cs
- SmtpFailedRecipientException.cs
- WebPartConnectionsCancelEventArgs.cs
- AxisAngleRotation3D.cs
- BinaryFormatterWriter.cs
- HttpStreams.cs
- EntityTypeEmitter.cs
- CodeArgumentReferenceExpression.cs
- PropertyItem.cs
- ToolStripDropDownClosedEventArgs.cs
- LookupBindingPropertiesAttribute.cs
- TemplatePropertyEntry.cs
- LinearKeyFrames.cs
- XamlSerializer.cs