Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Bookmark.cs / 1305376 / Bookmark.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities { using System; using System.Activities.Hosting; using System.Activities.Runtime; using System.Collections.Generic; using System.Runtime; using System.Runtime.Serialization; using System.Globalization; [DataContract] [Fx.Tag.XamlVisible(false)] public class Bookmark : IEquatable{ static Bookmark asyncOperationCompletionBookmark = new Bookmark(-1); static IEqualityComparer comparer; //Used only when exclusive scopes are involved [DataMember(EmitDefaultValue = false, Order = 2)] ExclusiveHandleList exclusiveHandlesThatReferenceThis; [DataMember(EmitDefaultValue = false, Order = 0)] long id; [DataMember(EmitDefaultValue = false, Order = 1)] string externalName; Bookmark(long id) { Fx.Assert(id != 0, "id should not be zero"); this.id = id; } public Bookmark(string name) { if (string.IsNullOrEmpty(name)) { throw FxTrace.Exception.ArgumentNullOrEmpty("name"); } this.externalName = name; } internal static Bookmark AsyncOperationCompletionBookmark { get { return asyncOperationCompletionBookmark; } } internal static IEqualityComparer Comparer { get { if (comparer == null) { comparer = new BookmarkComparer(); } return comparer; } } [DataMember(EmitDefaultValue = false)] internal BookmarkScope Scope { get; set; } internal bool IsNamed { get { return this.id == 0; } } public string Name { get { if (this.IsNamed) { return this.externalName; } else { return string.Empty; } } } internal long Id { get { Fx.Assert(!this.IsNamed, "We should only get the id for unnamed bookmarks."); return this.id; } } internal ExclusiveHandleList ExclusiveHandles { get { return this.exclusiveHandlesThatReferenceThis; } set { this.exclusiveHandlesThatReferenceThis = value; } } internal static Bookmark Create(long id) { return new Bookmark(id); } internal BookmarkInfo GenerateBookmarkInfo(BookmarkCallbackWrapper bookmarkCallback) { Fx.Assert(this.IsNamed, "Can only generate BookmarkInfo for external bookmarks"); BookmarkScopeInfo scopeInfo = null; if (this.Scope != null) { scopeInfo = this.Scope.GenerateScopeInfo(); } return new BookmarkInfo(this.externalName, bookmarkCallback.ActivityInstance.Activity.DisplayName, scopeInfo); } public bool Equals(Bookmark other) { if (object.ReferenceEquals(other, null)) { return false; } if (this.IsNamed) { return other.IsNamed && this.externalName == other.externalName; } else { return this.id == other.id; } } public override bool Equals(object obj) { return this.Equals(obj as Bookmark); } public override int GetHashCode() { if (this.IsNamed) { return this.externalName.GetHashCode(); } else { return this.id.GetHashCode(); } } public override string ToString() { if (this.IsNamed) { return this.Name; } else { return this.Id.ToString(CultureInfo.InvariantCulture); } } [DataContract] class BookmarkComparer : IEqualityComparer { public BookmarkComparer() { } public bool Equals(Bookmark x, Bookmark y) { if (object.ReferenceEquals(x, null)) { return object.ReferenceEquals(y, null); } return x.Equals(y); } public int GetHashCode(Bookmark obj) { return obj.GetHashCode(); } } } } // 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
- SafeRightsManagementSessionHandle.cs
- ProfilePropertyMetadata.cs
- HtmlInputImage.cs
- FixedSOMPage.cs
- CellIdBoolean.cs
- ThreadExceptionDialog.cs
- BlobPersonalizationState.cs
- DataObjectFieldAttribute.cs
- ConfigurationLocation.cs
- SubclassTypeValidator.cs
- ServiceDesigner.cs
- glyphs.cs
- XPathMultyIterator.cs
- TypefaceMetricsCache.cs
- ServiceDebugBehavior.cs
- NotifyParentPropertyAttribute.cs
- Rotation3DAnimation.cs
- LogArchiveSnapshot.cs
- CodeNamespaceCollection.cs
- QuaternionConverter.cs
- Compiler.cs
- DeclarativeCatalogPart.cs
- StructuredTypeEmitter.cs
- XmlILOptimizerVisitor.cs
- TargetControlTypeAttribute.cs
- SmtpFailedRecipientsException.cs
- DoubleAnimationUsingKeyFrames.cs
- ProcessModelInfo.cs
- HttpInputStream.cs
- ScriptingScriptResourceHandlerSection.cs
- CategoryNameCollection.cs
- HandlerMappingMemo.cs
- ScrollItemPattern.cs
- HyperLinkStyle.cs
- validationstate.cs
- KoreanCalendar.cs
- ErasingStroke.cs
- Rijndael.cs
- RemotingSurrogateSelector.cs
- MethodExpression.cs
- Span.cs
- HttpModuleCollection.cs
- SimpleWebHandlerParser.cs
- XamlRtfConverter.cs
- ThreadSafeList.cs
- GeometryDrawing.cs
- ToolBarButtonClickEvent.cs
- OracleFactory.cs
- MetadataArtifactLoader.cs
- PropertyReferenceSerializer.cs
- TreeNodeEventArgs.cs
- SqlInternalConnectionTds.cs
- SudsParser.cs
- Journal.cs
- SplitterEvent.cs
- ResourcesGenerator.cs
- NameGenerator.cs
- SqlMethods.cs
- NetPipeSectionData.cs
- CqlLexer.cs
- TemplateControlParser.cs
- ReflectionServiceProvider.cs
- InstanceDataCollectionCollection.cs
- AudioDeviceOut.cs
- MdiWindowListStrip.cs
- Size.cs
- CreateUserWizard.cs
- CompatibleIComparer.cs
- HtmlTableCellCollection.cs
- ViewGenResults.cs
- UnicastIPAddressInformationCollection.cs
- IndentedWriter.cs
- SqlCacheDependency.cs
- SectionInformation.cs
- GradientSpreadMethodValidation.cs
- XmlDataSourceNodeDescriptor.cs
- VisualProxy.cs
- CroppedBitmap.cs
- FieldAccessException.cs
- DoubleCollection.cs
- IISUnsafeMethods.cs
- TextSerializer.cs
- ApplyImportsAction.cs
- AttributeSetAction.cs
- UrlPropertyAttribute.cs
- AssemblyNameUtility.cs
- TimeSpanMinutesConverter.cs
- XPathArrayIterator.cs
- TerminateWorkflow.cs
- FixedDocumentSequencePaginator.cs
- DeadCharTextComposition.cs
- DataContractSet.cs
- MatrixTransform.cs
- HostSecurityManager.cs
- WebPartRestoreVerb.cs
- ProviderBase.cs
- GregorianCalendarHelper.cs
- UrlPath.cs
- DataBindingHandlerAttribute.cs
- XomlCompilerError.cs