private CommandResult Detect()
 {
     try
     {
         string newInstanceId = serviceProvider.DetectAvailableInstanceId().ToString();
         return(CommandResult.CreateResult(MessageOutput.Create(newInstanceId)));
     }
     catch (Service.TimeoutException ex)
     {
         throw new TargetExecutionException(DaemonErrorCode.COMMAND_TIME_OUT, ex);
     }
     catch (TargetExecutionException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw new TargetExecutionException(DaemonErrorCode.UNKNOWN_ERROR, ex);
     }
 }
示例#2
0
        private int?DecideInstanceId(ConfigureParameter parameter, InstanceTypes instanceType, bool force)
        {
            // Decide the instanceId
            if (parameter.InstanceId.HasValue)
            {
                return(parameter.InstanceId.Value);
            }

            if (parameter.AutoDecideInstanceId || force)
            {
                ServiceProvider serviceProvider = ServiceProvider.GetServiceProvider(instanceType);
                if (serviceProvider == null)
                {
                    return(null);
                }
                else
                {
                    return(serviceProvider.DetectAvailableInstanceId());
                }
            }

            return(null);
        }