public bool TryAdd <T>(Guid instanceId, ActivityBuilder <T> ab)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         ActivityPersistenceHelper.SaveActivity(ab, stream);
         stream.Position = 0;
         return(InstanceDefinitions.TryAdd(instanceId, stream.ToArray()));
     }
 }
 public bool TryAdd(WorkflowIdentity definitionIdentity, Activity a)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         ActivityPersistenceHelper.SaveActivity(a, stream);
         stream.Position = 0;
         return(InstanceDefinitions.TryAdd(definitionIdentity, stream.ToArray()));
     }
 }