public static void CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, ref IList <ValidationError> validationErrors)
 {
     if (!ShouldShortcut(activity, options))
     {
         lock (activity.ThisLock)
         {
             if (!ShouldShortcut(activity, options))
             {
                 if (activity.HasBeenAssociatedWithAnInstance)
                 {
                     throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.RootActivityAlreadyAssociatedWithInstance(activity.DisplayName)));
                 }
                 activity.InitializeAsRoot(hostEnvironment);
                 ProcessActivityTreeCore(new ChildActivity(activity, true), null, options, callback, ref validationErrors);
                 if (!ActivityValidationServices.HasErrors(validationErrors) && options.IsRuntimeReadyOptions)
                 {
                     activity.SetRuntimeReady();
                 }
             }
         }
     }
 }