-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8d26ff
commit e0c9f2e
Showing
66 changed files
with
1,552 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace ApiAggregator.Net | ||
{ | ||
/// <summary> | ||
/// Implement the api aggregate with web apis and result transformers to map data to aggregated contract. | ||
/// </summary> | ||
/// <typeparam name="TContract">Aggregated Contract</typeparam> | ||
public abstract class ApiAggregate<TContract> : IApiAggregate<TContract> where TContract : IContract | ||
{ | ||
public IEnumerable<Mapping<TContract, IApiResult>> Mappings { get; } | ||
|
||
public ApiAggregate() | ||
{ | ||
Mappings = Construct(); | ||
} | ||
|
||
/// <summary> | ||
/// Implement to configure mappings with Apis & result transformers. | ||
/// </summary> | ||
/// <returns>Entity Schema mappings</returns> | ||
public abstract IEnumerable<Mapping<TContract, IApiResult>> Construct(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace ApiAggregator.Net | ||
{ | ||
internal class ApiComparer : IEqualityComparer<IWebApi> | ||
{ | ||
#region IApi | ||
|
||
public bool Equals(IWebApi x, IWebApi y) => x.GetType() == y.GetType(); | ||
Check warning on line 7 in src/ApiAggregator/ApiComparer.cs GitHub Actions / build
Check warning on line 7 in src/ApiAggregator/ApiComparer.cs GitHub Actions / build
|
||
|
||
public int GetHashCode(IWebApi obj) => obj.GetType().GetHashCode(); | ||
|
||
#endregion IApi | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
namespace ApiAggregator.Net | ||
{ | ||
internal class ApiList : IApiList | ||
{ | ||
private readonly List<IWebApi> apiList; | ||
|
||
public ApiList() | ||
{ | ||
apiList = new List<IWebApi>(); | ||
} | ||
|
||
public IEnumerable<IWebApi> Apis | ||
{ get { return apiList; } } | ||
|
||
public ApiList(IEnumerable<IWebApi> collection) | ||
{ | ||
apiList = new List<IWebApi>(collection); | ||
} | ||
|
||
public int ApiNestingDepth { get; set; } | ||
|
||
public IApiList GetByType<T>() where T : class | ||
{ | ||
var apis = apiList.Where(q => q as T != null); | ||
return new ApiList(apis); | ||
} | ||
|
||
public List<T> As<T>() => apiList.Cast<T>().ToList(); | ||
|
||
public List<NestedApiList> GetChildrenApis() | ||
{ | ||
var childrenApis = apiList | ||
.Select(x => new NestedApiList { ParentApiResultType = x.ResultType, Apis = x.Children }) | ||
.Where(x => x.Apis != null && x.Apis.Any()) | ||
.ToList(); | ||
|
||
return childrenApis | ||
.Select(x => | ||
{ | ||
var distinctList = childrenApis | ||
.Where(d => d.ParentApiResultType == x.ParentApiResultType) | ||
.SelectMany(q => q.Apis) | ||
.Distinct(new ApiComparer()) | ||
.ToList(); | ||
|
||
return new NestedApiList { ParentApiResultType = x.ParentApiResultType, Apis = distinctList }; | ||
}) | ||
.ToList(); | ||
} | ||
|
||
public new int Count() => apiList.Count; | ||
|
||
public bool IsEmpty() => !apiList.Any(); | ||
|
||
public void AddRange(IEnumerable<IWebApi> collection) | ||
{ | ||
apiList.AddRange(collection); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// In SDK-style projects such as this one, several assembly attributes that were historically | ||
// defined in this file are now automatically added during build and populated with | ||
// values defined in project properties. For details of which attributes are included | ||
// and how to customise this process see: https://aka.ms/assembly-info-properties | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible to COM | ||
// components. If you need to access a type in this assembly from COM, set the ComVisible | ||
// attribute to true on that type. | ||
|
||
[assembly: ComVisible(false)] | ||
[assembly: InternalsVisibleTo("ApiAggregator.Net.Tests")] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM. | ||
|
||
[assembly: Guid("5188e472-36fc-4e3c-8a49-17d5e32c9ee8")] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace ApiAggregator.Net | ||
{ | ||
public class CacheResultAttribute : Attribute | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ApiAggregator.Net | ||
{ | ||
public class CollectionResult<T> : List<T>, IApiResult | ||
{ | ||
public CollectionResult(IEnumerable<T> list) : base(list) | ||
{ | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.