public static Activity Resolve(Activity root, string id) { if (root == null) { throw FxTrace.Exception.ArgumentNull(nameof(root)); } if (string.IsNullOrEmpty(id)) { throw FxTrace.Exception.ArgumentNullOrEmpty(nameof(id)); } if (!root.IsMetadataCached) { IList <ValidationError> validationErrors = null; ActivityUtilities.CacheRootMetadata(root, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors); ActivityValidationServices.ThrowIfViolationsExist(validationErrors); } var parsedId = QualifiedId.Parse(id); if (!QualifiedId.TryGetElementFromRoot(root, parsedId, out var result)) { throw FxTrace.Exception.Argument(nameof(id), SR.IdNotFoundInWorkflow(id)); } return(result); }
public static Activity Resolve(Activity root, string id) { Activity activity; if (root == null) { throw FxTrace.Exception.ArgumentNull("root"); } if (string.IsNullOrEmpty(id)) { throw FxTrace.Exception.ArgumentNullOrEmpty("id"); } if (!root.IsMetadataCached) { IList <ValidationError> validationErrors = null; ActivityUtilities.CacheRootMetadata(root, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors); ActivityValidationServices.ThrowIfViolationsExist(validationErrors); } QualifiedId id2 = QualifiedId.Parse(id); if (!QualifiedId.TryGetElementFromRoot(root, id2, out activity)) { throw FxTrace.Exception.Argument("id", System.Activities.SR.IdNotFoundInWorkflow(id)); } return(activity); }