Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / InArgument.cs / 1305376 / InArgument.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.ComponentModel; using System.Linq.Expressions; using System.Runtime; using System.Windows.Markup; using System.Diagnostics.CodeAnalysis; public abstract class InArgument : Argument { internal InArgument() : base() { this.Direction = ArgumentDirection.In; } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Subclass needed to enforce rules about which directions can be referenced.")] public static InArgument CreateReference(InArgument argumentToReference, string referencedArgumentName) { if (argumentToReference == null) { throw FxTrace.Exception.ArgumentNull("argumentToReference"); } if (string.IsNullOrEmpty(referencedArgumentName)) { throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName"); } return (InArgument)ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, ArgumentDirection.In, referencedArgumentName); } [SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, Justification = "Subclass needed to enforce rules about which directions can be referenced.")] public static InArgument 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 In since we want an InArgument created return (InArgument)ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, ArgumentDirection.In, referencedArgumentName); } } [ContentProperty("Expression")] [TypeConverter(typeof(InArgumentConverter))] [ValueSerializer(typeof(ArgumentValueSerializer))] public sealed class InArgument: InArgument { public InArgument(Variable variable) : this() { if (variable != null) { this.Expression = new VariableValue { Variable = variable }; } } public InArgument(DelegateArgument delegateArgument) : this() { if (delegateArgument != null) { this.Expression = new DelegateArgumentValue { DelegateArgument = delegateArgument }; } } public InArgument(T constValue) : this() { this.Expression = new Literal { Value = constValue }; } public InArgument(Expression > expression) : this() { if (expression != null) { this.Expression = new LambdaValue (expression); } } public InArgument(Activity expression) : this() { this.Expression = expression; } public InArgument() : 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 InArgument (Variable variable) { return FromVariable(variable); } public static implicit operator InArgument (DelegateArgument delegateArgument) { return FromDelegateArgument(delegateArgument); } public static implicit operator InArgument (Activity expression) { return FromExpression(expression); } public static implicit operator InArgument (T constValue) { return FromValue(constValue); } public static InArgument FromVariable(Variable variable) { if (variable == null) { throw FxTrace.Exception.ArgumentNull("variable"); } return new InArgument (variable); } public static InArgument FromDelegateArgument(DelegateArgument delegateArgument) { if (delegateArgument == null) { throw FxTrace.Exception.ArgumentNull("delegateArgument"); } return new InArgument (delegateArgument); } public static InArgument FromExpression(Activity expression) { if (expression == null) { throw FxTrace.Exception.ArgumentNull("expression"); } return new InArgument (expression); } public static InArgument FromValue(T constValue) { return new InArgument { Expression = new Literal { Value = constValue } }; } // 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"); } context.SetValue(this, value); } internal override Location CreateDefaultLocation() { return Argument.CreateLocation (); } internal override bool TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityContext resolutionContext) { Fx.Assert(this.Expression != null, "This should only be called for non-empty bindings"); Location location = Argument.CreateLocation (); targetEnvironment.Declare(this.RuntimeArgument, location, activityInstance); T argumentValue; if (this.Expression.TryGetValue(resolutionContext, out argumentValue)) { location.Value = argumentValue; return true; } else { return false; } } internal override void Declare(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance) { targetEnvironment.Declare(this.RuntimeArgument, CreateDefaultLocation(), targetActivityInstance); } } } // 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
- UnionExpr.cs
- SystemNetworkInterface.cs
- JoinTreeNode.cs
- PropertyChangingEventArgs.cs
- CustomErrorCollection.cs
- DataGridViewImageColumn.cs
- Page.cs
- PropertyMap.cs
- SqlCacheDependencySection.cs
- ArrayConverter.cs
- PerformanceCountersElement.cs
- UIInitializationException.cs
- ToolBarButtonClickEvent.cs
- AccessControlEntry.cs
- DateTimePicker.cs
- BaseTreeIterator.cs
- CreatingCookieEventArgs.cs
- DataGridRowHeaderAutomationPeer.cs
- HandlerFactoryWrapper.cs
- ContentTextAutomationPeer.cs
- TabItemWrapperAutomationPeer.cs
- SplineKeyFrames.cs
- GeometryValueSerializer.cs
- WindowsUpDown.cs
- HeaderUtility.cs
- ThicknessAnimationBase.cs
- Registry.cs
- ISessionStateStore.cs
- DelegateTypeInfo.cs
- DoubleLinkList.cs
- XmlSchemaFacet.cs
- XhtmlBasicFormAdapter.cs
- ErrorEventArgs.cs
- SelectionEditor.cs
- ResXBuildProvider.cs
- UniqueSet.cs
- ThicknessKeyFrameCollection.cs
- SettingsContext.cs
- HandlerFactoryWrapper.cs
- BitmapEffectInput.cs
- ButtonRenderer.cs
- PenThread.cs
- DesignTimeTemplateParser.cs
- WhitespaceRuleReader.cs
- ListControlConvertEventArgs.cs
- DataTableClearEvent.cs
- MouseGestureValueSerializer.cs
- XmlWrappingReader.cs
- counter.cs
- validation.cs
- XmlILOptimizerVisitor.cs
- PointConverter.cs
- MetaModel.cs
- ZipIOLocalFileBlock.cs
- SpeakCompletedEventArgs.cs
- WebPartCatalogAddVerb.cs
- InheritedPropertyChangedEventArgs.cs
- StreamResourceInfo.cs
- SafeLibraryHandle.cs
- SoapProtocolReflector.cs
- WinEventTracker.cs
- HttpPostServerProtocol.cs
- FilteredReadOnlyMetadataCollection.cs
- DataKey.cs
- Compress.cs
- Repeater.cs
- FileLevelControlBuilderAttribute.cs
- SqlReorderer.cs
- XamlStream.cs
- __Filters.cs
- CellParagraph.cs
- PhysicalFontFamily.cs
- StandardTransformFactory.cs
- ActivityDefaults.cs
- Part.cs
- AppearanceEditorPart.cs
- ZipIOExtraFieldZip64Element.cs
- XmlSchemaDocumentation.cs
- ErrorInfoXmlDocument.cs
- ProgressBarAutomationPeer.cs
- NamedPipeTransportSecurity.cs
- BulletedListEventArgs.cs
- FrameworkTextComposition.cs
- HandlerMappingMemo.cs
- PrimitiveSchema.cs
- DataView.cs
- SwitchLevelAttribute.cs
- HtmlUtf8RawTextWriter.cs
- CriticalExceptions.cs
- DataServiceSaveChangesEventArgs.cs
- KeyedHashAlgorithm.cs
- DataStreamFromComStream.cs
- TransformedBitmap.cs
- SecurityTokenReferenceStyle.cs
- ToolStripSplitButton.cs
- DocumentXPathNavigator.cs
- ReflectionHelper.cs
- DiscoveryClientOutputChannel.cs
- GenericPrincipal.cs
- DynamicPropertyReader.cs