/// <summary> /// Writes a line of colored text to the console output. /// </summary> /// <param name="foreground">The foreground color of the text.</param> /// <param name="background">The background color of the text.</param> /// <param name="message">The message to send.</param> /// <param name="args">Optional arguments to use when formatting the message.</param> public static void WriteLine(IConsoleColor foreground, IConsoleColor background, string message, params object[] args) { message = Formatters.GetColorFormattedString(new ColorFormat(foreground, background), message, args); if (!string.IsNullOrEmpty(message)) { if (isLastWriteALine) { WriteLineToConsoles("{0}{1}", headerText, message); } else { WriteLineToConsoles(message); } } else { WriteLine(); } }
public void ConfusionMatrixWithCategories_ValidCategories_ReturnsHtml() { //Arrange var(trainingData, testingData) = TestHelper.LoadData(DATASET_PATH); var model = TestHelper.TrainModel(trainingData); var predictions = model.Transform(testingData); var metrics = TestHelper.MLContext.MulticlassClassification.Evaluate(predictions, "Label", "Score", "PredictedLabel"); var categories = new string[] { "FlashLight", "Infrared", "Day", "Lighter" }; var displayString = @"<table style=""margin: 50px; ""><tbody><tr style=""background-color: transparent""><td colspan=""2"" rowspan=""2"" style=""padding: 8px; background-color: lightsteelblue; text-align: center; "">Confusion Matrix</td>"; Formatters.Register <ConfusionMatrixDisplayView>(); //Act var confusionMatrixWithCategories = metrics.ConfusionMatrix.AddCategories(categories); var expectedString = confusionMatrixWithCategories.ToDisplayString("text/html"); //Assert expectedString.Should().Contain(displayString); }
/// <summary> /// Writes a line of colored text to the console output. /// </summary> /// <param name="colors">The color of the text.</param> /// <param name="message">The message to send.</param> /// <param name="args">Optional arguments to use when formatting the message.</param> public static void WriteLine(ColorFormat colors, string message, params object[] args) { message = Formatters.GetColorFormattedString(colors, message, args); if (!string.IsNullOrEmpty(message)) { if (isLastWriteALine) { WriteLineToConsoles("{0}{1}", headerText, message); } else { WriteLineToConsoles(message); } } else { WriteLine(); } }
private void LinkVerse_Cliked(object sender, RoutedEventArgs e) { if (this.selectedKey.IsNullEmptyOrWhiteSpace()) { MessageDisplay.Show("Please select a Verse."); return; } try { Type linkType = Type.GetType("Bibles.Link.LinkEditor,Bibles.Link"); BibleVerseModel verseModel = this.uxSearchPager .ItemsSource .Items .FirstOrDefault(vk => ((BibleVerseModel)vk).BibleVerseKey == this.selectedKey) .To <BibleVerseModel>(); object[] args = new object[] { Formatters.GetBibleFromKey(this.selectedKey), verseModel }; UserControlBase linkEditor = Activator.CreateInstance(linkType, args) as UserControlBase; string title = $"Link - {GlobalStaticData.Intance.GetKeyDescription(this.selectedKey)}"; linkEditor.Height = this.Height; if (ControlDialog.ShowDialog(title, linkEditor, "AcceptLink", false).IsFalse()) { return; } int selectedVerse = Formatters.GetVerseFromKey(this.selectedKey); } catch (Exception err) { ErrorLog.ShowError(err); } }
public async Task Handle(CommandRequest request) { await request.WriteLine($"Version: {NibriboardServer.Version}"); await request.WriteLine($"Build date: {NibriboardServer.BuildDate.ToString("R")}"); using (Process process = Process.GetCurrentProcess()) { await request.WriteLine($"PID: {process.Id}"); await request.WriteLine($"Private memory usage: {Formatters.HumanSize(process.PrivateMemorySize64)}"); } await request.WriteLine($"Connected clients: {server.AppServer.NibriClients.Count}"); await request.WriteLine($"Planes: {server.PlaneManager.Planes.Count}"); await request.WriteLine($"Total chunks: {server.PlaneManager.Planes.Sum((Plane nextPlane) => nextPlane.TotalSavedChunks)}"); await request.WriteLine($"...of which loaded: {server.PlaneManager.Planes.Sum((Plane nextPlane) => nextPlane.LoadedChunks)}"); }
public override bool TryGet(Type type, out IMessagePackFormatter formatter) { if (!base.TryGet(type, out formatter)) { Type formatterType = null; switch (type) { case Type collectionType when collectionType.IsArray: { formatterType = typeof(CollectionFormatterArray <>).MakeGenericType(collectionType.GetElementType()); break; } case Type collectionType when collectionType.IsConstructedGenericType && collectionType.GetGenericTypeDefinition() == typeof(List <>): { formatterType = typeof(CollectionFormatterList <>).MakeGenericType(collectionType.GenericTypeArguments[0]); break; } case Type collectionType when collectionType.IsConstructedGenericType && collectionType.GetGenericTypeDefinition() == typeof(Dictionary <,>): { Type[] arguments = collectionType.GenericTypeArguments; formatterType = typeof(CollectionFormatterDictionary <,>).MakeGenericType(arguments[0], arguments[1]); break; } } if (formatterType != null) { formatter = (IMessagePackFormatter)Activator.CreateInstance(formatterType, Provider, Context); Formatters.Add(type, formatter); } return(formatter != null); } formatter = null; return(false); }
private void BackColour_Clicked(object sender, RoutedEventArgs e) { if (this.selectedKey.IsNullEmptyOrWhiteSpace() || Formatters.GetVerseFromKey(this.selectedKey) <= 0) { MessageDisplay.Show("Please select a Verse"); return; } try { ColourPicker picker = new ColourPicker(); if (picker.ShowDialog().IsFalse()) { return; } int verseNumber = Formatters.GetVerseFromKey(this.selectedKey); HighlightRitchTextBox textBox = this.loadedTextBoxDictionary[verseNumber]; int start = textBox.GetSelectionStartIndex(); int length = textBox.GetSelectedTextLength(); textBox.HighlightText(start, length, picker.SelectedColour); string bibleVerseKey = Formatters.IsBiblesKey(this.selectedKey) ? this.selectedKey : $"{this.Bible.BibleId}||{this.selectedKey}"; BiblesData.Database.InsertVerseColour(bibleVerseKey, start, length, ColourConverters.GetHexFromBrush(picker.SelectedColour)); } catch (Exception err) { ErrorLog.ShowError(err); } }
private async void solicitarInformacao(IDialogContext context, LuisResult result) { await context.PostAsync("Por favor, veja se algum desses links pode te ajudar:"); try { string SearchFor = ""; foreach (var dt in result.Entities) { if ("InfoEntity".Equals(dt.Type)) { SearchFor = dt.Entity; } } List <SearchResult> SearchList = new List <SearchResult>(PortoSearch.GetPortoSearch(SearchFor)); SearchList.AddRange(MicrosftAPI.BingSearch(SearchFor)); List <Attachment> heroCards = new List <Attachment>(); foreach (SearchResult s in SearchList) { heroCards.Add(Formatters.GetHeroCard( s.Title, s.Desc, s.SubDesc, new CardImage(url: ""), new CardAction(ActionTypes.OpenUrl, "Acessar", value: s.Link)) ); } var reply = context.MakeMessage(); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; reply.Attachments = heroCards; await context.PostAsync(reply); } catch (Exception e) { await context.PostAsync("Desculpe, ocorreu um erro enquanto buscávamos mais informações, por favor tente mais tarde."); } context.Wait(MessageReceived); }
private static string EvaluateTemplateContext(string path, IDictionary <string, object> context) { var splitted = path.Trim('{', '}').Split(':'); var cleanPath = splitted.First().Replace(" ", string.Empty); var pathElements = new Queue <string>(cleanPath.Split('.')); // TODO: this can be expressed in a functional way. // Follow the path in the object's properties. context.TryGetValue(pathElements.Dequeue(), out var obj); while (obj != null && pathElements.Any()) { var pathElement = pathElements.Dequeue(); // Custom operators are priorized. if (CustomOperators.TryGetValue(pathElement, out var customOperator)) { obj = customOperator(obj); continue; } obj = TryDictionaryLookup(obj, pathElement) ?? obj.GetType().GetProperty(pathElement)?.GetValue(obj) ?? obj.GetType().GetMethod(pathElement)?.Invoke(obj, new object[0]); } // Apply formatting if specified. var format = splitted.Skip(1).FirstOrDefault(); if (format != null && Formatters.TryGetValue(format.Trim(), out var formatter)) { obj = formatter(obj); } // Special formatter: Apply string value without quotes into template. if ("rawstring".Equals(format, StringComparison.OrdinalIgnoreCase) && obj is string stringValue) { return(stringValue); } return(JsonConvert.SerializeObject(obj)); }
public void ShouldDetectChange_UpdatedNull() { var detector = new TestEntityChangeDetector(); TestEntity original = new TestEntity() { StringValue = "After" }; TestEntity updated = null; Assert.IsTrue(detector.HasChange(a => a.StringValue, original, updated), "No change detected for the property."); var changes = detector.GetChanges(original, updated); Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected."); IPropertyChange change = changes.Single(); Assert.AreEqual(TestEntityChangeDetector.StringDescription, change.DisplayName, "The wrong property was recorded."); Assert.AreEqual(Formatters.FormatString(original.StringValue), change.FormatOriginalValue(), "The old value was not recorded."); Assert.AreEqual(null, change.FormatUpdatedValue(), "The new value was not recorded."); }
public Outputs Create(Inputs inputs) { LifeCycle lc = new LifeCycle(inputs.ENozzle1, inputs.ENozzle2, inputs.ENozzle3); Behavior <Double> litersDelivered = Accumulate(lc.EStart.Map(u => Unit.UNIT), inputs.EFuelPulses, inputs.Calibration); return(new Outputs() .SetDelivery(lc.FillActive.Map( Of => Of.Equals(Optional <Fuel> .Of(Fuel.ONE)) ? Delivery.FAST1 : Of.Equals(Optional <Fuel> .Of(Fuel.TWO)) ? Delivery.FAST2 : Of.Equals(Optional <Fuel> .Of(Fuel.THREE)) ? Delivery.FAST3 : Delivery.OFF)) .SetSaleQuantityLcd(litersDelivered.Map( q => Formatters.FormatSaleQuantity(q)))); }
static ExportDescriptorPromise[] GetLazyDefinitions <TValue, TMetadata>(CompositionContract lazyContract, DependencyAccessor definitionAccessor) { var metadataProvider = MetadataViewProvider.GetMetadataViewProvider <TMetadata>(); return(definitionAccessor.ResolveDependencies("value", lazyContract.ChangeType(typeof(TValue)), false) .Select(d => new ExportDescriptorPromise( lazyContract, Formatters.Format(typeof(Lazy <TValue, TMetadata>)), false, () => new[] { d }, _ => { var dsc = d.Target.GetDescriptor(); var da = dsc.Activator; return ExportDescriptor.Create((c, o) => { return new Lazy <TValue, TMetadata>(() => (TValue)CompositionOperation.Run(c, da), metadataProvider(dsc.Metadata)); }, dsc.Metadata); })) .ToArray()); }
private static UIElement[] GetVerseNumberElements(int bibleId, BibleVerseModel verse) { UIElement[] result = new UIElement[5]; Label labelVerse = new Label { Content = Formatters.GetVerseFromKey(verse.BibleVerseKey), Foreground = Brushes.LightGray, Tag = verse }; result[0] = labelVerse; result[1] = BibleLoader.GetVerseBookmarkImage(bibleId, verse.BibleVerseKey); result[2] = BibleLoader.GetStudyBookmarkImage(bibleId, verse.BibleVerseKey); result[3] = BibleLoader.GetLinkImage(verse.BibleVerseKey); result[4] = BibleLoader.GetNotesImage(verse.BibleVerseKey); return(result); }
public override bool TryGet(Type type, out IMessagePackFormatter formatter) { if (!base.TryGet(type, out formatter)) { object formatterInner = Resolver.GetFormatterDynamic(type); if (formatterInner != null) { Type formatterType = typeof(MessagePackFormatterWrapper <>).MakeGenericType(type); formatter = (IMessagePackFormatter)Activator.CreateInstance(formatterType, this, Context, formatterInner, Resolver); Formatters.Add(type, formatter); return(true); } } return(formatter != null); }
public List <InventoryDto> GetAllInventory(InventoryDto input) { var query = (from Inventory in _context.Inventory.ToList() select new InventoryDto { Name = Inventory.Name, Description = Inventory.Description, Id = Inventory.Id, CostPrice = Formatters.FormatAmount(Inventory.CostPrice), SellingPrice = Formatters.FormatAmount(Inventory.SellingPrice), Quantity = Inventory.Quantity, DateCreated = Inventory.DateCreated, Status = Inventory.Status, UserId = Inventory.UserId }).ToList(); // Map Records List <InventoryDto> invDto = MappingProfile.MappingConfigurationSetups().Map <List <InventoryDto> >(query); if (input.PagedResultDto != null) { //Apply Sort invDto = Sort(input.PagedResultDto.Sort, input.PagedResultDto.SortOrder, invDto); // Apply search if (!string.IsNullOrEmpty(input.PagedResultDto.Search)) { invDto = invDto.Where(p => p.Status != null && p.Status.ToLower().ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.Name != null && p.Name.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.Description != null && p.Name.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.CostPrice != null && p.CostPrice.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.SellingPrice != null && p.CostPrice.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.Quantity != null && p.Quantity.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.DateCreated != null && p.DateCreated.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) || p.Name != null && p.Name.ToString().ToLower().ToString().Contains(input.PagedResultDto.Search.ToLower()) ).ToList(); } } return(invDto); }
public void SetVerse(string bibleVerseKey) { try { if (bibleVerseKey.IsNullEmptyOrWhiteSpace()) { bibleVerseKey = "01O||1||1"; } string bookKey = $"{Formatters.GetBookFromKey(bibleVerseKey)}||"; string chapterKey = $"{bookKey}{Formatters.GetChapterFromKey(bibleVerseKey)}||"; string verseKey = $"{chapterKey}{Formatters.GetVerseFromKey(bibleVerseKey)}||"; if (Formatters.IsOldTestament(bibleVerseKey)) { BookModel book = this.OldTestamentBooks.FirstOrDefault(b => b.BookKey == bookKey); this.SelectedOldTestamentBook = book; } else { BookModel book = this.NewTestamentBooks.FirstOrDefault(b => b.BookKey == bookKey); this.SelectedNewTestamentBook = book; } ChapterModel chapter = this.bookChapters.FirstOrDefault(c => c.ChapterKey == chapterKey); this.SelectedChapter = chapter; VerseModel verse = this.ChapterVerses.FirstOrDefault(v => v.VerseKey == verseKey); this.SelectedVerse = verse; } catch { // DO NOTHING, We would not like to have things fall over } }
private void LoadSearchResults(BibleVerseModel[] result) { foreach (BibleVerseModel row in result) { this.uxResultGrid.RowDefinitions.Add(this.GetRowDefinition()); if (this.showBibleColumn) { int bibleId = Formatters.GetBibleFromKey(row.BibleVerseKey); LableItem bible = new LableItem { Content = this.bibleNames[bibleId] }; this.SetUiElementPosition(bible, 0); } LableItem verse = new LableItem { Content = GlobalStaticData.Intance.GetKeyDescription(row.BibleVerseKey) }; this.SetUiElementPosition(verse, 1); HighlightRitchTextBox text = new HighlightRitchTextBox { Text = row.VerseText, Tag = row, BorderBrush = Brushes.Transparent, IsReadOnly = true, Margin = new Thickness(2, 0, 0, 15) }; text.GotFocus += this.Verse_GotFocus; text.HighlightText(this.searchSplitResult); this.SetUiElementPosition(text, 2); ++this.rowIndex; } }
public void ShouldIncludeChangeToDoubleDerivedProperty() { var detector = new DoubleDerivedChangeDetector(); DoubleDerivedEntity original = new DoubleDerivedEntity() { DoubleDerivedValue = "John" }; DoubleDerivedEntity updated = new DoubleDerivedEntity() { DoubleDerivedValue = "Tom" }; var changes = detector.GetChanges(original, updated); Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected."); IPropertyChange change = changes.Single(); Assert.AreEqual(DoubleDerivedChangeDetector.DoubleDerivedDescription, change.DisplayName, "The wrong property was recorded."); Assert.AreEqual(Formatters.FormatString(original.DoubleDerivedValue), change.FormatOriginalValue(), "The old value was not recorded."); Assert.AreEqual(Formatters.FormatString(updated.DoubleDerivedValue), change.FormatUpdatedValue(), "The new value was not recorded."); }
private HttpClient Configure(FluentHttpClientOptions options) { var httpHandler = new FluentMiddlewareHttpHandler( _middlewareRunner, this, _requestTracker, options.HttpMessageHandler ); var httpClient = new HttpClient(httpHandler) { BaseAddress = new Uri(options.BaseUrl) }; httpClient.DefaultRequestHeaders.Add(HeaderTypes.Accept, Formatters.SelectMany(x => x.SupportedMediaTypes).Select(x => x.MediaType)); httpClient.Timeout = options.Timeout; httpClient.DefaultRequestHeaders.AddRange(options.Headers); return(httpClient); }
public ActionResult GetResistanceValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor) { try { ColorCodes colorCodes = new ColorCodes(); // Call library method to calculcate the resistance value. double ohmValue = _ohmCalculator.CalculateOhmValue(bandAColor, bandBColor, bandCColor, bandDColor); var tolerance = colorCodes.Tolerance[bandDColor].Item2; string resistance = Formatters.FormatResistance(ohmValue, tolerance); /// return JSON response return(Json(new { resistance = resistance }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Trace.TraceError(ex.Message); throw ex; } }
public void WriteToBuffer(string msg) { if (string.IsNullOrEmpty(msg)) { return; } var encoder = new ASCIIEncoding(); var clientStream = TcpClient.GetStream(); try { foreach (var formattedString in Formatters.Select(formatter => formatter.Format(msg))) { clientStream.Write(encoder.GetBytes(formattedString), 0, formattedString.Length); } clientStream.Flush(); } catch (ArgumentNullException ex) { ex.Handle(ExceptionHandlingOptions.RecordAndThrow, Log); } catch (ArgumentOutOfRangeException ex) { ex.Handle(ExceptionHandlingOptions.RecordAndThrow, Log); } catch (IOException ex) { ex.Handle(ExceptionHandlingOptions.RecordAndThrow, Log); } catch (ObjectDisposedException ex) { ex.Handle(ExceptionHandlingOptions.RecordAndThrow, Log); } catch (InvalidOperationException ex) { ex.Handle(ExceptionHandlingOptions.RecordAndThrow, Log); } }
private void Right_Cliked(object sender, RoutedEventArgs e) { try { int chapter = Formatters.GetChapterFromKey(this.selectedKey); ++chapter; this.PageToChapter(chapter); this.BookChanged?.Invoke(this, this.selectedKey); if (this.versesDictionaryLeft.ContainsKey(Formatters.GetVerseFromKey(this.selectedKey))) { this.SelectedVerseChanged?.Invoke(this, this.versesDictionaryLeft[Formatters.GetVerseFromKey(this.selectedKey)]); } } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Reader_Loaded(object sender, RoutedEventArgs e) { if (base.WasFirstLoaded) { return; } try { this.ScrollToVerse(this.scrollOnLoadVerse); this.scrollOnLoadVerse = -1; base.WasFirstLoaded = true; this.SetCanPage(Formatters.GetChapterFromKey(this.selectedKey)); } catch (Exception err) { ErrorLog.ShowError(err); } }
public List <List <Ephemeris> > GetEphemerides(CelestialObject body, double from, double to, double step, IEnumerable <string> categories, CancellationToken?cancelToken = null, IProgress <double> progress = null) { List <List <Ephemeris> > ephemerides = new List <List <Ephemeris> >(); var config = EphemConfigs[body.GetType()]; var itemsToBeCalled = config.Filter(categories); for (double jd = from; jd < to; jd += step) { if (cancelToken != null && cancelToken.Value.IsCancellationRequested) { break; } else { progress?.Report((jd - from) / (to - from) * 100); } var context = new SkyContext(jd, Context.GeoLocation); List <Ephemeris> ephemeris = new List <Ephemeris>(); foreach (var item in itemsToBeCalled) { ephemeris.Add(new Ephemeris() { Key = item.Category, Value = item.Formula.DynamicInvoke(context, body), Formatter = item.Formatter ?? Formatters.GetDefault(item.Category) }); } ephemerides.Add(ephemeris); } return(ephemerides); }
private void Verse_GotFocus(object sender, RoutedEventArgs e) { try { HighlightRitchTextBox box = (HighlightRitchTextBox)sender; this.selectedKey = Formatters.RemoveBibleId(((BibleVerseModel)box.Tag).BibleVerseKey); this.SetHeader(); this.SelectedVerseChanged?.Invoke(this, this.versesDictionary[Formatters.GetVerseFromKey(this.selectedKey)]); if (this.uxStrongs != null) { this.uxStrongs.BibleId = this.Bible.BibleId; this.uxStrongs.VerseKey = this.selectedKey; } if (this.uxHebrew != null) { this.uxHebrew.BibleId = this.Bible.BibleId; this.uxHebrew.VerseKey = this.selectedKey; } if (this.uxGreek != null) { this.uxGreek.BibleId = this.Bible.BibleId; this.uxGreek.VerseKey = this.selectedKey; } } catch (Exception err) { ErrorLog.ShowError(err); } }
private TableInfo GetTableInfo(string schemaName, string tableName) { var fullTableName = $"{QuoteName(schemaName)}.{QuoteName(tableName)}"; var table = new TableInfo(fullTableName); using (var columnsCommand = _connection.CreateCommand()) { columnsCommand.CommandText = ColumnsCommand; columnsCommand.Parameters.Add(SchemaParam, SqlDbType.NVarChar); columnsCommand.Parameters.Add(TableParam, SqlDbType.NVarChar); columnsCommand.Parameters.Add(SchemaAndTableParam, SqlDbType.NVarChar); columnsCommand.Parameters[SchemaParam].Value = schemaName; columnsCommand.Parameters[TableParam].Value = tableName; columnsCommand.Parameters[SchemaAndTableParam].Value = fullTableName; using (var metaReader = columnsCommand.ExecuteReader()) { while (metaReader.Read()) { var columnName = metaReader.GetString(0); var typeName = metaReader.GetString(1); var isSorted = !metaReader.IsDBNull(2); table.Columns.Add(columnName); if (isSorted) { table.SortColumns.Add(columnName); } columnName = QuoteName(columnName); if (Formatters.IsSpecialType(typeName)) { columnName = $"{columnName}.ToString() as {columnName}"; } table.SelectList.Add(columnName); } } } return(table); }
public UnloadedModulesView(MiniDumpUnloadedModulesStream unloadedModulesStream) : this() { _unloadedModulesStream = unloadedModulesStream; if (unloadedModulesStream.NumberOfEntries == 0) { this.listView1.Items.Add("No data found for stream"); return; } foreach (MiniDumpUnloadedModule unloadedModule in _unloadedModulesStream.Entries) { ListViewItem newItem = new ListViewItem(unloadedModule.ModuleName); newItem.SubItems.Add(Formatters.FormatAsSizeString(unloadedModule.SizeOfImage)); newItem.SubItems.Add(unloadedModule.TimeDateStamp.ToString()); newItem.SubItems.Add(Formatters.FormatAsMemoryAddress(unloadedModule.BaseOfImage)); newItem.Tag = unloadedModule; this.listView1.Items.Add(newItem); } }
public void SelectVerse(string key) { if (key.IsNullEmptyOrWhiteSpace()) { return; } this.SetCanPage(Formatters.GetChapterFromKey(key)); this.selectedKey = key; this.SetHeader(); // Causes a stack overflow //int verseNumber = Formatters.GetVerseFromKey(key); //if (verseNumber > 0 && this.loadedTextBoxDictionary.ContainsKey(verseNumber)) //{ // HighlightRitchTextBox verseBox = this.loadedTextBoxDictionary[verseNumber]; // verseBox.Focus(); //} }
/// <summary> /// Writes a debug message to the console, using the console's DebugColors ColorFormat. /// </summary> /// <param name="obj">The object the message is originating from. Can be null.</param> /// <param name="message">The message to write.</param> /// <param name="args">Optional arguments to use when formatting the message.</param> public static void WriteDebugLine(object obj, string message, params object[] args) { try { if (Options.Instance.DebugLevels.Contains(DebugLevels.Debug) && IsValid(obj)) { message = Formatters.GetColorFormattedString(ConsoleBase.Colors.Debug, message, args); if (isLastWriteALine) { var headerColors = GetHeaderColors(obj); var header = Formatters.GetColorFormattedString(headerColors, GetMessageHeaderWithTimestamp(obj)); ForceWriteLine("{0}{1}", header, message); } else { ForceWriteLine(Formatters.GetColorFormattedString(ConsoleBase.Colors.Debug, message, args)); } } } catch { } }
private static ExportDescriptorPromise[] GetExportFactoryDescriptors <TProduct>(CompositionContract exportFactoryContract, DependencyAccessor definitionAccessor) { var productContract = exportFactoryContract.ChangeType(typeof(TProduct)); var boundaries = EmptyArray <string> .Value; IEnumerable <string> specifiedBoundaries; CompositionContract unwrapped; if (exportFactoryContract.TryUnwrapMetadataConstraint(Constants.SharingBoundaryImportMetadataConstraintName, out specifiedBoundaries, out unwrapped)) { productContract = unwrapped.ChangeType(typeof(TProduct)); boundaries = (specifiedBoundaries ?? EmptyArray <string> .Value).ToArray(); } return(definitionAccessor.ResolveDependencies("product", productContract, false) .Select(d => new ExportDescriptorPromise( exportFactoryContract, Formatters.Format(typeof(ExportFactory <TProduct>)), false, () => new[] { d }, _ => { var dsc = d.Target.GetDescriptor(); var da = dsc.Activator; return ExportDescriptor.Create((c, o) => { return new ExportFactory <TProduct>(() => { var lifetimeContext = new LifetimeContext(c, boundaries); return Tuple.Create <TProduct, Action>((TProduct)CompositionOperation.Run(lifetimeContext, da), lifetimeContext.Dispose); }); }, dsc.Metadata); })) .ToArray()); }
/// <summary> /// Sets formatter with default formatoptions (as set in language file) /// </summary> /// <param name = "formatter">Formatter</param> public Column SetFormatter(Formatters formatter) { if (!string.IsNullOrEmpty(_customFormatter.Trim())) { throw new Exception( "You cannot set a formatter and a customformatter at the same time, please choose one."); } _formatter = new KeyValuePair<Formatters, string>(formatter, ""); return this; }
/// <summary> /// /// </summary> /// <param name = "formatter"></param> /// <param name = "customFormatter"></param> /// <param name = "formatOptions"></param> public Column SetFormatter(Formatters formatter = Formatters.Custom, string customFormatter = null, string formatOptions = "") { _customFormatter = customFormatter; _formatter = formatter; _formatOptions = formatOptions; return this; }
public ExportManager(Formatters.IMetaFormatter formatter) { _Formatter = formatter; }
/// <summary> /// Sets formatter with formatoptions (see jqGrid documentation for more info on formatoptions) /// </summary> /// <param name="formatter">Formatter</param> /// <param name="formatOptions">Formatoptions</param> public Column SetFormatter(Formatters formatter, string formatOptions) { if (!string.IsNullOrWhiteSpace(this.customFormatter)) { throw new Exception("You cannot set a formatter and a customformatter at the same time, please choose one."); } this.formatter = new KeyValuePair<Formatters, string>(formatter, formatOptions); return this; }
/// <summary> /// Writes the data contained in this instance to the given html text writer. /// </summary> internal void WriteTo(Formatters.HtmlTextWriter writer) { var buffer = writer.Buffer; for (var i = 0; i < this._partCounter; i++) { if (buffer.Length < this._parts[i].Length) buffer = writer.Buffer = new char[this._parts[i].Length]; this._parts[i].Source.CopyTo(this._parts[i].StartIndex, buffer, 0, this._parts[i].Length); writer.Write(buffer, 0, this._parts[i].Length); } }