Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Argument.cs / 1305376 / Argument.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Runtime; using System.Activities.Validation; using System.Activities.XamlIntegration; using System.Collections.Generic; using System.ComponentModel; using System.Runtime; using System.Runtime.Serialization; using System.Windows.Markup; public abstract class Argument { public static readonly int UnspecifiedEvaluationOrder = -1; public const string ResultValue = "Result"; ArgumentDirection direction; RuntimeArgument runtimeArgument; int evaluationOrder; internal Argument() { this.evaluationOrder = Argument.UnspecifiedEvaluationOrder; } public Type ArgumentType { get; internal set; } public ArgumentDirection Direction { get { return this.direction; } internal set { ArgumentDirectionHelper.Validate(value, "value"); this.direction = value; } } [DefaultValue(-1)] public int EvaluationOrder { get { return this.evaluationOrder; } set { if (value < 0 && value != Argument.UnspecifiedEvaluationOrder) { throw FxTrace.Exception.ArgumentOutOfRange("EvaluationOrder", value, SR.InvalidEvaluationOrderValue); } this.evaluationOrder = value; } } [IgnoreDataMember] // this member is repeated by all subclasses, which we control [DefaultValue(null)] public ActivityWithResult Expression { get { return this.ExpressionCore; } set { this.ExpressionCore = value; } } internal abstract ActivityWithResult ExpressionCore { get; set; } internal RuntimeArgument RuntimeArgument { get { return this.runtimeArgument; } set { this.runtimeArgument = value; } } internal bool IsInTree { get { return (this.runtimeArgument != null && this.runtimeArgument.IsInTree); } } internal bool WasDesignTimeNull { get; set; } internal int Id { get { Fx.Assert(this.runtimeArgument != null, "We shouldn't call Id unless we have a runtime argument."); return this.runtimeArgument.Id; } } internal bool IsEmpty { get { return this.Expression == null; } } public static Argument CreateReference(Argument argumentToReference, string referencedArgumentName) { if (argumentToReference == null) { throw FxTrace.Exception.ArgumentNull("argumentToReference"); } if (string.IsNullOrEmpty(referencedArgumentName)) { throw FxTrace.Exception.ArgumentNullOrEmpty("referencedArgumentName"); } return ActivityUtilities.CreateReferenceArgument(argumentToReference.ArgumentType, argumentToReference.Direction, referencedArgumentName); } // for ArgumentValueSerializer internal bool CanConvertToString(IValueSerializerContext context) { if (this.WasDesignTimeNull) { return true; } else { if (this.EvaluationOrder == Argument.UnspecifiedEvaluationOrder) { return ActivityWithResultValueSerializer.CanConvertToStringWrapper(this.Expression, context); } else { return false; } } } internal string ConvertToString(IValueSerializerContext context) { if (this.WasDesignTimeNull) { // this argument instance was artificially created by the runtime // to Xaml, this should appear as {x:Null} return null; } return ActivityWithResultValueSerializer.ConvertToStringWrapper(this.Expression, context); } internal static void Bind(Argument binding, RuntimeArgument argument) { if (binding != null) { Fx.Assert(binding.Direction == argument.Direction, "The directions must match."); Fx.Assert(binding.ArgumentType == argument.Type, "The types must match."); binding.RuntimeArgument = argument; } argument.BoundArgument = binding; } internal static void TryBind(Argument binding, RuntimeArgument argument, Activity violationOwner) { if (argument == null) { throw FxTrace.Exception.ArgumentNull("argument"); } bool passedValidations = true; if (binding != null) { if (binding.Direction != argument.Direction) { violationOwner.AddTempValidationError(new ValidationError(SR.ArgumentDirectionMismatch(argument.Name, argument.Direction, binding.Direction))); passedValidations = false; } if (binding.ArgumentType != argument.Type) { violationOwner.AddTempValidationError(new ValidationError(SR.ArgumentTypeMismatch(argument.Name, argument.Type, binding.ArgumentType))); passedValidations = false; } } if (passedValidations) { Bind(binding, argument); } } public static Argument Create(Type type, ArgumentDirection direction) { return ActivityUtilities.CreateArgument(type, direction); } internal abstract Location CreateDefaultLocation(); internal abstract void Declare(LocationEnvironment targetEnvironment, ActivityInstance activityInstance); // Soft-Link: This method is referenced through reflection by // ExpressionUtilities.TryRewriteLambdaExpression. Update that // file if the signature changes. public object Get(ActivityContext context) { return Get
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PostBackOptions.cs
- RC2CryptoServiceProvider.cs
- Timer.cs
- ChildTable.cs
- StrokeDescriptor.cs
- XmlSigningNodeWriter.cs
- QuerySettings.cs
- COAUTHINFO.cs
- EdmToObjectNamespaceMap.cs
- ExternalCalls.cs
- SqlDataSource.cs
- InteropBitmapSource.cs
- PriorityItem.cs
- XPathSelfQuery.cs
- BamlLocalizableResource.cs
- MimeMapping.cs
- SqlRecordBuffer.cs
- Size3DValueSerializer.cs
- XmlImplementation.cs
- XmlNamespaceMappingCollection.cs
- SqlParameterCollection.cs
- WebPartManager.cs
- DataKey.cs
- MouseActionValueSerializer.cs
- AsyncStreamReader.cs
- LinqDataSourceContextEventArgs.cs
- XPathMultyIterator.cs
- RankException.cs
- SemaphoreFullException.cs
- XslTransform.cs
- EncryptedPackage.cs
- ConnectionStringsExpressionEditor.cs
- CollectionChangedEventManager.cs
- AppSettingsReader.cs
- GroupBoxAutomationPeer.cs
- SmtpNegotiateAuthenticationModule.cs
- PaginationProgressEventArgs.cs
- DrawingContextWalker.cs
- DictationGrammar.cs
- TransportContext.cs
- ResourcePart.cs
- BlurBitmapEffect.cs
- TransformedBitmap.cs
- DbConnectionPoolCounters.cs
- Mouse.cs
- TempFiles.cs
- Unit.cs
- BeginStoryboard.cs
- _SslState.cs
- TabControlDesigner.cs
- SiteMapNode.cs
- HtmlAnchor.cs
- Blend.cs
- InternalBase.cs
- NetWebProxyFinder.cs
- ScrollItemPatternIdentifiers.cs
- GeometryHitTestParameters.cs
- TdsParserSafeHandles.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- Errors.cs
- TextServicesDisplayAttributePropertyRanges.cs
- VisualBasicSettings.cs
- ToolStripGripRenderEventArgs.cs
- Tablet.cs
- WeakReferenceList.cs
- DoubleLink.cs
- Attribute.cs
- IsolatedStorageFileStream.cs
- CellParagraph.cs
- Variable.cs
- SafeThemeHandle.cs
- DbXmlEnabledProviderManifest.cs
- XamlToRtfParser.cs
- MexBindingBindingCollectionElement.cs
- X509CertificateTokenFactoryCredential.cs
- DriveInfo.cs
- ReachFixedDocumentSerializerAsync.cs
- Button.cs
- UnsafeNativeMethods.cs
- ResourcePart.cs
- Selector.cs
- ScaleTransform.cs
- PermissionListSet.cs
- UIAgentCrashedException.cs
- WebServicesSection.cs
- LockedAssemblyCache.cs
- FileClassifier.cs
- AvTraceDetails.cs
- Model3DCollection.cs
- TransformedBitmap.cs
- ImportContext.cs
- Binding.cs
- FileVersionInfo.cs
- HtmlMobileTextWriter.cs
- GridEntryCollection.cs
- DataControlImageButton.cs
- DispatcherObject.cs
- XXXInfos.cs
- TrackingQuery.cs
- RightNameExpirationInfoPair.cs