2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 11:32:59 +00:00

inheritance

This commit is contained in:
Esiur Project 2022-06-20 20:51:04 +03:00
parent 26709a959c
commit 0dc457bf7e
5 changed files with 31 additions and 23 deletions

View File

@ -47,6 +47,7 @@ public static class EsiurExtensions
//}
public static T AddResource<T>(this DbSet<T> dbSet, T resource) where T : class, IResource
=> AddResourceAsync(dbSet, resource).Wait();

View File

@ -6,7 +6,7 @@
<Copyright>Ahmed Kh. Zamil</Copyright>
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.2.4.4</Version>
<Version>2.2.5</Version>
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
<Authors>Ahmed Kh. Zamil</Authors>
<AssemblyVersion></AssemblyVersion>

View File

@ -219,16 +219,6 @@ public class TypeTemplate
// Add self
list.Add(template);
// Add parents
var parentType = template.ParentDefinedType;
// Get parents
while (parentType != null)
{
var parentTemplate = Warehouse.GetTemplateByType(parentType);
list.Add(parentTemplate);
parentType = parentTemplate.ParentDefinedType;
}
Action<TypeTemplate, List<TypeTemplate>> getDependenciesFunc = null;
@ -237,6 +227,20 @@ public class TypeTemplate
if (template.DefinedType == null)
return;
// Add parents
var parentType = tmp.ParentDefinedType;
// Get parents
while (parentType != null)
{
var parentTemplate = Warehouse.GetTemplateByType(parentType);
if (parentTemplate != null)
{
list.Add(parentTemplate);
parentType = parentTemplate.ParentDefinedType;
}
}
// functions
foreach (var f in tmp.functions)
{
@ -803,7 +807,7 @@ public class TypeTemplate
if (hasParent)
{
// find the first parent type that implements IResource
var ParentDefinedType = ResourceProxy.GetBaseType(type.BaseType);
ParentDefinedType = ResourceProxy.GetBaseType(type.BaseType);
var parentId = GetTypeGuid(ParentDefinedType);
b.AddGuid(parentId);
}
@ -838,7 +842,8 @@ public class TypeTemplate
var parent = type.BaseType;
if (parent == typeof(Resource)
|| parent == typeof(Record))
|| parent == typeof(Record)
|| parent == typeof(EntryPoint))
return false;
while (parent != null)

View File

@ -1,2 +1,4 @@
1- Change branch to main
2- Generic Records/Resources
2- Generic Records/Resources
3- Static functions calls
4- Scan assembly for child classes

View File

@ -55,14 +55,14 @@ namespace Test
{
// Create stores to keep objects.
var system = await Warehouse.Put("mem", new MemoryStore());
var server = await Warehouse.Put("mem/server", new DistributedServer());
var web = await Warehouse.Put("mem/web", new HTTPServer() { Port = 8888});
var system = await Warehouse.Put("sys", new MemoryStore());
var server = await Warehouse.Put("sys/server", new DistributedServer());
var web = await Warehouse.Put("sys/web", new HTTPServer() { Port = 8888});
var service = await Warehouse.Put("mem/service", new MyService());
var res1 = await Warehouse.Put("mem/service/r1", new MyResource() { Description = "Testing 1", CategoryId = 10 });
var res2 = await Warehouse.Put("mem/service/r2", new MyResource() { Description = "Testing 2", CategoryId = 11 });
var res3 = await Warehouse.Put("mem/service/c1", new MyChildResource() { ChildName = "Child 1", Description = "Child Testing 3", CategoryId = 12 });
var service = await Warehouse.Put("sys/service", new MyService());
var res1 = await Warehouse.Put("sys/service/r1", new MyResource() { Description = "Testing 1", CategoryId = 10 });
var res2 = await Warehouse.Put("sys/service/r2", new MyResource() { Description = "Testing 2", CategoryId = 11 });
var res3 = await Warehouse.Put("sys/service/c1", new MyChildResource() { ChildName = "Child 1", Description = "Child Testing 3", CategoryId = 12 });
service.Resource = res1;
@ -92,7 +92,7 @@ namespace Test
private static async void TestClient(IResource local)
{
dynamic remote = await Warehouse.Get<IResource>("iip://localhost/mem/service");
dynamic remote = await Warehouse.Get<IResource>("iip://localhost/sys/service");
var con = remote.Connection as DistributedConnection;
var template = await con.GetTemplateByClassName("Test.MyResource");
@ -134,7 +134,7 @@ namespace Test
//var childTemplate = remote.Child.Instance.Template;
var path = TemplateGenerator.GetTemplate("iip://localhost/mem/service", "Generated");
var path = TemplateGenerator.GetTemplate("iip://localhost/sys/service", "Generated");
Console.WriteLine(path);