public async Task <Models.Group> GetGroup(string id) { try { Models.Group objGroup = new Models.Group(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load group profile. var group = await client.Groups[id].Request().GetAsync(); // Copy Microsoft-Graph Group to DTO Group objGroup = CopyHandler.GroupProperty(group); return(objGroup); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { Log.Warning(ex.Message); throw new NotFoundException(); } else { throw new Exception(); } } }
public async Task <IActionResult> GetUsers() { Users users = new Users(); try { users.Resources = new List <Models.User>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load users profiles. var userList = await client.Users.Request().GetAsync(); // Copy Microsoft User to DTO User foreach (var user in userList) { var objUser = CopyHandler.UserProperty(user); users.Resources.Add(objUser); } return(Ok(users)); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest()); } else { return(NotFound()); } } }
public async Task <IActionResult> GetGroup(string id) { Models.Group objGroup = new Models.Group(); try { // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load group profile. var group = await client.Groups[id].Request().GetAsync(); // Copy Microsoft-Graph Group to DTO Group objGroup = CopyHandler.GroupProperty(group); return(Ok(objGroup)); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest()); } else { return(NotFound()); } } }
public async Task <IActionResult> GetUser(string id) { Models.User objUser = new Models.User(); try { if (string.IsNullOrEmpty(id) || string.IsNullOrWhiteSpace(id)) { return(BadRequest()); } // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load user profile. var user = await client.Users[id].Request().GetAsync(); // Copy Microsoft-Graph User to DTO User objUser = CopyHandler.UserProperty(user); return(Ok(objUser)); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest()); } else { return(NotFound()); } } }
//private readonly MicrosoftGraphClient graphClient; //public AzureADHandler() //{ // this.graphClient = MicrosoftGraphClient.graphClient; //} public async Task <Models.User> GetUser(string id) { try { Models.User objUser = new Models.User(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load user profile. var user = await client.Users[id].Request().GetAsync(); // Copy Microsoft-Graph User to DTO User objUser = CopyHandler.UserProperty(user); return(objUser); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.NotFound) { Log.Warning(ex.Message); throw new NotFoundException(); } else { throw new Exception(); } } }
public async Task Scenario1() { //Arrange var handler = new CopyHandler(); //Act //await handler.RunAsync(null); //Assert }
public void Copy_EmptyModel_To_Other_EmptyModel_WithoutForce() { //Arrange var fromKey = "key1"; var toKey = "key2"; var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); targetBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); targetBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var logger = Substitute.For <IInternalLogger>(); var handler = new CopyHandler(blipAIClientFactory, logger); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.From = new MyNamedParameter <string>(); handler.To = new MyNamedParameter <string>(); handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act var result = handler.RunAsync(null).Result; //Assert Assert.AreEqual(0, result); }
public object Copy(CopyHandler RangeOnCopy) { object origin = xRange.get_Value(Missing.Value), rlt; if (RangeOnCopy != null) { //RangeOnCopy(this); } rlt = xRange.Copy(Missing.Value); if (RangeOnCopy != null) { RangeOnCopy(this); //xRange.set_Value(Missing.Value, origin); } return rlt; }
static new public void ClearStatic() { if (_caret != null) { _caret.Dispose(); } if (_selectionShape != null) { _selectionShape.Dispose(); } _caret = null; _selectionShape = null; _nextBlink = 0; onCopy = null; onPaste = null; }
public void CopyHandler() { const string CURRENT_ROOT = "TestCopyFolder"; const string CURRENT_ROOT_PATH = ROOT_TEST_PATH + "\\" + CURRENT_ROOT; const string TEST_FOLDER_SRC_NAME = "FolderSrc"; const string TEST_FOLDER_SRC_PATH = CURRENT_ROOT_PATH + "\\" + TEST_FOLDER_SRC_NAME; const string TEST_FOLDER_DST_NAME = "FolderDst"; const string TEST_FOLDER_DST_PATH = CURRENT_ROOT_PATH + "\\" + TEST_FOLDER_DST_NAME; const string TEST_FILE_TXT_NAME = "TestFile.txt"; const string TEST_SRC_FILE_TXT_PATH = TEST_FOLDER_SRC_PATH + "\\" + TEST_FILE_TXT_NAME; const string TEST_DST_FILE_TXT_PATH = TEST_FOLDER_DST_PATH + "\\" + TEST_FILE_TXT_NAME; Directory.CreateDirectory(TEST_FOLDER_SRC_PATH); Directory.CreateDirectory(TEST_FOLDER_DST_PATH); FileIO.WriteData(TEST_SRC_FILE_TXT_PATH, "0"); FileIO.WriteData(TEST_DST_FILE_TXT_PATH, "1"); var targetToCopy = new BaseActionTarget { IsFile = true, Name = TEST_FILE_TXT_NAME }; var param = new CopyParam { SourceDirectory = $"/{CURRENT_ROOT}/{TEST_FOLDER_SRC_NAME}", DestinationDirectory = $"/{CURRENT_ROOT}/{TEST_FOLDER_DST_NAME}", Targets = new List <BaseActionTarget> { targetToCopy }, Overwrite = true }; var result = new CopyHandler(CreateHostingEnv()).Run(param) as CopyResult; PrintErrors(result.Errors); string value = FileIO.ReadToEnd(TEST_DST_FILE_TXT_PATH); Assert.Equal("0", value); Assert.True(File.Exists(TEST_SRC_FILE_TXT_PATH)); Assert.True(result.Errors.Count == 0); }
public void Scenario1Test() { //Arrange var fromKey = "key1"; var toKey = "key2"; var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); sourceBlipAIClient.GetAllIntents(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var handler = new CopyHandler(blipAIClientFactory); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.From = new MyNamedParameter <string>(); handler.To = new MyNamedParameter <string>(); handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act handler.RunAsync(null).Wait(); //Assert }
public async Task <UserResources> GetUsers(string filter, int?startIndex, int?count, string sortBy) { try { UserResources users = new UserResources(); users.resources = new List <Models.User>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load users profiles. var userList = await client.Users.Request().Filter($"{filter}").GetAsync(); // Copy Microsoft User to DTO User foreach (var user in userList) { var objUser = CopyHandler.UserProperty(user); users.resources.Add(objUser); } users.totalResults = users.resources.Count; return(users); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { Log.Warning(ex.Message); throw new BadRequestException(); } else if (ex.StatusCode == HttpStatusCode.NotFound) { Log.Warning(ex.Message); throw new NotFoundException(); } else { throw new Exception(); } } }
public async Task <GroupResources> GetGroups(string filter, int?startIndex, int?count, string sortBy) { try { GroupResources groups = new GroupResources(); groups.resources = new List <Models.Group>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load groups profiles. var groupList = await client.Groups.Request().Filter($"{filter}").GetAsync(); // Copy Microsoft-Graph Group to DTO Group foreach (var group in groupList) { var objGroup = CopyHandler.GroupProperty(group); groups.resources.Add(objGroup); } groups.totalResults = groups.resources.Count; return(groups); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { Log.Warning(ex.Message); throw new BadRequestException(); } else if (ex.StatusCode == HttpStatusCode.NotFound) { Log.Warning(ex.Message); throw new NotFoundException(); } else { throw new Exception(); } } }
public async Task <IActionResult> GetUsersNotInTeam(string teamId) { UsersDto users = new UsersDto(); try { users.Resources = new List <UserDto>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load users profiles. var userList = await client.Users.Request().GetAsync(); TeamModel team = await Mediator.Send(new GetTeamQuery { TeamId = new Guid(teamId) }); // Copy Microsoft User to DTO User foreach (var user in userList) { if (!team.Users.Any(x => x.UserId.ToString().Equals(user.Id))) { var objUser = CopyHandler.UserProperty(user); users.Resources.Add(objUser); } } users.TotalResults = users.Resources.Count; return(Ok(users)); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest()); } else { return(NotFound()); } } }
public CopyHandler GetCopyHandler(Type type) { CopyHandler copyHandler = null; lock (_handlersLock) { if (_handlers.TryGetValue(type, out copyHandler) == false) { var attributes = type.GetCustomAttributes(typeof(CopyableAttribute), inherit: true); var isCopyable = attributes.Length > 0; if (isCopyable) { copyHandler = new CopyHandler(type); } _handlers.Add(type, copyHandler); } } return(copyHandler); }
public async Task <IActionResult> Get() { //return new string[] { "value1", "value2" }; Groups groups = new Groups(); try { groups.resources = new List <Models.Group>(); // Initialize the GraphServiceClient. GraphServiceClient client = await MicrosoftGraphClient.GetGraphServiceClient(); // Load groups profiles. var groupList = await client.Groups.Request().GetAsync(); // Copy Microsoft-Graph Group to DTO Group foreach (var group in groupList) { var objGroup = CopyHandler.GroupProperty(group); groups.resources.Add(objGroup); } groups.totalResults = groups.resources.Count; return(Ok(groups)); } catch (ServiceException ex) { if (ex.StatusCode == HttpStatusCode.BadRequest) { return(BadRequest()); } else { return(NotFound()); } } }
private static void Execute(FlexibleOptions options) { logger.Debug("Start"); // Parsing Arguments - Sanity Check ParseArguments(options); logger.Debug("Opening connections..."); CheckConnections(options); // Reaching Databases MongoServer sourceDatabase = MongoDbContext.GetServer(options.Get("source")); MongoServer targetDatabase = MongoDbContext.GetServer(options.Get("target")); // process list logger.Debug("Start migrating data..."); CopyHandler.DatabaseCopy(sourceDatabase, targetDatabase, _sourceDatabases, _targetDatabases, _collections, _targetCollection, _insertBatchSize, _copyIndexes, _dropCollections, _skipCount, _eraseObjectId, _threads, options); System.Threading.Thread.Sleep(1000); logger.Debug("Done migrating data!"); }
public void Copy_EmptyModel_To_Model_WithoutForce(int numIntents, int numEntities) { //Arrange var fromKey = "key1"; var toKey = "key2"; var intents = new List <Intention>(); for (int i = 0; i < numIntents; i++) { intents.Add(new Intention { Id = $"{i}", Name = $"Name{i}" }); } var entities = new List <Entity>(); for (int i = 0; i < numEntities; i++) { entities.Add(new Entity { Id = $"{i}", Name = $"Name{i}" }); } var sourceBlipAIClient = Substitute.For <IBlipAIClient>(); sourceBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult <List <Intention> >(null)); sourceBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult <List <Entity> >(null)); var targetBlipAIClient = Substitute.For <IBlipAIClient>(); targetBlipAIClient.GetAllIntentsAsync(Arg.Any <bool>()).Returns(Task.FromResult(intents)); targetBlipAIClient.GetAllEntities(Arg.Any <bool>()).Returns(Task.FromResult(entities)); var blipAIClientFactory = Substitute.For <IBlipClientFactory>(); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(fromKey))).Returns(sourceBlipAIClient); blipAIClientFactory.GetInstanceForAI(Arg.Is <string>(s => s.Equals(toKey))).Returns(targetBlipAIClient); var logger = Substitute.For <IInternalLogger>(); var handler = new CopyHandler(blipAIClientFactory, logger); handler.FromAuthorization = new MyNamedParameter <string> { Value = fromKey }; handler.ToAuthorization = new MyNamedParameter <string> { Value = toKey }; handler.Verbose = new MySwitch { IsSet = false }; handler.Force = new MySwitch { IsSet = false }; handler.Contents = new MyNamedParameter <List <BucketNamespace> > { Value = new List <BucketNamespace> { BucketNamespace.AIModel } }; //Act var result = handler.RunAsync(null).Result; //Assert Assert.AreEqual(0, result); targetBlipAIClient.DidNotReceive().AddEntity(Arg.Any <Entity>()); targetBlipAIClient.DidNotReceive().AddIntent(Arg.Any <string>()); targetBlipAIClient.DidNotReceive().DeleteIntent(Arg.Any <string>()); targetBlipAIClient.DidNotReceive().DeleteEntity(Arg.Any <string>()); }
private void HandleConnection(Socket sock) { NetworkStream stream = new NetworkStream(sock); string line = null; bool error = false; bool keepAlive = false; DateTime startTime = DateTime.Now; sock.ReceiveTimeout = RequestHandler.Timeout * 100; sock.Blocking = false; sock.NoDelay = true; sock.SendBufferSize = 16 * 1024; sock.UseOnlyOverlappedIO = true; string type = ""; string path = ""; do { bool first = true; RequestHandler handler = null; do { line = null; try { line = ReadLine(stream); BytesReadHeader += line.Length + 2; } catch (ThreadAbortException e) { keepAlive = false; error = true; break; } catch (IOException e) { keepAlive = false; error = true; break; } catch (Exception e) { keepAlive = false; error = true; break; } /* connection timed out or closed */ if (line == null) { sock.Close(); LogRequest(" (Socket closed)"); return; } if (first) { LogRequest(" (Connection from " + sock.RemoteEndPoint + ")"); } LogRequest("< " + line); /* not an empty line? */ if (line != "") { /* the first line contains the request */ if (first) { if (line.Contains(' ')) { type = line.Substring(0, line.IndexOf(' ')); path = line.Substring(line.IndexOf(' ')).Trim(); try { switch (type) { case "OPTIONS": handler = new OptionsHandler(this, path); break; case "PROPFIND": handler = new PropFindHandler(this, path); break; case "GET": handler = new GetHandler(this, path); break; case "HEAD": handler = new HeadHandler(this, path); break; case "PUT": handler = new PutHandler(this, path); break; case "LOCK": handler = new LockHandler(this, path); break; case "UNLOCK": handler = new UnlockHandler(this, path); break; case "DELETE": handler = new DeleteHandler(this, path); break; case "MOVE": handler = new MoveHandler(this, path); break; case "COPY": handler = new CopyHandler(this, path); break; case "MKCOL": handler = new MkColHandler(this, path); break; case "PROPPATCH": handler = new PropPatchHandler(this, path); break; default: handler = new RequestHandler(this, "/"); break; } } catch (IOException e) { Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + ") had IOException"); } catch (Exception e) { Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (" + type + ")"); } } first = false; } else { try { handler.AddHeaderLine(line); } catch (IOException e) { /* just close */ sock.Close(); LogRequest(" (Socket closed)"); return; } catch (Exception e) { Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (AddHeaderLine)"); } //stream.Flush(); } } } while (line != ""); if (handler == null) { Log("[E] Empty request in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); handler.KeepAlive = false; return; } if (!error) { try { if (handler.RequestContentLength > 0) { handler.HandleContent(stream); } handler.HandleRequest(stream); stream.Flush(); } catch (FileNotFoundException e) { Log("[E] 404 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(404); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } catch (SocketException e) { Log("[E] '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); handler.KeepAlive = false; return; } catch (UnauthorizedAccessException e) { Log("[i] 403 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(403); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } catch (Exception e) { Log("[E] 500 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(500); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } if (EnableRequestLog) { DateTime endTime = DateTime.Now; Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + " " + path + ") took " + (endTime - startTime).TotalMilliseconds + " ms (" + handler.StatusCode + ")"); } LogRequest(""); lock (StatisticsLock) { BytesWrittenHeader += handler.BytesWrittenHeader; BytesWrittenData += handler.BytesWrittenData; BytesReadHeader += handler.BytesReadHeader; BytesReadData += handler.BytesReadData; } keepAlive = handler.KeepAlive; /* windows isnt really using keepalive :( */ keepAlive = false; } } while (keepAlive); sock.Close(); LogRequest(" (Socket closed)"); }
public static int Main(string[] args) { RegisterBlipTypes(); var serviceProvider = new ServiceCollection() .AddSingleton <IStringService, StringService>() .AddSingleton <NLPCompareHandler>() .BuildServiceProvider(); return(CLI.HandleErrors(() => { var app = CLI.Parser(); app.ExecutableName(typeof(Program).GetTypeInfo().Assembly.GetName().Name); app.FromAssembly(typeof(Program).GetTypeInfo().Assembly); app.HelpText("BLiP Command Line Interface"); _verbose = app.Switch("v").Alias("verbose").HelpText("Enable verbose output."); _force = app.Switch("force").HelpText("Enable force operation."); var pingHandler = new PingHandler(); var pingCommand = app.Command("ping"); pingHandler.Node = pingCommand.Parameter <string>("n").Alias("node").HelpText("Node to ping"); pingCommand.HelpText("Ping a specific bot (node)"); pingCommand.Handler(pingHandler.Run); var nlpImportHandler = new NLPImportHandler(); var nlpImportCommand = app.Command("nlp-import"); nlpImportHandler.Node = nlpImportCommand.Parameter <string>("n").Alias("node").HelpText("Node to receive the data"); nlpImportHandler.Authorization = nlpImportCommand.Parameter <string>("a").Alias("authorization").HelpText("Node Authorization to receive the data"); nlpImportHandler.EntitiesFilePath = nlpImportCommand.Parameter <string>("ep").Alias("entities").HelpText("Path to entities file"); nlpImportHandler.IntentsFilePath = nlpImportCommand.Parameter <string>("ip").Alias("intents").HelpText("Path to intents file"); nlpImportCommand.HelpText("Import intents and entities to a specific bot (node)"); nlpImportCommand.Handler(nlpImportHandler.Run); var copyHandler = new CopyHandler(); var copyCommand = app.Command("copy"); copyHandler.From = copyCommand.Parameter <string>("f").Alias("from").HelpText("Node (bot) source"); copyHandler.To = copyCommand.Parameter <string>("t").Alias("to").HelpText("Node (bot) target"); copyHandler.FromAuthorization = copyCommand.Parameter <string>("fa").Alias("fromAuthorization").HelpText("Authorization key of source bot"); copyHandler.ToAuthorization = copyCommand.Parameter <string>("ta").Alias("toAuthorization").HelpText("Authorization key of target bot"); copyHandler.Contents = copyCommand.Parameter <List <BucketNamespace> >("c").Alias("contents").HelpText("Define which contents will be copied").ParseUsing(copyHandler.CustomNamespaceParser); copyHandler.Verbose = _verbose; copyHandler.Force = _force; copyCommand.HelpText("Copy data from source bot (node) to target bot (node)"); copyCommand.Handler(copyHandler.Run); var saveNodeHandler = new SaveNodeHandler(); var saveNodeCommand = app.Command("saveNode"); saveNodeHandler.Node = saveNodeCommand.Parameter <string>("n").Alias("node").HelpText("Node (bot) to be saved"); saveNodeHandler.AccessKey = saveNodeCommand.Parameter <string>("k").Alias("accessKey").HelpText("Node accessKey"); saveNodeHandler.Authorization = saveNodeCommand.Parameter <string>("a").Alias("authorization").HelpText("Node authoriaztion header"); saveNodeCommand.HelpText("Save a node (bot) to be used next"); saveNodeCommand.Handler(saveNodeHandler.Run); var formatKeyHandler = new FormatKeyHandler(); var formatKeyCommand = app.Command("formatKey").Alias("fk"); formatKeyHandler.Identifier = formatKeyCommand.Parameter <string>("i").Alias("identifier").HelpText("Bot identifier").Required(); formatKeyHandler.AccessKey = formatKeyCommand.Parameter <string>("k").Alias("accessKey").HelpText("Bot accessKey"); formatKeyHandler.Authorization = formatKeyCommand.Parameter <string>("a").Alias("authorization").HelpText("Bot authoriaztion header"); formatKeyCommand.HelpText("Show all valid keys for a bot"); formatKeyCommand.Handler(formatKeyHandler.Run); var nlpAnalyseHandler = new NLPAnalyseHandler(); var nlpAnalyseCommand = app.Command("nlp-analyse").Alias("analyse"); nlpAnalyseHandler.Text = nlpAnalyseCommand.Parameter <string>("t").Alias("text").HelpText("Text to be analysed"); nlpAnalyseHandler.Node = nlpAnalyseCommand.Parameter <string>("n").Alias("node").Alias("identifier").HelpText("Bot identifier"); nlpAnalyseHandler.Node = nlpAnalyseCommand.Parameter <string>("a").Alias("accessKey").HelpText("Bot access key"); nlpAnalyseCommand.HelpText("Analyse some text using a bot IA model"); nlpAnalyseCommand.Handler(nlpAnalyseHandler.Run); var exportHandler = new ExportHandler(); var exportCommand = app.Command("export").Alias("get"); exportHandler.Node = exportCommand.Parameter <string>("n").Alias("node").HelpText("Node (bot) source"); exportHandler.Authorization = exportCommand.Parameter <string>("a").Alias("authorization").HelpText("Authorization key of source bot"); exportHandler.OutputFilePath = exportCommand.Parameter <string>("o").Alias("output").Alias("path").HelpText("Output file path"); exportHandler.Model = exportCommand.Parameter <ExportModel>("m").Alias("model").HelpText("Model to be exported").ParseUsing(exportHandler.CustomParser); exportCommand.HelpText("Export some BLiP model"); exportCommand.Handler(exportHandler.Run); var compareHandler = serviceProvider.GetService <NLPCompareHandler>(); var compareCommand = app.Command("comp").Alias("compare"); compareHandler.Authorization1 = compareCommand.Parameter <string>("a1").Alias("authorization1").Alias("first").HelpText("Authorization key of first bot"); compareHandler.Bot1Path = compareCommand.Parameter <string>("p1").Alias("path1").Alias("firstpath").HelpText("Path of first bot containing exported model"); compareHandler.Authorization2 = compareCommand.Parameter <string>("a2").Alias("authorization2").Alias("second").HelpText("Authorization key of second bot"); compareHandler.Bot2Path = compareCommand.Parameter <string>("p2").Alias("path2").Alias("secondpath").HelpText("Path of second bot containing exported model"); compareHandler.OutputFilePath = compareCommand.Parameter <string>("o").Alias("output").Alias("path").HelpText("Output file path"); compareHandler.Method = compareCommand.Parameter <ComparisonMethod>("m").Alias("method").HelpText("Comparison method (exact, levenshtein)").ParseUsing(compareHandler.CustomMethodParser); compareHandler.Verbose = _verbose; compareCommand.HelpText("Compare two knowledgebases"); compareCommand.Handler(compareHandler.Run); app.HelpCommand(); return app.Parse(args).Run(); })); }