Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / CodeActivityMetadata.cs / 1305376 / CodeActivityMetadata.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Activities { using System; using System.Runtime; using System.Collections.ObjectModel; using System.Activities.Validation; public struct CodeActivityMetadata { Activity activity; LocationReferenceEnvironment environment; bool createEmptyBindings; internal CodeActivityMetadata(Activity activity, LocationReferenceEnvironment environment, bool createEmptyBindings) { this.activity = activity; this.environment = environment; this.createEmptyBindings = createEmptyBindings; } internal bool CreateEmptyBindings { get { return this.createEmptyBindings; } } public LocationReferenceEnvironment Environment { get { return this.environment; } } internal Activity CurrentActivity { get { return this.activity; } } public bool HasViolations { get { if (this.activity == null) { return false; } else { return this.activity.HasTempViolations; } } } public static bool operator ==(CodeActivityMetadata left, CodeActivityMetadata right) { return left.Equals(right); } public static bool operator !=(CodeActivityMetadata left, CodeActivityMetadata right) { return !left.Equals(right); } public override bool Equals(object obj) { if (!(obj is CodeActivityMetadata)) { return false; } CodeActivityMetadata other = (CodeActivityMetadata)obj; return other.activity == this.activity && other.Environment == this.Environment && other.CreateEmptyBindings == this.CreateEmptyBindings; } public override int GetHashCode() { if (this.activity == null) { return 0; } else { return this.activity.GetHashCode(); } } public void Bind(Argument binding, RuntimeArgument argument) { ThrowIfDisposed(); Argument.TryBind(binding, argument, this.activity); } internal bool TryGetInlinedLocationReference(LocationReference sourceReference, out LocationReference inlinedReference) { Fx.Assert(this.activity.SkipArgumentResolution, "We should only be calling this from activities which skip argument resolution."); ThrowIfDisposed(); if (this.Environment.IsVisible(sourceReference)) { CreateArgument(sourceReference); inlinedReference = new InlinedLocationReference(sourceReference, this.activity); return true; } inlinedReference = null; return false; } void CreateArgument(LocationReference sourceReference) { RuntimeArgument argument = new RuntimeArgument(NameGenerator.Next(), sourceReference.Type, ArgumentDirection.In); Argument inArgument = ActivityUtilities.CreateArgument(sourceReference.Type, ArgumentDirection.In); inArgument.Expression = ActivityUtilities.CreateLocationReferenceValue(sourceReference); Bind(inArgument, argument); this.activity.AddTempAutoGeneratedArgument(argument); } public void SetValidationErrorsCollection(CollectionvalidationErrors) { ThrowIfDisposed(); ActivityUtilities.RemoveNulls(validationErrors); this.activity.SetTempValidationErrorCollection(validationErrors); } public void AddValidationError(string validationErrorMessage) { AddValidationError(new ValidationError(validationErrorMessage)); } public void AddValidationError(ValidationError validationError) { ThrowIfDisposed(); if (validationError != null) { this.activity.AddTempValidationError(validationError); } } public void SetArgumentsCollection(Collection arguments) { ThrowIfDisposed(); ActivityUtilities.RemoveNulls(arguments); this.activity.SetArgumentsCollection(arguments, this.createEmptyBindings); } public void AddArgument(RuntimeArgument argument) { ThrowIfDisposed(); if (argument != null) { this.activity.AddArgument(argument, this.createEmptyBindings); } } public Collection GetArgumentsWithReflection() { return Activity.ReflectedInformation.GetArguments(this.activity); } public void AddDefaultExtensionProvider (Func extensionProvider) where T : class { if (extensionProvider == null) { throw FxTrace.Exception.ArgumentNull("extensionProvider"); } this.activity.AddDefaultExtensionProvider(extensionProvider); } public void RequireExtension () where T : class { this.activity.RequireExtension(typeof(T)); } public void RequireExtension(Type extensionType) { if (extensionType == null) { throw FxTrace.Exception.ArgumentNull("extensionType"); } if (extensionType.IsValueType) { throw FxTrace.Exception.Argument("extensionType", SR.RequireExtensionOnlyAcceptsReferenceTypes(extensionType.FullName)); } this.activity.RequireExtension(extensionType); } void ThrowIfDisposed() { if (this.activity == null) { throw FxTrace.Exception.AsError(new ObjectDisposedException(ToString())); } } internal void Dispose() { this.activity = null; } } } // 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
- FrameworkTemplate.cs
- MdImport.cs
- StringUtil.cs
- ToolStripItemImageRenderEventArgs.cs
- PropertyTabChangedEvent.cs
- SerializationUtilities.cs
- XmlDataSourceView.cs
- BaseTemplateCodeDomTreeGenerator.cs
- ActivationWorker.cs
- FixedSOMTableCell.cs
- __TransparentProxy.cs
- EnumerableRowCollectionExtensions.cs
- SelectionGlyph.cs
- ArrayItemValue.cs
- GridSplitter.cs
- TaskResultSetter.cs
- __FastResourceComparer.cs
- ToolStripPanelRow.cs
- ContextProperty.cs
- ColorIndependentAnimationStorage.cs
- HMACRIPEMD160.cs
- TypeUnloadedException.cs
- SizeConverter.cs
- PeerNameRecordCollection.cs
- SimpleNameService.cs
- WinEventHandler.cs
- DbgUtil.cs
- BaseCAMarshaler.cs
- ConnectionManagementElement.cs
- HttpCacheParams.cs
- AttachmentService.cs
- SimplePropertyEntry.cs
- DataGridViewColumnCollection.cs
- ConstantCheck.cs
- WebPartTracker.cs
- XmlSchemaRedefine.cs
- WpfKnownTypeInvoker.cs
- PageAdapter.cs
- TypeConverterHelper.cs
- ReaderWriterLockWrapper.cs
- CodeConstructor.cs
- MaskedTextBox.cs
- RegionData.cs
- WebHttpSecurity.cs
- UInt64Storage.cs
- Buffer.cs
- ListViewGroup.cs
- SuspendDesigner.cs
- FrameworkContentElementAutomationPeer.cs
- SerializationHelper.cs
- ImageProxy.cs
- CachedPathData.cs
- PartialCachingAttribute.cs
- EventHandlerList.cs
- FastEncoder.cs
- CollectionsUtil.cs
- ManagedFilter.cs
- WinInetCache.cs
- GridItemProviderWrapper.cs
- DateTimeUtil.cs
- TabControlToolboxItem.cs
- Facet.cs
- CodeTypeMemberCollection.cs
- GridViewCommandEventArgs.cs
- StatusBarAutomationPeer.cs
- ActivityExecutorSurrogate.cs
- DefaultIfEmptyQueryOperator.cs
- HScrollBar.cs
- HandlerBase.cs
- QuotedPairReader.cs
- loginstatus.cs
- BindingList.cs
- WarningException.cs
- TraceLevelStore.cs
- CodeRegionDirective.cs
- CodeAccessPermission.cs
- FileUpload.cs
- ProfileGroupSettings.cs
- ReadOnlyCollection.cs
- TextCollapsingProperties.cs
- CodeMethodInvokeExpression.cs
- GroupBox.cs
- ActivityExecutionFilter.cs
- AutomationPattern.cs
- RuntimeUtils.cs
- ErrorView.xaml.cs
- FormatSettings.cs
- TileBrush.cs
- FormsIdentity.cs
- StyleBamlTreeBuilder.cs
- HexParser.cs
- OdbcConnectionHandle.cs
- COM2PropertyDescriptor.cs
- SettingsProperty.cs
- OleDbCommandBuilder.cs
- DataGridViewTopLeftHeaderCell.cs
- _ProxyChain.cs
- SystemException.cs
- brushes.cs
- OuterGlowBitmapEffect.cs