Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / OutArgument.cs / 1305376 / OutArgument.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Expressions; using System.Activities.Runtime; using System.Activities.XamlIntegration; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq.Expressions; using System.Runtime; using System.Windows.Markup; using System.Diagnostics.CodeAnalysis; public abstract class OutArgument : Argument { internal OutArgument() { this.Direction = ArgumentDirection.Out; } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Subclass needed to enforce rules about which directions can be referenced.")] public static OutArgument CreateReference(OutArgument argumentToReference, string referencedArgumentName) { if (argumentToReference == null) { throw FxTrace.Exception.ArgumentNull("argumentToReference"); } if (string.IsNullOrEmpty(referencedArgumentName)) { throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName"); } return (OutArgument)ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, ArgumentDirection.Out, referencedArgumentName); } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Subclass needed to enforce rules about which directions can be referenced.")] public static OutArgument CreateReference(InOutArgument argumentToReference, string referencedArgumentName) { if (argumentToReference == null) { throw FxTrace.Exception.ArgumentNull("argumentToReference"); } if (string.IsNullOrEmpty(referencedArgumentName)) { throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName"); } // Note that we explicitly pass Out since we want an OutArgument created return (OutArgument)ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, ArgumentDirection.Out, referencedArgumentName); } } [ContentProperty("Expression")] [TypeConverter(typeof(OutArgumentConverter))] [ValueSerializer(typeof(ArgumentValueSerializer))] public sealed class OutArgument: OutArgument { public OutArgument(Variable variable) : this() { if (variable != null) { this.Expression = new VariableReference { Variable = variable }; } } public OutArgument(DelegateArgument delegateArgument) : this() { if (delegateArgument != null) { this.Expression = new DelegateArgumentReference { DelegateArgument = delegateArgument }; } } public OutArgument(Expression > expression) : this() { if (expression != null) { this.Expression = new LambdaReference (expression); } } public OutArgument(Activity > expression) : this() { this.Expression = expression; } public OutArgument() : base() { this.ArgumentType = typeof(T); } [DefaultValue(null)] public new Activity > Expression { get; set; } internal override ActivityWithResult ExpressionCore { get { return this.Expression; } set { if (value == null) { this.Expression = null; return; } if (value is Activity >) { this.Expression = (Activity >)value; } else { // We do not verify compatibility here. We will do that // during CacheMetadata in Argument.Validate. this.Expression = new ActivityWithResultWrapper >(value); } } } public static implicit operator OutArgument (Variable variable) { return FromVariable(variable); } public static implicit operator OutArgument (DelegateArgument delegateArgument) { return FromDelegateArgument(delegateArgument); } public static implicit operator OutArgument (Activity > expression) { return FromExpression(expression); } public static OutArgument FromVariable(Variable variable) { if (variable == null) { throw FxTrace.Exception.ArgumentNull("variable"); } return new OutArgument (variable); } public static OutArgument FromDelegateArgument(DelegateArgument delegateArgument) { if (delegateArgument == null) { throw FxTrace.Exception.ArgumentNull("delegateArgument"); } return new OutArgument (delegateArgument); } public static OutArgument FromExpression(Activity > expression) { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } return new OutArgument (expression); } // Soft-Link: This method is referenced through reflection by // ExpressionUtilities.TryRewriteLambdaExpression. Update that // file if the signature changes. public new Location GetLocation(ActivityContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } ThrowIfNotInTree(); return context.GetLocation (this.RuntimeArgument); } // Soft-Link: This method is referenced through reflection by // ExpressionUtilities.TryRewriteLambdaExpression. Update that // file if the signature changes. public new T Get(ActivityContext context) { return Get (context); } public void Set(ActivityContext context, T value) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } ThrowIfNotInTree(); context.SetValue(this, value); } internal override Location CreateDefaultLocation() { return Argument.CreateLocation (); } internal override void Declare(LocationEnvironment targetEnvironment, ActivityInstance activityInstance) { targetEnvironment.DeclareTemporaryLocation >(this.RuntimeArgument, activityInstance, true); } internal override bool TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityContext resolutionContext) { Fx.Assert(this.Expression != null, "This should only be called for non-empty bindings."); Location argumentValue; if (this.Expression.TryGetValue(resolutionContext, out argumentValue)) { targetEnvironment.Declare(this.RuntimeArgument, argumentValue.CreateReference(true), targetActivityInstance); return true; } else { targetEnvironment.DeclareTemporaryLocation >(this.RuntimeArgument, targetActivityInstance, true); return false; } } } } // 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
- PropertyItem.cs
- Directory.cs
- PersonalizationAdministration.cs
- DownloadProgressEventArgs.cs
- X509CertificateCollection.cs
- ToolStripPanelSelectionBehavior.cs
- LambdaCompiler.Unary.cs
- TriggerBase.cs
- RangeBaseAutomationPeer.cs
- OuterGlowBitmapEffect.cs
- RegistryPermission.cs
- TableAdapterManagerHelper.cs
- MSG.cs
- BufferedWebEventProvider.cs
- AttributeCollection.cs
- Bidi.cs
- EndpointNotFoundException.cs
- WebServiceAttribute.cs
- DataGridViewMethods.cs
- FacetEnabledSchemaElement.cs
- XmlnsCompatibleWithAttribute.cs
- ReaderWriterLock.cs
- Baml2006ReaderFrame.cs
- Baml2006KeyRecord.cs
- StoragePropertyMapping.cs
- _AutoWebProxyScriptHelper.cs
- SynchronizationLockException.cs
- RSAPKCS1SignatureFormatter.cs
- Nullable.cs
- StrokeNodeEnumerator.cs
- DbConnectionClosed.cs
- WebPartCancelEventArgs.cs
- SqlServices.cs
- SpanIndex.cs
- LassoSelectionBehavior.cs
- PlainXmlDeserializer.cs
- ClusterSafeNativeMethods.cs
- SafeIUnknown.cs
- CreateInstanceBinder.cs
- ExternalException.cs
- Help.cs
- httpapplicationstate.cs
- TriggerActionCollection.cs
- DataPagerFieldCommandEventArgs.cs
- DnsPermission.cs
- SettingsSavedEventArgs.cs
- UndoEngine.cs
- PeerInvitationResponse.cs
- ToggleProviderWrapper.cs
- ClientFormsIdentity.cs
- PresentationAppDomainManager.cs
- Vector3DCollectionValueSerializer.cs
- TableLayoutPanelCellPosition.cs
- CreatingCookieEventArgs.cs
- ScriptMethodAttribute.cs
- ConstructorExpr.cs
- TransformerInfo.cs
- TextSchema.cs
- KeyEventArgs.cs
- DelegatingConfigHost.cs
- RectangleGeometry.cs
- TdsValueSetter.cs
- GenerateScriptTypeAttribute.cs
- StylusDevice.cs
- Currency.cs
- Rijndael.cs
- PerformanceCounterPermissionAttribute.cs
- HttpTransportManager.cs
- FixedBufferAttribute.cs
- CorrelationManager.cs
- AccessibleObject.cs
- Point3DKeyFrameCollection.cs
- CacheSection.cs
- TableRowCollection.cs
- ColorInterpolationModeValidation.cs
- BitmapMetadata.cs
- ProfileInfo.cs
- DescendantOverDescendantQuery.cs
- SqlUDTStorage.cs
- Query.cs
- TreeWalkHelper.cs
- SqlUnionizer.cs
- AuthenticationService.cs
- FontStretches.cs
- StyleModeStack.cs
- VideoDrawing.cs
- CultureInfoConverter.cs
- XamlPathDataSerializer.cs
- CalendarDateRangeChangingEventArgs.cs
- XmlNotation.cs
- DecimalStorage.cs
- TextBlockAutomationPeer.cs
- InstanceLockQueryResult.cs
- CollectionViewGroupRoot.cs
- validation.cs
- CompilationUnit.cs
- SelectionRange.cs
- SerialPort.cs
- SqlPersonalizationProvider.cs
- SslStream.cs