mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
sketching out mergers API
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Octokit.CodeGen
|
||||
{
|
||||
using TypeBuilderFunc = System.Func<PathMetadata, ApiClientFileMetadata, ApiClientFileMetadata>;
|
||||
|
||||
using TypeMergeFunc = System.Func<List<ApiClientFileMetadata>, List<ApiClientFileMetadata>>;
|
||||
|
||||
public class ApiBuilder
|
||||
{
|
||||
static ApiBuilder()
|
||||
@@ -18,7 +20,8 @@ namespace Octokit.CodeGen
|
||||
Default.Register(Builders.AddPropertiesForNestedClients);
|
||||
}
|
||||
|
||||
private List<TypeBuilderFunc> funcs = new List<TypeBuilderFunc>();
|
||||
private List<TypeBuilderFunc> typeBuilders = new List<TypeBuilderFunc>();
|
||||
private List<TypeMergeFunc> typeMergers = new List<TypeMergeFunc>();
|
||||
|
||||
public List<ApiClientFileMetadata> Build(List<PathMetadata> paths)
|
||||
{
|
||||
@@ -28,7 +31,7 @@ namespace Octokit.CodeGen
|
||||
{
|
||||
var result = new ApiClientFileMetadata();
|
||||
|
||||
foreach (var func in funcs)
|
||||
foreach (var func in typeBuilders)
|
||||
{
|
||||
result = func(path, result);
|
||||
}
|
||||
@@ -36,12 +39,22 @@ namespace Octokit.CodeGen
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
foreach (var merger in typeMergers)
|
||||
{
|
||||
results = merger(results);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public void Register(TypeBuilderFunc func)
|
||||
{
|
||||
funcs.Add(func);
|
||||
typeBuilders.Add(func);
|
||||
}
|
||||
|
||||
public void Register(TypeMergeFunc func)
|
||||
{
|
||||
typeMergers.Add(func);
|
||||
}
|
||||
|
||||
public static ApiBuilder Default { get; }
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using OneOf;
|
||||
|
||||
namespace Octokit.CodeGen
|
||||
{
|
||||
using TypeMergeFunc = System.Func<List<ApiClientFileMetadata>, List<ApiClientFileMetadata>>;
|
||||
|
||||
public partial class Builders
|
||||
{
|
||||
public static readonly TypeMergeFunc AddPropertiesForNestedClients = (clients) =>
|
||||
{
|
||||
return clients;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,11 @@ namespace Octokit.CodeGen
|
||||
public ApiClientMetadata()
|
||||
{
|
||||
Methods = new List<ApiMethodMetadata>();
|
||||
Properties = new List<ApiPropertyMetadata>();
|
||||
}
|
||||
public string InterfaceName { get; set; }
|
||||
public string ClassName { get; set; }
|
||||
public List<ApiPropertyMetadata> Properties { get;set;}
|
||||
public List<ApiMethodMetadata> Methods { get; set; }
|
||||
}
|
||||
|
||||
@@ -94,6 +96,12 @@ namespace Octokit.CodeGen
|
||||
}
|
||||
}
|
||||
|
||||
public class ApiPropertyMetadata
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
}
|
||||
|
||||
public class ApiMethodMetadata
|
||||
{
|
||||
public ApiMethodMetadata()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Octokit.CodeGen
|
||||
var writeFilesToDisk = Array.IndexOf(args, "--write") > -1;
|
||||
|
||||
var filter = new PathFilter();
|
||||
filter.Allow("/marketplace_listing/accounts/");
|
||||
filter.Allow("/marketplace_listing/plans");
|
||||
//filter.Allow("/repos/{owner}/{repo}/topics");
|
||||
|
||||
var apiBuilder = ApiBuilder.Default;
|
||||
|
||||
Reference in New Issue
Block a user