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

Interfaces

This commit is contained in:
Ahmed Zamil 2024-11-11 17:26:15 +03:00
parent 44943b23b0
commit 0c335c6023
6 changed files with 24 additions and 1 deletions

View File

@ -217,6 +217,8 @@ namespace Esiur.Data
return new RepresentationType(RepresentationTypeIdentifier.Resource, nullable); return new RepresentationType(RepresentationTypeIdentifier.Resource, nullable);
else if (type == typeof(IRecord) || type == typeof(Record)) else if (type == typeof(IRecord) || type == typeof(Record))
return new RepresentationType(RepresentationTypeIdentifier.Record, nullable); return new RepresentationType(RepresentationTypeIdentifier.Record, nullable);
else if (type.IsInterface)
return null; // other interfaces are not supported
else if (type == typeof(Map<object, object>)) else if (type == typeof(Map<object, object>))
return new RepresentationType(RepresentationTypeIdentifier.Map, nullable); return new RepresentationType(RepresentationTypeIdentifier.Map, nullable);
else if (Codec.ImplementsInterface(type, typeof(IResource))) else if (Codec.ImplementsInterface(type, typeof(IResource)))

View File

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

View File

@ -765,6 +765,9 @@ public static class Warehouse
/// <returns>Resource template.</returns> /// <returns>Resource template.</returns>
public static TypeTemplate GetTemplateByType(Type type) public static TypeTemplate GetTemplateByType(Type type)
{ {
if (!(type.IsClass || type.IsEnum))
return null;
var baseType = ResourceProxy.GetBaseType(type); var baseType = ResourceProxy.GetBaseType(type);
if (baseType == typeof(IResource) if (baseType == typeof(IResource)

13
Test/IMyRecord.cs Normal file
View File

@ -0,0 +1,13 @@
using Esiur.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public interface IMyRecord:IRecord
{
}
}

View File

@ -128,6 +128,7 @@ public partial class MyService
[Export] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } }; [Export] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
[Export] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } }; [Export] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
//[Export] public IMyRecord myrecord { get; set; }
[Export] public MyResource[]? myResources; [Export] public MyResource[]? myResources;

View File

@ -48,6 +48,7 @@ using System.Text;
using Esiur.Security.Cryptography; using Esiur.Security.Cryptography;
using Esiur.Security.Membership; using Esiur.Security.Membership;
using Esiur.Net.Packets; using Esiur.Net.Packets;
using System.Numerics;
namespace Test namespace Test
{ {
@ -56,6 +57,9 @@ namespace Test
{ {
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
var rp = RepresentationType.FromType(typeof(IMyRecord));
var hhhh = Warehouse.GetTemplateByType(typeof(IMyRecord));
var a = new ECDH(); var a = new ECDH();
var b = new ECDH(); var b = new ECDH();