public static void load_helps(TextReaderProxy proxy) { do { var help = new HelpData { Level = proxy.ReadNumber(), Keyword = proxy.ReadToEndOfLine() }; if (help.Keyword.StartsWith("#$")) { break; } help.Text = proxy.ReadString(new[] { '~' }); if (help.Keyword.EqualsIgnoreCase("greeting")) { HelpGreeting = help.Text; } add_help(help); } while (!proxy.EndOfStream); }
public void DisplayHelp() { var helpData = new HelpData() { AppDescription = config.AppDescription, parameters = config.parameters.Select(item => new CmdArgParam() { Description = item.Description, Key = item.Key, Value = item.Value }).ToList() }; if (config.CustomHelp != null) { try { config.CustomHelp(helpData); } catch (Exception e) { Console.WriteLine("Custom help provided in this implementation thrown an exception."); Console.WriteLine("Exception details:"); Console.WriteLine(e.ToString()); Console.WriteLine("Showing default help instead:"); Help.Show(helpData); } } else { Help.Show(helpData); } }
public void HelpStrategy_Should_WriteHelpTextWithOptions() { // Arrange help data var helpData = new HelpData { CommandName = sampleCommandName, HelpTextFirstLine = { { sampleFirstLineText, string.Empty } }, Options = { { sampleOption, sampleOptionDescription } }, HelpTextLastLine = { { string.Empty, sampleLastLineText } }, LogMessage = sampleLogMessage, HelpText = sampleHelpText, }; AppioLogger.RegisterListener(_loggerListenerMock.Object); var helpStrategy = new HelpStrategy <object>(helpData); helpStrategy.CommandFactory = _factoryMock.Object; // Act var strategyResult = helpStrategy.Execute(new string[] { }); // Assert Assert.IsTrue(strategyResult.Success); Assert.IsNotNull(strategyResult.OutputMessages); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(sampleFirstLineText, string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>("Options:", string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(sampleOption, sampleOptionDescription))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(string.Empty, sampleLastLineText))); _loggerListenerMock.Verify(x => x.Info(sampleLogMessage), Times.Once); AppioLogger.RemoveListener(_loggerListenerMock.Object); }
public async Task PostLoginTest() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <DataContext>() .UseSqlite(connection) .Options; using (var context = new DataContext(options)) { context.Database.EnsureCreated(); } using (var context = new DataContext(options)) { HelpData.SetTestUsers(context); context.SaveChanges(); } //check if errors are present using (var context = new DataContext(options)) { var controller = new UserController(context); controller.ModelState.AddModelError("Email", "Required"); User newUser = new User(); var result = await controller.Login(newUser); var viewResult = Assert.IsType <ViewResult>(result); Assert.Equal(newUser, viewResult?.Model); } //check if errors are not present using (var context = new DataContext(options)){ var controller = new UserController(context); controller.ModelState.AddModelError("Email", ""); controller.ModelState.AddModelError("Password", ""); controller.ModelState["Email"].Errors.Clear(); controller.ModelState["Password"].Errors.Clear(); User newUser = new User() { Password = "******", Email = "*****@*****.**" }; var result = await controller.Login(newUser); var viewResult = Assert.IsType <ViewResult>(result); Assert.Equal("Wrong email or password", viewResult.ViewData["Error"]); } } finally { connection.Close(); } }
public IEnumerator ChangeTexOnPiece(Touch touch) { if (paintableObject) { Transform newDetected = paintableObject.transform; HelpData hd = newDetected.GetComponent <HelpData>(); Renderer meshRenderer = newDetected.GetComponent <MeshRenderer>(); timerForApplyTex = 0; meshRenderer.material.SetColor("_FirstColor", Color.white); meshRenderer.material.SetColor("_SecondColor", Color.white); //meshRendere.material = hd.normalMat; //paintableTexture.Texture = meshRendere.material.GetTexture("_BaseMap"); Renderer newDetectedPieceRenderer = newDetected.transform.GetComponent <Renderer>(); newDetectedPieceRenderer.materials[0].SetTexture("_BaseMap", texture.texture); previouslyDetectedPiece = newDetected; RefreshMap(paintableObject); } else { timerForApplyTex = 0; } changingTexNow = false; yield return(null); }
public async Task IndexTest() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <DataContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new DataContext(options)) { context.Database.EnsureCreated(); } // Run the test against one instance of the context using (var context = new DataContext(options)) { HelpData.SetTestUsers(context); context.SaveChanges(); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new DataContext(options)) { int testUserId = 1; var controller = new UserController(context); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { new Claim(ClaimTypes.Name, testUserId.ToString()) }, "Basic")) } }; var result = await controller.Index(testUserId); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsType <User>(viewResult.ViewData.Model); Assert.Equal("Bob", model.Username); Assert.Equal("123456", model.Password); Assert.Equal("*****@*****.**", model.Email); } } finally { connection.Close(); } }
public void Show(Images.Name helpImage, HelpData helpData) { ClearData(); UpdateData(helpImage, helpData); Visible = true; mWindow.Repaint(); }
public async Task ListTest() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <DataContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new DataContext(options)) { context.Database.EnsureCreated(); } // Run the test against one instance of the context using (var context = new DataContext(options)) { HelpData.SetTestUsers(context); HelpData.GetTestPost(context); context.SaveChanges(); } // news output check using (var context = new DataContext(options)) { var controller = new PostController(context); var result = await controller.List(1); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsType <ListPages>(viewResult.ViewData.Model); Post testPost = null; foreach (var post in model.Posts) { if (post.Id == 7) { testPost = post; } } Assert.Equal(5, model.Posts.Count()); Assert.NotNull(testPost); Assert.Equal("SeventhTitle", testPost.Title); } } finally { connection.Close(); } }
/// <summary> /// Adds a help page to the list if it is not a duplicate of an existing page. /// Page is insert-sorted by keyword. (The reason for sorting is to keep do_hlist looking nice) /// </summary> public static void add_help(HelpData newHelp) { if (HELPS.Any(x => x.Level == newHelp.Level && x.Keyword.Equals(newHelp.Keyword))) { LogManager.Instance.Bug("Duplicate Help {0}", newHelp.Keyword); return; } // TODO At some point do some sorting based on keyword HELPS.Add(newHelp); }
/// <summary> /// Register a new item /// </summary> /// <param name="name">Name</param> /// <param name="text">Text</param> /// <returns></returns> public static bool Register(string name, string text) { lock (HelpData) { if (!HelpData.ContainsKey(name)) { HelpData.Add(name, text); return(true); } } return(false); }
/// <summary> /// Remove a help /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool Unregister(string name) { lock (HelpData) { if (HelpData.ContainsKey(name)) { HelpData.Remove(name); return(true); } } return(false); }
// APPIO Publish command private static PublishStrategy CreatePublishStrategy(IFileSystem fileSystem) { // Publish command help first lines var publishHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.PublishFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.PublishCallDescription } }; // Publish command options var nameOption = new StringBuilder(Constants.PublishCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.PublishCommandOptions.VerboseName).ToString(); var helpOption = new StringBuilder(Constants.PublishCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.PublishCommandOptions.VerboseHelp).ToString(); var publishOptions = new MessageLines { { nameOption, HelpTextValues.OptionNameDescription }, { helpOption, HelpTextValues.OptionHelpDescription } }; // Publish help strategy var publishHelpStrategyData = new HelpData { CommandName = Constants.PublishCommandOptions.Help, HelpTextFirstLine = publishHelpStrategyHelpText, Options = publishOptions, LogMessage = LoggingText.OpcuaappPublishHelpCalled, HelpText = HelpTextValues.PublishHelpArgumentCommandDescription, }; var publishHelpStrategy = new HelpStrategy <PublishStrategy>(publishHelpStrategyData); publishHelpStrategyData.CommandName = Constants.PublishCommandOptions.VerboseHelp; var publishHelpVerboseStrategy = new HelpStrategy <PublishStrategy>(publishHelpStrategyData); var publishStrategies = new ICommand <PublishStrategy>[] { new PublishNameStrategy(Constants.PublishCommandOptions.Name, fileSystem), new PublishNameStrategy(Constants.PublishCommandOptions.VerboseName, fileSystem), publishHelpStrategy, publishHelpVerboseStrategy, }; var publishStrategyCommandFactory = new CommandFactory <PublishStrategy>(publishStrategies, Constants.PublishCommandOptions.Help); publishHelpStrategy.CommandFactory = publishStrategyCommandFactory; publishHelpVerboseStrategy.CommandFactory = publishStrategyCommandFactory; return(new PublishStrategy(publishStrategyCommandFactory)); }
// APPIO Build command private static BuildStrategy CreateBuildStrategy(IFileSystem fileSystem) { // Build command help first lines var buildHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.BuildFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.BuildCallDescription } }; // Build command options var nameOption = new StringBuilder(Constants.BuildCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.BuildCommandOptions.VerboseName).ToString(); var helpOption = new StringBuilder(Constants.BuildCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.BuildCommandOptions.VerboseHelp).ToString(); var buildOptions = new MessageLines { { nameOption, HelpTextValues.OptionNameDescription }, { helpOption, HelpTextValues.OptionHelpDescription } }; // Build help strategy var buildHelpStrategyData = new HelpData { CommandName = Constants.BuildCommandOptions.Help, HelpTextFirstLine = buildHelpStrategyHelpText, Options = buildOptions, LogMessage = LoggingText.AppioHelpForBuildCommandCalled, HelpText = HelpTextValues.BuildHelpArgumentCommandDescription, }; var buildHelpStrategy = new HelpStrategy <BuildStrategy>(buildHelpStrategyData); buildHelpStrategyData.CommandName = Constants.BuildCommandOptions.VerboseHelp; var buildHelpVerboseStrategy = new HelpStrategy <BuildStrategy>(buildHelpStrategyData); var buildStrategies = new ICommand <BuildStrategy>[] { new BuildNameStrategy(Constants.BuildCommandOptions.Name, fileSystem), new BuildNameStrategy(Constants.BuildCommandOptions.VerboseName, fileSystem), buildHelpStrategy, buildHelpVerboseStrategy }; var buildStrategyCommandFactory = new CommandFactory <BuildStrategy>(buildStrategies, Constants.BuildCommandOptions.Help); buildHelpStrategy.CommandFactory = buildStrategyCommandFactory; buildHelpVerboseStrategy.CommandFactory = buildStrategyCommandFactory; return(new BuildStrategy(buildStrategyCommandFactory)); }
// APPIO Deploy command private static DeployStrategy CreateDeployStrategy(IFileSystem fileSystem) { // Deploy command help first lines var deployHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.DeployFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.DeployCallDescription } }; // Deploy command options var nameOption = new StringBuilder(Constants.DeployCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.DeployCommandOptions.VerboseName).ToString(); var helpOption = new StringBuilder(Constants.DeployCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.DeployCommandOptions.VerboseHelp).ToString(); var deployOptions = new MessageLines { { nameOption, HelpTextValues.OptionNameDescription }, { helpOption, HelpTextValues.OptionHelpDescription } }; var deployHelpStrategyData = new HelpData { CommandName = Constants.DeployCommandOptions.Help, HelpTextFirstLine = deployHelpStrategyHelpText, Options = deployOptions, LogMessage = LoggingText.AppioHelpForDeployCommandCalled, HelpText = HelpTextValues.DeployHelpArgumentCommandDescription, }; var deployHelpStrategy = new HelpStrategy <DeployStrategy>(deployHelpStrategyData); deployHelpStrategyData.CommandName = Constants.DeployCommandOptions.VerboseHelp; var deployVerboseHelpStrategy = new HelpStrategy <DeployStrategy>(deployHelpStrategyData); var deployStrategies = new ICommand <DeployStrategy>[] { new DeployNameStrategy(Constants.DeployCommandOptions.Name, fileSystem), new DeployNameStrategy(Constants.DeployCommandOptions.VerboseName, fileSystem), deployHelpStrategy, deployVerboseHelpStrategy }; var deployStrategyCommandFactory = new CommandFactory <DeployStrategy>(deployStrategies, Constants.DeployCommandOptions.Help); deployHelpStrategy.CommandFactory = deployStrategyCommandFactory; deployVerboseHelpStrategy.CommandFactory = deployStrategyCommandFactory; return(new DeployStrategy(deployStrategyCommandFactory)); }
private void helpDatabmdToolStripMenuItem_Click(object sender, EventArgs e) { string fpath = OpenDialog(); if (string.IsNullOrEmpty(fpath)) { return; } HelpData Decoder = new HelpData(fpath, BmdFile.FileType.HelpData); ClientEditor editor = new ClientEditor(Decoder, false); editor.Show(); }
void UpdateData(Images.Name helpImage, HelpData helpData) { mHelpImage = helpImage; mHelpData = helpData; string formattedHelpText; BuildFormattedHelp.ForData( mHelpData.CleanText, mHelpData.FormattedBlocks.ToArray(), mHelpData.Links.ToArray(), out formattedHelpText, out mFormattedLinks); mHelpGUIContent = new GUIContent(formattedHelpText); }
public void HelpStrategy_Should_ImplementICommandOfAnyType() { // Arrange var helpData = new HelpData { CommandName = "any-name", HelpTextFirstLine = { { "any-text", "" } }, HelpTextLastLine = { { "any-other-text", "" } }, LogMessage = "any-message", HelpText = "any-text", }; // Act var objectUnderTest = new HelpStrategy <object>(helpData); // Assert Assert.IsInstanceOf <ICommand <object> >(objectUnderTest); }
public override void Init() { base.Init(); string textAsset = BundleManager.Instance.GetJson("GameHelpConfig"); JsonData jd = JsonMapper.ToObject(textAsset); for (int i = 0; i < jd.Count; i++) { HelpData data = JsonMapper.ToObject <HelpData>(JsonMapper.ToJson(jd[i])); dataList.Add(data); } for (int i = 0; i < dataList.Count; i++) { if (strList.Find(p => p == dataList[i].type) == null) { strList.Add(dataList[i].type); } } }
public void ShouldReturnCommandName() { // Arrange var helpData = new HelpData { CommandName = "any-name", HelpTextFirstLine = { { "any-text", "" } }, HelpTextLastLine = { { "any-other-text", "" } }, LogMessage = "any-message", HelpText = "any-text", }; var helpStrategy = new HelpStrategy <object>(helpData); // Act var commandName = helpStrategy.Name; // Assert Assert.AreEqual("any-name", commandName); }
public void HelpData_Clone_ShouldPerformDeepClone() { // Arrange const string commandName = "any-name"; var helpTextFirstLine = new MessageLines { { "any-header-begin", "any-message-begin" } }; var helpTextLastLine = new MessageLines { { "any-header-end", "any-message-end" } }; const string helpText = "any-help-text"; const string logMessage = "any-log-message"; var obj = new HelpData { CommandName = commandName, HelpTextFirstLine = helpTextFirstLine, HelpTextLastLine = helpTextLastLine, HelpText = helpText, LogMessage = logMessage, }; // Act var clone = obj.Clone(); // Assert Assert.AreEqual(commandName, clone.CommandName); Assert.AreNotSame(helpTextFirstLine, clone.HelpTextFirstLine); Assert.AreEqual(1, helpTextFirstLine.Count()); Assert.AreEqual(1, clone.HelpTextFirstLine.Count()); Assert.AreEqual(1, helpTextLastLine.Count()); Assert.AreEqual(1, clone.HelpTextLastLine.Count()); Assert.AreEqual(helpTextFirstLine.First().Key, clone.HelpTextFirstLine.First().Key); Assert.AreEqual(helpTextFirstLine.First().Value, clone.HelpTextFirstLine.First().Value); Assert.AreEqual(helpTextLastLine.First().Key, clone.HelpTextLastLine.First().Key); Assert.AreEqual(helpTextLastLine.First().Value, clone.HelpTextLastLine.First().Value); Assert.AreNotSame(helpTextLastLine, clone.HelpTextLastLine); Assert.AreEqual(helpText, clone.HelpText); Assert.AreEqual(logMessage, clone.LogMessage); }
public void HelpStrategy_Should_WriteSparseHelpTextIfNoCommandFactoryIsProvided() { // Arrange var helpData = new HelpData { CommandName = "any-name", HelpTextFirstLine = { { "any-text", "" } }, HelpTextLastLine = { { "", "any-other-text" } }, LogMessage = "any-message", HelpText = "any-text", }; var helpStrategy = new HelpStrategy <object>(helpData); // Act var strategyResult = helpStrategy.Execute(new string[] { }); // Assert Assert.IsTrue(strategyResult.Success); Assert.IsNotNull(strategyResult.OutputMessages); Assert.AreEqual(string.Empty, strategyResult.OutputMessages.First().Value); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>("any-text", string.Empty))); Assert.IsTrue(strategyResult.OutputMessages.Contains(new KeyValuePair <string, string>(string.Empty, "any-other-text"))); }
// APPIO Generate command private static GenerateStrategy CreateGenerateStrategy(IFileSystem fileSystem, AbstractCertificateGenerator certificateGenerator) { // Generate command help first lines var generateHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.GenerateFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.GenerateCallDescription } }; // Generate command arguments var generateArguments = new MessageLines { { Constants.ImportCommandArguments.InformationModel, string.Empty }, { Constants.ImportCommandArguments.Certificate, string.Empty } }; // Generate command options var nameOption = new StringBuilder(Constants.GenerateCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.GenerateCommandOptions.VerboseName).ToString(); var helpOption = new StringBuilder(Constants.GenerateCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.GenerateCommandOptions.VerboseHelp).ToString(); var generateOptions = new MessageLines { { nameOption, HelpTextValues.OptionNameDescription }, { helpOption, HelpTextValues.OptionHelpDescription }, { Constants.GenerateCertificateCommandArguments.VerboseKeySize, HelpTextValues.GenerateCommandOptionKeySizeDescription }, { Constants.GenerateCertificateCommandArguments.VerboseDays, HelpTextValues.GenerateCommandOptionDaysDescription }, { Constants.GenerateCertificateCommandArguments.VerboseOrganization, HelpTextValues.GenerateCommandOptionOrganizationDescription } }; // Generate help strategy var generateHelpStrategyData = new HelpData { CommandName = Constants.GenerateCommandOptions.Help, HelpTextFirstLine = generateHelpStrategyHelpText, Arguments = generateArguments, Options = generateOptions, LogMessage = LoggingText.AppioHelpForGenerateCommand, HelpText = HelpTextValues.GenerateHelpArgumentCommandDescription, }; var generateHelpStrategy = new HelpStrategy <GenerateStrategy>(generateHelpStrategyData); generateHelpStrategyData.CommandName = Constants.GenerateCommandOptions.VerboseHelp; var generateHelpStrategyVerbose = new HelpStrategy <GenerateStrategy>(generateHelpStrategyData); var modelValidator = new ModelValidator(fileSystem); var nodesetGenerator = new NodesetGenerator(fileSystem, modelValidator); var generateSubCommands = new ICommand <GenerateStrategy>[] { new GenerateInformationModelStrategy(Constants.CommandName.GenerateInformationModel, fileSystem, modelValidator, nodesetGenerator), new GenerateCertificateStrategy(fileSystem, certificateGenerator), generateHelpStrategy, generateHelpStrategyVerbose }; var generateStrategyCommandFactory = new CommandFactory <GenerateStrategy>(generateSubCommands, Constants.GenerateCommandOptions.Help); generateHelpStrategy.CommandFactory = generateStrategyCommandFactory; generateHelpStrategyVerbose.CommandFactory = generateStrategyCommandFactory; return(new GenerateStrategy(generateStrategyCommandFactory)); }
public void Init(HelpData data) { title.text = data.questionType; content.text = data.answerType; UGUIEventListener.Get(arrow.gameObject).onClick = (g) => { PlayAnim(); }; }
public async Task PostEditTest() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); try { var options = new DbContextOptionsBuilder <DataContext>() .UseSqlite(connection) .Options; // Create the schema in the database using (var context = new DataContext(options)) { context.Database.EnsureCreated(); } // Run the test against one instance of the context using (var context = new DataContext(options)) { HelpData.SetTestUsers(context); HelpData.GetTestPost(context); context.SaveChanges(); } //check editing post: wrong user using (var context = new DataContext(options)) { var controller = new PostController(context); Post post = HelpData.GetEditTestPost(); var result = await controller.Edit(1, post); var viewResult = Assert.IsType <NotFoundResult>(result); } //the user is trying to change the record of another user using (var context = new DataContext(options)) { var controller = new PostController(context); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { new Claim(ClaimTypes.Name, "1") }, "Basic")) } }; Post post = HelpData.GetEditTestPost(); var result = await controller.Edit(6, post); var viewResult = Assert.IsType <NotFoundResult>(result); } //user is logged using (var context = new DataContext(options)){ var controller = new PostController(context); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { new Claim(ClaimTypes.Name, "2") }, "Basic")) } }; Post post = HelpData.GetEditTestPost(); var result = await controller.Edit(6, post); Post resultPost = await context.Post.FirstOrDefaultAsync(p => p.Id == 6); var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("EditSixthTitle", resultPost.Title); Assert.Equal("EditSixthDescription", resultPost.Description); Assert.Equal("EditSixthText", resultPost.Text); } } finally { connection.Close(); } }
private void UpdateWindowContents( HelpData.Help help ) { txtContents.Text = help.Text; txtKeywords.Text = help.Keyword; txtSyntax.Text = help.Syntax; cbLevel.Text = help.MinimumLevel.ToString(); txtSeeAlso.Text = help.SeeAlso; lblPosition.Text = (_selectedItem + 1).ToString() + " of " + _helpData.Count.ToString(); }
static bool LoadAreaFiles() { string listContents; try { listContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, areaList))); } catch (Exception e) { log.Error(e.Message); return(false); } using (var sr = new StringReader(listContents)) { for (;;) { var curFile = sr.ReadLine().Trim(); if (string.IsNullOrWhiteSpace(curFile)) { continue; } if (curFile.StartsWith("$")) { break; } if (curFile.StartsWith("-")) { // ?????? // fpArea = stdin; continue; } log.Info($"loadding {curFile}"); string areaContents; try { areaContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, curFile))); } catch (Exception e) { log.Error(e.Message); return(false); } using (var ar = new StringReader(areaContents)) { AreaData lastArea = null; for (;;) { var word = ar.ReadWord(); if (!word.StartsWith("#")) { return(false); } word = word.Substring(1); if (word.StartsWith("$")) { break; } switch (word) { case "AREA": lastArea = AreaData.Load(ar, curFile); break; case "HELPS": HelpData.LoadFromArea(ar); break; case "MOBILES": MobileDef.LoadFromArea(ar, lastArea); break; case "OBJECTS": ObjectDef.LoadFromArea(ar, lastArea); break; case "RESETS": ResetData.LoadFromArea(ar); break; case "ROOMS": RoomDef.LoadFromArea(ar, lastArea); break; case "SHOPS": ShopData.LoadFromArea(ar); break; case "SPECIALS": SpecType.LoadFromArea(ar); break; // OLC case "AREADATA": lastArea = AreaData.NewLoad(ar, curFile); break; // OLC 1.1b case "ROOMDATA": RoomDef.NewLoadFromArea(ar, lastArea); break; default: log.Error($"Boot_db: bad section name '{word}'."); return(false); } } } } return(true); } }
// APPIO New command private static NewStrategy CreateNewStrategy(IFileSystem fileSystem, AbstractCertificateGenerator certificateGenerator) { // New command help first lines var newHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.NewFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.NewCallDescription }, }; // New command arguments var newArguments = new MessageLines { { Constants.NewCommandArguments.OpcuaApp, string.Empty }, { Constants.NewCommandArguments.Sln, string.Empty } }; // New command options var nameOption = new StringBuilder(Constants.NewCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseName).ToString(); var helpOption = new StringBuilder(Constants.NewCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseHelp).ToString(); var typeOption = new StringBuilder(Constants.NewCommandOptions.Type).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseType).ToString(); var portOption = new StringBuilder(Constants.NewCommandOptions.Port).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerbosePort).ToString(); var urlOption = new StringBuilder(Constants.NewCommandOptions.Url).Append(Constants.HelpOptionSeparator).Append(Constants.NewCommandOptions.VerboseUrl).ToString(); var newOptions = new MessageLines { { nameOption, HelpTextValues.NewCommandOptionNameDescription }, { helpOption, HelpTextValues.OptionHelpDescription }, { typeOption, HelpTextValues.NewCommandOptionTypeDescription }, { portOption, HelpTextValues.NewCommandOptionPortDescription }, { urlOption, HelpTextValues.NewCommandOptionUrlDescription }, { Constants.NewCommandOptions.VerboseNoCert, HelpTextValues.NewCommandOptionNoCertDescription } }; // New help strategy var newHelpStrategyData = new HelpData { CommandName = Constants.NewCommandOptions.Help, HelpTextFirstLine = newHelpStrategyHelpText, Arguments = newArguments, Options = newOptions, LogMessage = LoggingText.AppioHelpForNewCommandCalled, HelpText = HelpTextValues.NewHelpArgumentCommandDescription, }; var newHelpStrategy = new HelpStrategy <NewStrategy>(newHelpStrategyData); newHelpStrategyData.CommandName = Constants.NewCommandOptions.VerboseHelp; var newHelpVerboseStrategy = new HelpStrategy <NewStrategy>(newHelpStrategyData); var newStrategies = new ICommand <NewStrategy>[] { new NewSlnCommandStrategy(fileSystem), new NewOpcuaAppCommandStrategy(fileSystem, certificateGenerator), newHelpStrategy, newHelpVerboseStrategy, }; var newStrategyCommandFactory = new CommandFactory <NewStrategy>(newStrategies, Constants.NewCommandOptions.Help); newHelpStrategy.CommandFactory = newStrategyCommandFactory; newHelpVerboseStrategy.CommandFactory = newStrategyCommandFactory; return(new NewStrategy(newStrategyCommandFactory)); }
// APPIO Import Strategy private static ImportStrategy CreateImportStrategy(IFileSystem fileSystem) { // Import command help first lines var importHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.ImportFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.ImportCallDescription } }; // Improt command arguments var importArguments = new MessageLines { { Constants.ImportCommandArguments.InformationModel, string.Empty }, { Constants.ImportCommandArguments.Certificate, string.Empty } }; // Import command options var nameOption = new StringBuilder(Constants.ImportCommandOptions.Name).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseName).ToString(); var pathOption = new StringBuilder(Constants.ImportCommandOptions.Path).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerbosePath).ToString(); var typesOption = new StringBuilder(Constants.ImportCommandOptions.Types).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseTypes).ToString(); var helpOption = new StringBuilder(Constants.ImportCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseHelp).ToString(); var sampleOption = new StringBuilder(Constants.ImportCommandOptions.Sample).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCommandOptions.VerboseSample).ToString(); var keyOption = new StringBuilder(Constants.ImportCertificateCommandArguments.Key).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCertificateCommandArguments.VerboseKey).ToString(); var certiciateOption = new StringBuilder(Constants.ImportCertificateCommandArguments.Certificate).Append(Constants.HelpOptionSeparator).Append(Constants.ImportCertificateCommandArguments.VerboseCertificate).ToString(); var clientServerOption = new StringBuilder(Constants.ImportCertificateCommandArguments.VerboseClient).Append(" or ").Append(Constants.ImportCertificateCommandArguments.VerboseServer).ToString(); var importOptions = new MessageLines { { nameOption, HelpTextValues.OptionNameDescription }, { pathOption, HelpTextValues.ImportCommandOptionPathDescription }, { typesOption, HelpTextValues.ImportCommandOptionTypesDescription }, { helpOption, HelpTextValues.OptionHelpDescription }, { sampleOption, HelpTextValues.ImportCommandOptionSampleDescription }, { keyOption, HelpTextValues.ImportCommandOptionKeyDescription }, { certiciateOption, HelpTextValues.ImportCommandOptionCertificateDescription }, { clientServerOption, HelpTextValues.ImportCommandOptionClientServerDescription } }; // Import help strategy var importHelpStrategyData = new HelpData { CommandName = Constants.ImportCommandOptions.Help, HelpTextFirstLine = importHelpStrategyHelpText, Arguments = importArguments, Options = importOptions, LogMessage = LoggingText.AppioHelpForImportInformationModel, HelpText = HelpTextValues.ImportHelpArgumentCommandDescription, }; var importHelpStrategy = new HelpStrategy <ImportStrategy>(importHelpStrategyData); importHelpStrategyData.CommandName = Constants.ImportCommandOptions.VerboseHelp; var importHelpStrategyVerbose = new HelpStrategy <ImportStrategy>(importHelpStrategyData); var importCommands = new ICommand <ImportStrategy>[] { new ImportInformationModelCommandStrategy(fileSystem, new ModelValidator(fileSystem)), new ImportCertificateStrategy(fileSystem), importHelpStrategy, importHelpStrategyVerbose }; var importStrategyCommandFactory = new CommandFactory <ImportStrategy>(importCommands, Constants.ImportCommandOptions.Help); importHelpStrategy.CommandFactory = importStrategyCommandFactory; importHelpStrategyVerbose.CommandFactory = importStrategyCommandFactory; return(new ImportStrategy(importStrategyCommandFactory)); }
// APPIO Sln command private static SlnStrategy CreateSlnStrategy(IFileSystem fileSystem) { // Sln command help first lines var slnHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.SlnFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.SlnCallDescription } }; // Sln command arguments var slnArguments = new MessageLines { { Constants.SlnCommandArguments.Add, HelpTextValues.SlnCommandArgumentAddDescription }, { Constants.SlnCommandArguments.Remove, HelpTextValues.SlnCommandArtgumentRemoveDescription }, { Constants.SlnCommandArguments.Build, HelpTextValues.SlnCommandArtgumentBuildDescription }, { Constants.SlnCommandArguments.Publish, HelpTextValues.SlnCommandArtgumentPublishDescription }, { Constants.SlnCommandArguments.Deploy, HelpTextValues.SlnCommandArtgumentDeployDescription } }; // Sln command options var solutionOption = new StringBuilder(Constants.SlnCommandOptions.Solution).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseSolution).ToString(); var projectOption = new StringBuilder(Constants.SlnCommandOptions.Project).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseProject).ToString(); var helpOption = new StringBuilder(Constants.SlnCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.SlnCommandOptions.VerboseHelp).ToString(); var slnOptions = new MessageLines { { solutionOption, HelpTextValues.SlnCommandOptionSolutionDescription }, { projectOption, HelpTextValues.SlnCommandOptionProjectDescription }, { helpOption, HelpTextValues.OptionHelpDescription }, }; // Sln help strategy var slnHelpStrategyData = new HelpData { CommandName = Constants.SlnCommandOptions.Help, HelpTextFirstLine = slnHelpStrategyHelpText, Arguments = slnArguments, Options = slnOptions, LogMessage = LoggingText.AppioHelpForSlnCommand, HelpText = HelpTextValues.SlnHelpArgumentCommandDescription, }; var slnHelpStrategy = new HelpStrategy <SlnStrategy>(slnHelpStrategyData); slnHelpStrategyData.CommandName = Constants.SlnCommandOptions.VerboseHelp; var slnHelpVerboseStrategy = new HelpStrategy <SlnStrategy>(slnHelpStrategyData); var SlnBuildCommandData = new SlnOperationData(); SlnBuildCommandData.CommandName = Constants.CommandName.Build; SlnBuildCommandData.FileSystem = fileSystem; SlnBuildCommandData.Subcommand = new BuildNameStrategy(Constants.CommandName.Build, fileSystem); SlnBuildCommandData.SuccessLoggerMessage = LoggingText.SlnBuildSuccess; SlnBuildCommandData.SuccessOutputMessage = OutputText.SlnBuildSuccess; SlnBuildCommandData.HelpText = HelpTextValues.SlnBuildNameArgumentCommandDescription; var SlnDeployCommandData = new SlnOperationData(); SlnDeployCommandData.CommandName = Constants.CommandName.Deploy; SlnDeployCommandData.FileSystem = fileSystem; SlnDeployCommandData.Subcommand = new DeployNameStrategy(Constants.CommandName.Deploy, fileSystem); SlnDeployCommandData.SuccessLoggerMessage = LoggingText.SlnDeploySuccess; SlnDeployCommandData.SuccessOutputMessage = OutputText.SlnDeploySuccess; SlnDeployCommandData.HelpText = HelpTextValues.SlnDeployNameArgumentCommandDescription; var SlnPublishCommandData = new SlnOperationData(); SlnPublishCommandData.CommandName = Constants.CommandName.Publish; SlnPublishCommandData.FileSystem = fileSystem; SlnPublishCommandData.Subcommand = new PublishNameStrategy(Constants.CommandName.Publish, fileSystem); SlnPublishCommandData.SuccessLoggerMessage = LoggingText.SlnPublishSuccess; SlnPublishCommandData.SuccessOutputMessage = OutputText.SlnPublishSuccess; SlnPublishCommandData.HelpText = HelpTextValues.SlnPublishNameArgumentCommandDescription; var slnStrategies = new ICommand <SlnStrategy>[] { new SlnAddCommandStrategy(fileSystem), new SlnOperationCommandStrategy(SlnBuildCommandData), new SlnOperationCommandStrategy(SlnDeployCommandData), new SlnOperationCommandStrategy(SlnPublishCommandData), new SlnRemoveCommandStrategy(fileSystem), slnHelpStrategy, slnHelpVerboseStrategy, }; var slnStrategyCommandFactory = new CommandFactory <SlnStrategy>(slnStrategies, Constants.SlnCommandOptions.Help); slnHelpStrategy.CommandFactory = slnStrategyCommandFactory; slnHelpVerboseStrategy.CommandFactory = slnStrategyCommandFactory; return(new SlnStrategy(slnStrategyCommandFactory)); }
public Product Create(HelpData additionalData) { return(new MyProduct { Abc = additionalData.SomethingImportantForMyProduct }); }
// APPIO Reference command private static ReferenceStrategy CreateReferenceStrategy(IFileSystem fileSystem) { // Reference command help first lines var referenceHelpStrategyHelpText = new MessageLines { { string.Empty, HelpTextValues.ReferenceFirstLine }, { string.Empty, string.Empty }, { string.Empty, HelpTextValues.GeneralUsage }, { string.Empty, HelpTextValues.ReferenceCallDescription } }; // Reference command arguments var referenceArguments = new MessageLines { { Constants.ReferenceCommandArguments.Add, string.Empty }, { Constants.ReferenceCommandArguments.Remove, string.Empty } }; // Reference command options var clientOption = new StringBuilder(Constants.ReferenceCommandOptions.Client).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseClient).ToString(); var serverOption = new StringBuilder(Constants.ReferenceCommandOptions.Server).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseServer).ToString(); var helpOption = new StringBuilder(Constants.ReferenceCommandOptions.Help).Append(Constants.HelpOptionSeparator).Append(Constants.ReferenceCommandOptions.VerboseHelp).ToString(); var referenceOptions = new MessageLines { { clientOption, HelpTextValues.ReferenceCommandOptionClientDescription }, { serverOption, HelpTextValues.ReferenceCommandOptionServerDescription }, { helpOption, HelpTextValues.OptionHelpDescription }, }; // Reference help strategy var referenceHelpStrategyData = new HelpData { CommandName = Constants.ReferenceCommandOptions.Help, HelpTextFirstLine = referenceHelpStrategyHelpText, Arguments = referenceArguments, Options = referenceOptions, LogMessage = LoggingText.AppioHelpForReferenceCommand, HelpText = HelpTextValues.ReferenceHelpArgumentCommandDescription, }; var referenceHelpStrategy = new HelpStrategy <ReferenceStrategy>(referenceHelpStrategyData); referenceHelpStrategyData.CommandName = Constants.ReferenceCommandOptions.VerboseHelp; var referenceHelpVerboseStrategy = new HelpStrategy <ReferenceStrategy>(referenceHelpStrategyData); var referenceStrategies = new ICommand <ReferenceStrategy>[] { new ReferenceAddCommandStrategy(fileSystem), new ReferenceRemoveCommandStrategy(fileSystem), referenceHelpStrategy, referenceHelpVerboseStrategy, }; var referenceStrategyCommandFactory = new CommandFactory <ReferenceStrategy>(referenceStrategies, Constants.ReferenceCommandOptions.Help); referenceHelpStrategy.CommandFactory = referenceStrategyCommandFactory; referenceHelpVerboseStrategy.CommandFactory = referenceStrategyCommandFactory; return(new ReferenceStrategy(referenceStrategyCommandFactory)); }