private static string GetShortNameFromAutoGeneratedMember(IApiNode autoGeneratedNode) { var indexOfUnderscore = autoGeneratedNode.Name.IndexOf("_"); if (indexOfUnderscore < 3) { throw new ArgumentOutOfRangeException(nameof(autoGeneratedNode), autoGeneratedNode.Name, "Expected a node with a name starting with something like get_, set_ ,add_ or remove_"); } var nameBeforeUnderscore = autoGeneratedNode.Name.Substring(0, indexOfUnderscore); return $"{AccessibilityPrefix(autoGeneratedNode)}{nameBeforeUnderscore}"; }
public async Task Write(IApiNode apiNode, TextWriter file, CancellationToken cancellationToken, bool recurse = true) { if (recurse) file.WriteLine(); //Indentation is only correct after a newline (note: WriteLineAsync doesn't seem to do indentation at all) await file.WriteAsync($"{AccessibilityPrefix(apiNode)}{apiNode.Signature}"); if (recurse || ShouldWriteMembersInline(apiNode)) { var orderedMembers = MembersInCanonicalOrder(apiNode); await WriteMembers(apiNode, file, cancellationToken, orderedMembers); } }
private bool IsVisibleApiMember(IApiNode apiNode) { if (apiNode.Kind == SymbolKind.Namespace || apiNode.Kind == SymbolKind.Assembly) { return(apiNode.Members.Any(IsVisibleApiMember)); } else { return(m_PrinterConfig.ShouldPrint(apiNode.Namespace, apiNode.SymbolAccessibility)); } }
private async Task WriteMembers(IApiNode parentNode, TextWriter file, CancellationToken cancellationToken, IOrderedEnumerable<IApiNode> orderedMembers) { if (ShouldWriteMembersInline(parentNode)) { await WriteAutogeneratedShortnamesInline(file, cancellationToken, orderedMembers); } else { await WriteMembersIndented(file, cancellationToken, orderedMembers); } }
private async Task WriteMembers(IApiNode parentNode, TextWriter file, CancellationToken cancellationToken, IOrderedEnumerable <IApiNode> orderedMembers) { if (ShouldWriteMembersInline(parentNode)) { await WriteAutogeneratedShortnamesInline(file, cancellationToken, orderedMembers); } else { await WriteMembersIndented(file, cancellationToken, orderedMembers); } }
public HttpClusterApi AddHost(string url, string host, int weight = 10) { url = url.ToLower(); IApiNode node = OnGetNode(url); if (node == null) { node = CreateUrlNode(url); } node.Add(host, weight); return(this); }
public IApiNode GetUrlNode(string url) { url = url.ToLower(); if (url == "*") return DefaultNode; IApiNode node = OnGetNode(url); if (node == null) { node = CreateUrlNode(url); } return node; }
private static string GetShortNameFromAutoGeneratedMember(IApiNode autoGeneratedNode) { var indexOfUnderscore = autoGeneratedNode.Name.IndexOf("_"); if (indexOfUnderscore < 3) { throw new ArgumentOutOfRangeException(nameof(autoGeneratedNode), autoGeneratedNode.Name, "Expected a node with a name starting with something like get_, set_ ,add_ or remove_"); } var nameBeforeUnderscore = autoGeneratedNode.Name.Substring(0, indexOfUnderscore); return($"{AccessibilityPrefix(autoGeneratedNode)}{nameBeforeUnderscore}"); }
public async Task Write(IApiNode apiNode, TextWriter file, CancellationToken cancellationToken, bool recurse = true) { if (recurse) { file.WriteLine(); //Indentation is only correct after a newline (note: WriteLineAsync doesn't seem to do indentation at all) } await file.WriteAsync($"{AccessibilityPrefix(apiNode)}{apiNode.Signature}"); if (recurse || ShouldWriteMembersInline(apiNode)) { var orderedMembers = MembersInCanonicalOrder(apiNode); await WriteMembers(apiNode, file, cancellationToken, orderedMembers); } }
public ApiNodeAgent GetAgent(string url) { IApiNode node = MatchNode(url); if (node == null) node = DefaultNode; if (!mAgents.TryGetValue(node.Url, out ApiNodeAgent agent)) { agent = new ApiNodeAgent(); agent.Url = node.Url; agent.Node = node; mAgents[node.Url] = agent; } return agent; }
private void RemoveNode(string url) { ChangeVersion(); if (url == "*") { DefaultNode = new ApiNode("*"); } else { mNodes.TryRemove(url, out IApiNode apiNode); } if (mAgents.TryGetValue(url, out ApiNodeAgent agent)) { agent.Node = DefaultNode;//new ApiNode(url); } }
public ApiNodeAgent GetAgent(string url) { IApiNode node = MatchNode(url); if (node == null) { node = DefaultNode; } if (!mAgents.TryGetValue(node.Url, out ApiNodeAgent agent)) { agent = new ApiNodeAgent(); agent.Url = node.Url; agent.Node = node; mAgents[node.Url] = agent; } agent.Version = this.Version; return(agent); }
public HttpClusterApi AddHost(string url, string host, int weight = 10) { if (url == "*") { DefaultNode.Add(host, weight); } else { url = url.ToLower(); IApiNode node = OnGetNode(url); if (node == null) { node = CreateUrlNode(url); } node.Add(host, weight); } return this; }
public HttpClusterApi SetNode(string url, IApiNode node) { if (url == "*") DefaultNode = node; else mNodes[url.ToLower()] = node; if (mAgents.TryGetValue(url, out ApiNodeAgent agent)) { agent.Node = node; } else { agent = new ApiNodeAgent(); agent.Url = url; agent.Node = node; mAgents[url] = agent; } return this; }
public HttpClusterApi SetNode(string url, IApiNode node) { if (url == "*") { DefaultNode = node; } else { mNodes[url.ToLower()] = node; } if (mAgents.TryGetValue(url, out ApiNodeAgent agent)) { agent.Node = node; } else { agent = new ApiNodeAgent(); agent.Url = url; agent.Node = node; mAgents[url] = agent; } ChangeVersion(); return(this); }
private ApiNodeComparison([CanBeNull] IApiNode oldApiNode, [CanBeNull] IApiNode newApiNode, IEnumerable <ApiNodeComparison> memberComparison) { OldApiNode = oldApiNode; NewApiNode = newApiNode; MemberComparison = memberComparison.ToList(); }
private static bool ShouldWriteMembersInline(IApiNode parentNode) { return parentNode.Kind == SymbolKind.Property || parentNode.Kind == SymbolKind.Event; }
private static string AccessibilityPrefix(IApiNode node) { return node.Kind == SymbolKind.Namespace || node.Kind == SymbolKind.Assembly || node.SymbolAccessibility == Accessibility.NotApplicable ? "" : $"{node.SymbolAccessibility.ToString().ToLowerInvariant()} "; }
public FilteredApiNode(IApiNode apiNodeImplementation, PrinterConfig printerConfig) { m_ApiNodeImplementation = apiNodeImplementation; m_PrinterConfig = printerConfig; }
private static IApiNode GetFiltered(PrinterConfig printerConfig, IApiNode assemblyNode) { return FilteredApiNode.For(printerConfig, new[] { assemblyNode }).Single(); }
private static IOrderedEnumerable<IApiNode> MembersInCanonicalOrder(IApiNode apiNode) { return apiNode.Members.OrderBy(n => n, new PrettyNodeOrderComparer()); }
private static bool ShouldWriteMembersInline(IApiNode parentNode) { return(parentNode.Kind == SymbolKind.Property || parentNode.Kind == SymbolKind.Event); }
private static IApiNode GetFiltered(PrinterConfig printerConfig, IApiNode assemblyNode) { return(FilteredApiNode.For(printerConfig, new[] { assemblyNode }).Single()); }
private static IOrderedEnumerable <IApiNode> MembersInCanonicalOrder(IApiNode apiNode) { return(apiNode.Members.OrderBy(n => n, new PrettyNodeOrderComparer())); }
private static IReadOnlyCollection <ApiNodeComparison> Compare(IApiNode oldApi, IApiNode newApi) { return(ApiNodeComparison.Compare(new[] { oldApi }, new[] { newApi })); }
private static string AccessibilityPrefix(IApiNode node) { return(node.Kind == SymbolKind.Namespace || node.Kind == SymbolKind.Assembly || node.SymbolAccessibility == Accessibility.NotApplicable ? "" : $"{node.SymbolAccessibility.ToString().ToLowerInvariant()} "); }