// Creates an unzipped copy of the executable for the Stitch, and any other resource // allocation. Call StartInstance to start the instance public LocalCreateInstanceResponse CreateNewInstance(LocalCreateInstanceRequest request) { try { var response = new LocalCreateInstanceResponse(); if (request == null || !request.IsValid() || request.NumberOfInstances <= 0) { return(response.AsFailure()); } var packageFile = _data.Get <PackageFile>(request.GroupName.ToString()); if (packageFile == null) { return(response.AsFailure()); } for (int i = 0; i < request.NumberOfInstances; i++) { var instance = CreateSingleNewInstanceInternal(packageFile, request); if (instance != null) { response.CreatedIds.Add(instance.Id); } } response.IsSuccess = response.CreatedIds.Count == request.NumberOfInstances; return(response); } catch (Exception e) { _log.LogError(e, "Could not create new stitch instance"); return(null); } }