public InstanceActionResult Start(PackageFile packageFile, StitchInstance stitchInstance)
        {
            if (string.IsNullOrEmpty(stitchInstance?.Id))
            {
                return(InstanceActionResult.BadRequest());
            }

            string         instanceId = stitchInstance.Id;
            IStitchAdaptor adaptor    = null;

            try
            {
                stitchInstance.State = InstanceStateType.Stopped;
                adaptor = GetOrCreateStitchAdaptor(packageFile, stitchInstance);
                if (adaptor == null)
                {
                    stitchInstance.State = InstanceStateType.Missing;
                    return(InstanceActionResult.NotFound(instanceId));
                }

                // TODO: On Stitch start, we should send it information about the application topology
                // TODO: We should also send application topology change notifications to every Stitch
                // involved in the affected application.

                bool started = adaptor.Start();
                if (started)
                {
                    stitchInstance.State = InstanceStateType.Started;
                }

                return(InstanceActionResult.Result(instanceId, started, stitchInstance));
            }
            catch (Exception e)
            {
                stitchInstance.State = InstanceStateType.Error;
                return(InstanceActionResult.Failure(stitchInstance.Id, adaptor != null, e));
            }
        }
        public bool Add(string id, IStitchAdaptor adaptor)
        {
            bool added = _adaptors.TryAdd(id, adaptor);

            return(added);
        }