static void Main(string[] args) { if (args.Count() == 0) { Console.WriteLine("MP Model Generator Utility"); Console.WriteLine("This tool will produce poco models from all mapped meta-data in the MP REST api. It will also produce a base class that all model will inherit. The file mpmodels.cs will be created with all models."); Console.WriteLine("usage: mpmodelgenerator <api base url> <client> <secret>"); Console.WriteLine("example: mpmodelgenerator https://demo.ministryplatform.net/ministryplatformapi myapiclient myapisecret"); Console.WriteLine("Press <ENTER> key to exit..."); var returnVal = Console.ReadLine(); return; } // Check that Arg[0] is a Uri try { var uriTest = new Uri(args[0]); } catch (Exception ex) { Console.WriteLine($"Exception Occurred: {ex.Message}"); Console.WriteLine("Argument 0 must be a valid Uri."); Console.WriteLine("Example: (https://demo.ministryplatform.net/ministryplatformapi)"); var returnVal = Console.ReadLine(); return; } // Initialize the api var _api = PowerServiceClientFactory.CreateAsync(new Uri(args[0]), args[1], args[2]).Result; Task.Run(async() => { await GenerateModels(_api); }).GetAwaiter().GetResult(); }
public HomeController(ILogger <HomeController> logger, IConfiguration configuration) { _logger = logger; _configuration = configuration; // Initialize the PowerServiceClientFactory using configuration data saved in application _api = PowerServiceClientFactory.CreateAsync(new Uri(_configuration["mp.ApiBaseUrl"]), _configuration["mp.client"], _configuration["mp.secret"]).Result; }