/// <summary> /// Runs based on the specified options. /// </summary> /// <param name="options">The options.</param> /// <returns> /// The program return code /// </returns> private static int Run(Options options) { if (!options.LoadSettingsFile()) { Console.Error.WriteLine(string.Format(OptionsExtensions.FileDoesNotExist, options.SettingsFile)); return(INVALID_RUN); } string error = options.Validate(); if (!string.IsNullOrEmpty(error)) { Console.Error.WriteLine(error); return(INVALID_ARGUMENTS); } IServiceProvider serviceProvider = InitDependencyInjection(options); IEmailHandler handler = serviceProvider.GetRequiredService <IEmailHandler>(); if (!handler.HandleIncomingEmail()) { return(INVALID_RUN); } return(VALID_RUN); }