public static IHost BuildHost(string[] args, TextRepository repo, Dispatcher dispatcher, int port = 15000) { return(CreateHostBuilder(args, repo, dispatcher, port).Build()); }
public IActionResult Status(string id) { Console.WriteLine("status requested for id=" + id); var repo = new TextRepository(); return(Ok(repo.GetTextStatus(id).ToString())); }
public GalleryElementDetailsViewModel(ITextAssetsRepository textRepository, ArtPiece artPiece, string returnUrl, HttpContext context) : base(textRepository) { LabelValueDict = new Dictionary <string, string>(); ArtPiece = artPiece; ImageUri = artPiece.ImageUri; ForSale = artPiece.ForSale; ReturnUrl = returnUrl; if (textRepository.GetTranslatedValue(artPiece.Name, context) != null) { LabelValueDict[textRepository.GetTranslatedValue("name", context)] = TextRepository.GetTranslatedValue(artPiece.Name, context); } if (textRepository.GetTranslatedValue(artPiece.Description, context) != null) { LabelValueDict[textRepository.GetTranslatedValue("description", context)] = TextRepository.GetTranslatedValue(artPiece.Description, context); } LabelValueDict[textRepository.GetTranslatedValue("technique", context)] = textRepository.GetTranslatedValue(artPiece.Technique.Name, context); if (artPiece.CreationDate != null) { LabelValueDict[textRepository.GetTranslatedValue("creation_date", context)] = artPiece.CreationDate; } if (textRepository.GetTranslatedValue(artPiece.AdditionalInfo, context) != null) { LabelValueDict[textRepository.GetTranslatedValue("additional_info", context)] = TextRepository.GetTranslatedValue(artPiece.AdditionalInfo, context); } }
public Text AddToFooter(Guid footerId, Text text) { if (FooterRepository.Exists(footerId)) { Footer footer = FooterRepository.GetById(footerId); footer.StyleClass = null; Footer footerForText = footer; Content contentOfFooter = footerForText.Content; IEnumerable <Text> footerTexts = TextRepository.GetByContent(contentOfFooter); if (footerTexts.Count() == 0) { text.Id = Guid.NewGuid(); text.Position = 0; text.ContentThatBelongs = contentOfFooter; TextRepository.Add(text); return(text); } else { throw new ExistingTextException("There is an existing text in the selected footer."); } } else { throw new MissingFooterException("This footer does not exist in the database"); } }
public void TestStringFormat() { var tr = new TextRepository(new[] { textRu, textEn }); Assert.AreEqual(tr.Translations["app.main.shop"], "Магазин"); Assert.AreEqual(tr.Get("app.main.shop"), "Магазин"); }
public void Update(Guid textId, Text newTextData) { if (TextRepository.Exists(textId)) { Text textToUpdate = TextRepository.GetById(textId); if (textToUpdate.Position != newTextData.Position) { IEnumerable <Text> textsInContent = TextRepository.GetByContent(textToUpdate.ContentThatBelongs); int newPosition = newTextData.Position; int maxPosition = textsInContent.Count() - 1; if (newPosition > maxPosition || newPosition < 0) { throw new InvalidPositionException("This position is not valid for the content in question."); } else { Text swappedText = textsInContent.First(p => p.Position == newPosition); swappedText.Position = textToUpdate.Position; TextRepository.Update(swappedText); textToUpdate.Position = newPosition; } } if (newTextData.StyleClass != null && !StyleClassRepository.Exists(newTextData.StyleClass.Name)) { newTextData.StyleClass = null; } textToUpdate.StyleClass = newTextData.StyleClass; textToUpdate.TextContent = newTextData.TextContent; TextRepository.Update(textToUpdate); } else { throw new MissingParagraphException("This paragraph is not in the database."); } }
public void LogModificationToText(Guid textId) { if (TextRepository.Exists(textId)) { Text textOfModdedDocument = TextRepository.GetById(textId); Content contentOfModdedDocument = textOfModdedDocument.ContentThatBelongs; if (HeaderRepository.ExistsWithContent(contentOfModdedDocument)) { Header headerOfModdedDocument = HeaderRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(headerOfModdedDocument.DocumentThatBelongs.Id); } else if (ParagraphRepository.ExistsWithContent(contentOfModdedDocument)) { Paragraph paragraphOfModdedDocument = ParagraphRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(paragraphOfModdedDocument.DocumentThatBelongs.Id); } else if (FooterRepository.ExistsWithContent(contentOfModdedDocument)) { Footer footerOfModdedDocument = FooterRepository.GetByContent(contentOfModdedDocument); LogModificationToDocument(footerOfModdedDocument.DocumentThatBelongs.Id); } } else { throw new MissingTextException("This text is not in the database."); } }
public Text AddToHeader(Guid headerId, Text text) { if (HeaderRepository.Exists(headerId)) { Header header = HeaderRepository.GetById(headerId); header.StyleClass = null; Header headerForText = header; Content contentOfHeader = headerForText.Content; IEnumerable <Text> headerTexts = TextRepository.GetByContent(contentOfHeader); if (headerTexts.Count() == 0) { text.Id = Guid.NewGuid(); text.Position = 0; text.ContentThatBelongs = contentOfHeader; TextRepository.Add(text); return(text); } else { throw new ExistingTextException("There is an existing text in the selected header."); } } else { throw new MissingHeaderException("This header does not exist in the database"); } }
public IActionResult Statistics() { Console.WriteLine("statistics requested"); var repo = new TextRepository(); string json = repo.GetStatsReport(); return(Ok(json)); }
public void oneTimeSetUp() { var connection = DbConnectionFactory.CreateTransient(); this.ctx = new ApplicationDbContext(connection); this.repo = new TextRepository(ctx); new DatabaseSeeder().CreateDependenciesAndSeed(ctx);//heavy duty }
public TextEditorPresenter(TextRepository repo) { Repository = repo; Repository.PropertyChanged += (_, _) => { OnPropertyChanged(nameof(ControledTextArea)); }; }
public void Initialize() { _repo = ContainerHelper.Container.Resolve <TextRepository>(); _privateRepo = new PrivateObject(_repo); if (Directory.Exists(TEXT_FOLDER_PATH)) { Directory.Delete(TEXT_FOLDER_PATH, true); } }
public void TestCreateRepository() { TextRepository tr = new TextRepository(new[] { textRu, textEn }); Assert.AreEqual(tr.Translations["app.main.shop"], "Магазин"); Assert.AreEqual(tr.Translations["app.main.tournament"], "Tournament"); tr = new TextRepository(new[] { textEn, textRu }); Assert.AreEqual(tr.Translations["app.main.shop"], "Shop"); Assert.AreEqual(tr.Translations["app.main.tournament"], "Tournament"); }
private string ApplyFooterStyles(Footer footer, Format format, IEnumerable <Style> formerStyles) { IEnumerable <Style> currentStyles = GetStylesWithInheritance(footer.StyleClass, format); currentStyles = MergeStyles(currentStyles, formerStyles); IEnumerable <Text> textsToApply = TextRepository.GetByContent(footer.Content); string appliedHtmlCode = "" + ApplyTextStyles(textsToApply, format, currentStyles); return(appliedHtmlCode); }
public string Post([FromBody] UploadModel model) { var repo = new TextRepository(); string id = repo.CreateText(model.Data); var messages = new TextMessages(); messages.SendTextCreated(id); return(id); }
static void Main(string[] args) { var repo = new TextRepository(); var messages = new TextMessages(); Console.WriteLine("Listening for ExchangeText event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueTextListener, TextMessages.ExchangeText, (model, id) => { var text = repo.GetText(id); Console.WriteLine(id + ": " + text); }); }
public Text GetById(Guid textId) { if (TextRepository.Exists(textId)) { return(TextRepository.GetById(textId)); } else { throw new MissingTextException("This text is not in the database."); } }
static void Main(string[] args) { Console.WriteLine("Reading CSV file"); //Openning file var csvFile = new StreamReader(Environment.CurrentDirectory + "\\ExcelTemplate\\TranslationTemplate.csv",Encoding.Default); string [] lineArray; string[] header; // Setting the repository saver var translationRep = new TextRepository_SQLToJSON(true); TextRepository translation; IdiomTranslation idiomTranslation; int contLines = 0; // Reading the header, to define how many idioms we got header = csvFile.ReadLine().Split(";".ToCharArray()); // Reading all the content do { translation = new TextRepository(); // Separate to array lineArray = csvFile.ReadLine().Split(";".ToCharArray()); translation.DOMElementID = lineArray[0]; // Only add a new translation, if it have a value if (translation.DOMElementID != "") { //Adding all idiom that exists for (int contColunms = 1; contColunms < header.Length; contColunms++) { idiomTranslation = new IdiomTranslation(); idiomTranslation.IdiomName = header[contColunms]; // Adding the title of the column, who have the idiom name idiomTranslation.Translation = lineArray[contColunms]; translation.AddTranslation(idiomTranslation); } // Saving the configuration of the idiom to the repository translationRep.SaveTextRepository(translation); } contLines ++; Console.WriteLine("Saving line " + contLines); } while (csvFile.EndOfStream == false ); // Finishing the text repository Console.WriteLine("The save operation is finish."); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Reading CSV file"); //Openning file var csvFile = new StreamReader(Environment.CurrentDirectory + "\\ExcelTemplate\\TranslationTemplate.csv", Encoding.Default); string [] lineArray; string[] header; // Setting the repository saver var translationRep = new TextRepository_SQLToJSON(true); TextRepository translation; IdiomTranslation idiomTranslation; int contLines = 0; // Reading the header, to define how many idioms we got header = csvFile.ReadLine().Split(";".ToCharArray()); // Reading all the content do { translation = new TextRepository(); // Separate to array lineArray = csvFile.ReadLine().Split(";".ToCharArray()); translation.DOMElementID = lineArray[0]; // Only add a new translation, if it have a value if (translation.DOMElementID != "") { //Adding all idiom that exists for (int contColunms = 1; contColunms < header.Length; contColunms++) { idiomTranslation = new IdiomTranslation(); idiomTranslation.IdiomName = header[contColunms]; // Adding the title of the column, who have the idiom name idiomTranslation.Translation = lineArray[contColunms]; translation.AddTranslation(idiomTranslation); } // Saving the configuration of the idiom to the repository translationRep.SaveTextRepository(translation); } contLines++; Console.WriteLine("Saving line " + contLines); } while (csvFile.EndOfStream == false); // Finishing the text repository Console.WriteLine("The save operation is finish."); Console.ReadLine(); }
static void Main(string[] args) { var messages = new TextMessages(); var repo = new TextRepository(); var stats = new TextStatsReport(); Console.WriteLine("Listening for TextScoreTask event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueTextStatistics, TextMessages.ExchangeTextRankCalculated, (model, json) => { TextRankCalculatedMessage message = TextRankCalculatedMessage.FromJson(json); stats.AddRankResult(message.Score); repo.SetStatsReport(stats.ToJson()); }); }
static void Main(string[] args) { var messages = new TextMessages(); var repo = new TextRepository(); var metrics = new TextMetrics(); Console.WriteLine("Listening for ExchangeTextRankCalculated event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueTextSuccessMarker, TextMessages.ExchangeTextRankCalculated, (model, json) => { var message = TextRankCalculatedMessage.FromJson(json); bool isTextSuccessful = (message.Score > minSuccessfulScore); messages.SendTextSuccessMarked(message.ContextId, isTextSuccessful); }); }
public void Configure( IApplicationBuilder app, TextRepository repo, Dispatcher dispatcher) { app.UseWebSockets(); app.Use(async(context, _) => { var start = context.Request.Query["start"]; var result = dispatcher.Invoke(() => context.RepositoryAsync(repo, start)); await result; }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var repo = new TextRepository(); var mainWindow = new MainWindow { DataContext = new MainWindowPresenter(repo) }; mainWindow.Show(); }
public IEnumerable <Text> GetAllByParagraph(Guid paragraphId) { if (ParagraphRepository.Exists(paragraphId)) { Paragraph paragraphForText = ParagraphRepository.GetById(paragraphId); Content contentFromParagraph = paragraphForText.Content; IEnumerable <Text> paragraphTexts = TextRepository.GetByContent(contentFromParagraph); return(paragraphTexts); } else { throw new MissingParagraphException("The paragraph is not in the database."); } }
static void Main(string[] args) { var messages = new TextMessages(); var repo = new TextRepository(); Console.WriteLine("Listening for TextScoreTask event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueVowelConsRater, TextMessages.ExchangeTextScoreTask, (model, message) => { VowelConsCountMessage count = VowelConsCountMessage.FromJson(message); string id = count.ContextId; float score = (float)count.VowelCount / (float)count.ConsCount; repo.SetTextScore(id, score); Console.WriteLine(id + " score: " + score); messages.SendTextRankCalculated(id, score); }); }
public void TestNewLineFormat() { var deserializer = new Deserializer(); var obj = (Dictionary <object, object>)deserializer.Deserialize( new StringReader(textRu), typeof(Dictionary <object, object>) ); Console.WriteLine("SR:" + Smart.Format("{app.main.demo}", obj)); Console.WriteLine(textRu); var tr = new TextRepository(new[] { textRu }); Console.WriteLine(tr.Get("app.main.demo")); }
static void Main(string[] args) { var messages = new TextMessages(); var repo = new TextRepository(); var metrics = new TextMetrics(); Console.WriteLine("Listening for ExchangeProcessingAccepted event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueTextRancCalc, TextMessages.ExchangeProcessingAccepted, (model, json) => { var message = TextProcessingAcceptedMessage.FromJson(json); if (message.Accepted) { messages.SendTextRankTask(message.ContextId); } }); }
public LabelWithLocalizationTest() { fontCore = new FakeFontCore("default"); font = new Font(fontCore); fontProvider = new FontProvider(); fontProvider.Add("default", font); textRepo = new TextRepository(); contentLayout = new LocalizedContentLayoutEngine( new ContentLayoutEngine(fontProvider), textRepo); context = CommonMocks.RenderContext(contentLayout); }
public void TextDiff() { var repo = new TextRepository(); repo.UpdateText(new[] { "s", "t", "r", "i", "n", "g" }); Assert.AreEqual("s t r i n g", string.Join(' ', repo.WorkSpace.List)); repo.UpdateText(new[] { "s", "t", "r", "e", "n", "g", "t", "h2" }); Assert.AreEqual("s t r e n g t h2", string.Join(' ', repo.WorkSpace.List)); var last = repo.Commits.ToList()[1]; var lastJson = JsonConvert.SerializeObject(last); Assert.IsTrue(lastJson.Length < 300); Console.WriteLine(lastJson.Length); Console.WriteLine(lastJson); }
private string ApplyParagraphStyles(IEnumerable <Paragraph> paragraphs, Format format, IEnumerable <Style> formerStyles) { paragraphs = paragraphs.OrderBy(p => p.Position); string appliedHtmlCode = ""; for (int i = 0; i < paragraphs.Count(); i++) { Paragraph selectedParagraph = paragraphs.ElementAt(i); IEnumerable <Style> currentStyles = GetStylesWithInheritance(selectedParagraph.StyleClass, format); currentStyles = MergeStyles(currentStyles, formerStyles); IEnumerable <Text> textsToApply = TextRepository.GetByContent(selectedParagraph.Content); string textsWithGeneratedHtml = ApplyTextStyles(textsToApply, format, currentStyles); appliedHtmlCode = appliedHtmlCode + "<br>" + textsWithGeneratedHtml; } return(appliedHtmlCode); }
public static IHostBuilder CreateHostBuilder( string[] args, TextRepository repo, Dispatcher dispatcher, int port) { return(Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseUrls($"http://*:{port}"); webBuilder.UseStartup <ServerStartup>(); webBuilder.ConfigureServices(services => { services.AddSingleton(dispatcher); services.AddSingleton(repo); }); })); }