public DocumentEventHandler( IDocumentLocator locator, IDocumentFormatter formatter) { this.locator = locator; this.formatter = formatter; }
public DocumentFormatService(DTE dte, Func <Document, IConfiguration> getGeneralCfg) { this.dte = dte; this.getGeneralCfg = getGeneralCfg; formatter = new VisualStudioCommandFormatter(dte); }
public ReportComposer(IReport report, IDocumentFormatter docFormattter, IReportPrinter reportPrinter) { report.formatDocumet(); string data = report.getData(); reportPrinter.printReport(data); }
private void WriteBuildType(BuildType bt, DirectoryInfo Directory, IDocumentFormatter Formatter) { // Create a factory for determining the DocumentFormatter; var docBuilder = new BuildTypeDocumentBuilder(Directory, bt, Formatter); docBuilder.Write(); }
private static ContentInfo CreateBuildContent(Build build, IDocumentFormatter Formatter) { StringBuilder sb = new StringBuilder(); using (StringWriter writer = new StringWriter(sb)) //(stream, Encoding.UTF8)) { writer.WriteLine(Formatter.Header2(Formatter.Url(build.WebUrl, build.Number))); writer.WriteLine(Formatter.StartList()); if (build.Changes == null) { writer.WriteLine(Formatter.ListItem("No Changes recorded for build.")); } else { foreach (var c in build.Changes) { writer.WriteLine(Formatter.ListItem(String.Format("{0:MM/dd/yyyy H:mm:ss zzz}", c.Date.ConvertToDateTime()) + ": " + c.ChangeDetails?.Comment.TrimEnd(writer.NewLine.ToCharArray()) + " (" + c.ChangeDetails?.Username + ")")); } } writer.WriteLine(Formatter.EndList()); writer.Flush(); var si = new ContentInfo() { Content = sb.ToString(), SortOrder = build.SortOrder, Id = build.Id }; return(si); } }
public DocumentFormatService(DTE dte, Func<ExtensionsCfg> getExtensionCfg) { this.dte = dte; this.getExtensionCfg = getExtensionCfg; var formatCmd = new VisualStudioCommand("Edit.FormatDocument"); formatter = new VisualStudioCommandFormatter(dte, formatCmd); }
public ReportComposer(IDataReader dataReader, IDocumentFormatter documentFormatter, IReportPrinter reportPrinter) { this.dataReader = dataReader; this.documentFormatter = documentFormatter; this.reportPrinter = reportPrinter; }
public BuildTypeDocumentBuilder(DirectoryInfo Directory, BuildType BType, IDocumentFormatter formatter) { _bType = BType; _directory = Directory; _formatter = formatter; AddSortOrder(_bType); _filePath = Path.Combine(Directory.FullName, String.Format("{0}.{1}", FileHelper.GetSafeName(_bType.Name), _formatter.FileSuffix)); }
public DocumentsController(IDirectoryBrowser browser, IDocumentFormatter formatter) { if (browser == null) { throw new ArgumentNullException("browser"); } if (formatter == null) { throw new ArgumentNullException("formatter"); } this._browser = browser; this._formatter = formatter; }
public When_I_call_document_printer() { var fixture = new Fixture(); document = fixture.Create<MergedDocument>(); formattedDocument = fixture.Create<string>(); documentFormatter = Substitute.For<IDocumentFormatter>(); documentFormatter.DocumentToString(document).Returns(formattedDocument); printer = Substitute.For<IPrinter>(); documentPrinter = new DocumentPrinter(documentFormatter, printer); // Act documentPrinter.Print(document); }
public void OnBeforeSave_Calls_DocumentFormatter( [Frozen] IDocumentLocator locator, [Frozen] IDocumentFormatter formatter, DocumentEventHandler sut, uint docCookie, Document document) { locator .FindDocument(docCookie) .Returns(document); sut.OnBeforeSave(docCookie); formatter .Received(1) .Format(document); }
private static string BuildDocumentation(CommandService commandService, IDocumentFormatter f) { string prefix = GuildConfig.DefaultPrefix; StringBuilder builder = new StringBuilder(); foreach (var module in commandService.Modules) { builder.AppendLine(f.H3(module.Name)); var modulePreconditions = module.Preconditions?.Select(x => TranslatePrecondition(x, f)).ToList(); if (modulePreconditions != null && modulePreconditions.Count > 0) { builder.AppendLine(f.NewLine($"{f.Strong("Preconditions:")} {string.Join(", ", modulePreconditions)}")); } builder.AppendLine(f.NewLine("")); foreach (var cmd in module.Commands) { string parameters = string.Empty; if (cmd.Parameters != null && cmd.Parameters.Count > 0) { parameters = $"{string.Join(" ", cmd.Parameters.Select(x => $"_{x.Name}"))}"; } builder.AppendLine(f.NewLine(f.InlineCode($"{prefix}{cmd.Aliases[0]} {parameters}"))); var example = cmd.Attributes.OfType <ExampleAttribute>().FirstOrDefault(); if (example != null && !example.ExampleText.IsEmpty()) { builder.AppendLine(f.NewLine($"{f.Em("Example:")} {f.InlineCode(example.ExampleText)}")); } var commandPreconditions = cmd.Preconditions?.Select(x => TranslatePrecondition(x, f)).ToList(); if (commandPreconditions != null && commandPreconditions.Count > 0) { builder.AppendLine(f.NewLine($"{f.Em("Preconditions:")} {string.Join(", ", commandPreconditions)}")); } if (!cmd.Remarks.IsEmpty()) { builder.AppendLine(f.NewLine($"{f.Em("Remarks:")} {cmd.Remarks}")); } builder.AppendLine(f.NewLine("")); } builder.AppendLine(f.NewLine(f.HorizontalRule())); } return(builder.ToString()); }
public ReportPrinter(IDataFetcher dataFetcher, IDocumentFormatter documentFormatter) { _dataFetcher = dataFetcher; _documentFormatter = documentFormatter; }
private static string TranslatePrecondition(PreconditionAttribute precondition, IDocumentFormatter f) { if (precondition is MinPermissionsAttribute minPermissionsAttribute) { return($"Minimum permission: {f.Em($"{minPermissionsAttribute.AccessLevel.Humanize(LetterCasing.Title)}")}"); } else if (precondition is RequireContextAttribute contextAttribute) { return($"Can only be used in a {f.Em(TranslateContext(contextAttribute.Contexts))}"); } else if (precondition is RequireBotPermissionAttribute || precondition is RequireUserPermissionAttribute) { string permission = ""; string prefix = ""; GuildPermission? guildPermission; ChannelPermission?channelPermission; if (precondition is RequireBotPermissionAttribute) { guildPermission = (precondition as RequireBotPermissionAttribute).GuildPermission; channelPermission = (precondition as RequireBotPermissionAttribute).ChannelPermission; prefix = "Bot"; } else { guildPermission = (precondition as RequireUserPermissionAttribute).GuildPermission; channelPermission = (precondition as RequireUserPermissionAttribute).ChannelPermission; prefix = "User"; } if (guildPermission != null && guildPermission.HasValue) { var guildPermissions = guildPermission.Value.ToString().Split(',').Select(flag => (GuildPermission)Enum.Parse(typeof(GuildPermission), flag)).ToList(); permission += $"{prefix} requires guild permission{(guildPermissions.Count() > 1 ? "s" : "")}: {f.Em(string.Join(", ", guildPermissions.Select(gp => gp.Humanize(LetterCasing.Title))))} "; } if (channelPermission != null && channelPermission.HasValue) { var channelPermissions = channelPermission.Value.ToString().Split(',').Select(flag => (ChannelPermission)Enum.Parse(typeof(ChannelPermission), flag)).ToList(); permission += $"{prefix} requires channel permission{(channelPermissions.Count() > 1 ? "s" : "")}: {f.Em(string.Join(", ", channelPermissions.Select(cp => cp.Humanize(LetterCasing.Title))))} "; } return(permission.Trim()); } else { return(precondition.ToString()); } }
public DocumentPrinter(IDocumentFormatter documentFormatter, IPrinter printer) { }
private void WriteBuildTypes(TeamCityProject Project, DirectoryInfo Directory, IDocumentFormatter Formatter) { Parallel.ForEach <BuildType>(Project.BuildTypes.BuildType, bt => { WriteBuildType(bt, Directory, Formatter); }); }
public ProjectDocumentWorker(IDocumentFormatter Formatter, IConfigurationManager AppMgr = null, ILogger <ProjectDocumentWorker> logger = null) { _fileMode = AppMgr?.Configuration["FileMode"]; _formatter = Formatter; _logger = logger; }
public BeautifierFormatService(DTE dte) { this.dte = dte; formatter = new VisualStudioCommandFormatter(dte); }
public ReportComposer(IDataGetter dg, IReportPrinter rp, IDocumentFormatter df) { _dataGetter = dg; _reportPrinter = rp; _documentFormatter = df; }
public DocumentPrinter(IDocumentFormatter documentFormatter, IPrinter printer) { _documentFormatter = documentFormatter; _printer = printer; }
public ReportComposer(IDocumentFormatter f, IReport r, IReportPrinter rp) { formatter = f; report = r; printer = rp; }
public When_I_call_document_printer() { documentFormatter = Substitute.For<IDocumentFormatter>(); printer = Substitute.For<IPrinter>(); documentPrinter = new DocumentPrinter(documentFormatter, printer); }