/// <summary> /// Initializes a new instance of the <see cref="TraceLinkBuilder{TLinkData}"/> class. /// </summary> /// <param name="cfg"> the config to instantiate the builder </param> public TraceLinkBuilder(TraceLinkBuilderConfig <TLinkData> cfg) : base( cfg.WorkflowId, (cfg.ParentLink != null ? cfg.ParentLink.TraceId() : Guid.NewGuid().ToString())) { // trace id is either retrieved from parent link when it is provided // or set to a new uuid. // set the parent link this.parentLink = (TraceLink <TLinkData>)cfg.ParentLink; // degree is always 1 base.WithDegree(1); // set priority to 1 by default // may be overriden if parent link was provided base.WithPriority(1); // set the created at timestamp this.metadata = new TraceLinkMetaData(); this.metadata.CreatedAt = DateTime.Now; // if parent link was provided set the parent hash and priority if (this.parentLink != null) { base.WithPriority(this.parentLink.Priority() + 1).WithParent(this.parentLink.Hash()); } }
/// <summary> /// Get the metadata as TraceLinkMetaData /// </summary> /// <returns></returns> new public TraceLinkMetaData Metadata() { TraceLinkMetaData traceLinkMd = JsonHelper.ObjectToObject <TraceLinkMetaData>(base.Metadata()); return(traceLinkMd); }