Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / InOutArgument.cs / 1305376 / InOutArgument.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Expressions; using System.Activities.XamlIntegration; using System.Activities.Runtime; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using System.Runtime; using System.Windows.Markup; public abstract class InOutArgument : Argument { internal InOutArgument() { this.Direction = ArgumentDirection.InOut; } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Subclass needed to enforce rules about which directions can be referenced.")] public static InOutArgument CreateReference(InOutArgument argumentToReference, string referencedArgumentName) { if (argumentToReference == null) { throw FxTrace.Exception.ArgumentNull("argumentToReference"); } if (string.IsNullOrEmpty(referencedArgumentName)) { throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName"); } return (InOutArgument)ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, ArgumentDirection.InOut, referencedArgumentName); } } [ContentProperty("Expression")] [TypeConverter(typeof(InOutArgumentConverter))] [ValueSerializer(typeof(ArgumentValueSerializer))] public sealed class InOutArgument: InOutArgument { public InOutArgument(Variable variable) : this() { if (variable != null) { this.Expression = new VariableReference { Variable = variable }; } } public InOutArgument(Variable variable) : this() { if (variable != null) { this.Expression = new VariableReference { Variable = variable }; } } public InOutArgument(Expression > expression) : this() { if (expression != null) { this.Expression = new LambdaReference (expression); } } public InOutArgument(Activity > expression) : this() { this.Expression = expression; } public InOutArgument() : 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; } Activity > typedActivity = value as Activity >; if (typedActivity != null) { this.Expression = typedActivity; } 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 InOutArgument (Variable variable) { return FromVariable(variable); } public static implicit operator InOutArgument (Activity > expression) { return FromExpression(expression); } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Generic needed for type inference")] public static InOutArgument FromVariable(Variable variable) { return new InOutArgument { Expression = new VariableReference { Variable = variable } }; } public static InOutArgument FromExpression(Activity > expression) { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } return new InOutArgument { Expression = 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, false); } 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(false), targetActivityInstance); return true; } else { targetEnvironment.DeclareTemporaryLocation >(this.RuntimeArgument, targetActivityInstance, false); 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
- DoubleAnimation.cs
- MetadataElement.cs
- ToolStripSettings.cs
- RegistryDataKey.cs
- NodeFunctions.cs
- COSERVERINFO.cs
- RuntimeConfig.cs
- EventLogQuery.cs
- EFTableProvider.cs
- WebBrowserSiteBase.cs
- RadialGradientBrush.cs
- DataGridViewEditingControlShowingEventArgs.cs
- AutoGeneratedField.cs
- SqlMethodCallConverter.cs
- PermissionRequestEvidence.cs
- RegexCompiler.cs
- ServiceDocumentFormatter.cs
- SizeAnimationClockResource.cs
- GatewayIPAddressInformationCollection.cs
- GroupBox.cs
- DocumentReferenceCollection.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- GroupedContextMenuStrip.cs
- EntityTemplateFactory.cs
- PointCollection.cs
- TemplateColumn.cs
- EmitterCache.cs
- SystemMulticastIPAddressInformation.cs
- RootDesignerSerializerAttribute.cs
- ListViewSelectEventArgs.cs
- Model3DGroup.cs
- VisualTarget.cs
- IisTraceWebEventProvider.cs
- TextRenderingModeValidation.cs
- PropertyTab.cs
- LoadItemsEventArgs.cs
- SmtpFailedRecipientsException.cs
- compensatingcollection.cs
- MemberMaps.cs
- DefaultValidator.cs
- DataStreams.cs
- StructuredTypeInfo.cs
- DataGridViewRowCancelEventArgs.cs
- ExpressionBindings.cs
- PrimarySelectionGlyph.cs
- VectorCollectionConverter.cs
- ErrorWrapper.cs
- Task.cs
- MultilineStringConverter.cs
- AncillaryOps.cs
- BufferAllocator.cs
- PageRanges.cs
- FileDialog_Vista_Interop.cs
- DataServiceRequestOfT.cs
- ColorIndependentAnimationStorage.cs
- ChannelManager.cs
- MDIWindowDialog.cs
- SafeNativeMethods.cs
- ControlBuilderAttribute.cs
- ActiveXMessageFormatter.cs
- PageBuildProvider.cs
- AudioSignalProblemOccurredEventArgs.cs
- ListCardsInFileRequest.cs
- FixedTextPointer.cs
- TypeForwardedToAttribute.cs
- WebServiceBindingAttribute.cs
- HMACSHA512.cs
- ItemsPresenter.cs
- XmlProcessingInstruction.cs
- BaseCollection.cs
- XmlSchemaSimpleContentExtension.cs
- ListBindingHelper.cs
- GZipDecoder.cs
- AuthenticationModuleElementCollection.cs
- ProgressBarRenderer.cs
- basemetadatamappingvisitor.cs
- CreateUserWizard.cs
- PreApplicationStartMethodAttribute.cs
- ViewSimplifier.cs
- Rfc2898DeriveBytes.cs
- HTTPNotFoundHandler.cs
- BindingList.cs
- WebPartTransformerAttribute.cs
- XmlWellformedWriter.cs
- DataControlReference.cs
- AppModelKnownContentFactory.cs
- SHA1CryptoServiceProvider.cs
- XmlBaseWriter.cs
- ToolStripScrollButton.cs
- TextStore.cs
- ScalarOps.cs
- HttpRawResponse.cs
- LayoutEvent.cs
- SQLDateTimeStorage.cs
- SafeLibraryHandle.cs
- HttpRuntime.cs
- RelationshipEnd.cs
- WebUtility.cs
- WriteFileContext.cs
- CatalogPart.cs