mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 13:33:13 +00:00
EntityCore
This commit is contained in:
26
Esyur/Resource/Template/AttributeTemplate.cs
Normal file
26
Esyur/Resource/Template/AttributeTemplate.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Esyur.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esyur.Resource.Template
|
||||
{
|
||||
public class AttributeTemplate : MemberTemplate
|
||||
{
|
||||
public PropertyInfo Info
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public AttributeTemplate(ResourceTemplate template, byte index, string name)
|
||||
: base(template, MemberType.Attribute, index, name)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ namespace Esyur.Resource.Template
|
||||
Function = 0,
|
||||
Property = 1,
|
||||
Event = 2,
|
||||
Attribute = 3
|
||||
}
|
||||
|
||||
public byte Index => index;
|
||||
|
@ -19,6 +19,7 @@ namespace Esyur.Resource.Template
|
||||
List<FunctionTemplate> functions = new List<FunctionTemplate>();
|
||||
List<EventTemplate> events = new List<EventTemplate>();
|
||||
List<PropertyTemplate> properties = new List<PropertyTemplate>();
|
||||
List<AttributeTemplate> attributes = new List<AttributeTemplate>();
|
||||
int version;
|
||||
//bool isReady;
|
||||
|
||||
@ -88,6 +89,14 @@ namespace Esyur.Resource.Template
|
||||
return null;
|
||||
}
|
||||
|
||||
public AttributeTemplate GetAttributeTemplate(string attributeName)
|
||||
{
|
||||
foreach (var i in attributes)
|
||||
if (i.Name == attributeName)
|
||||
return i;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Guid ClassId
|
||||
{
|
||||
get { return classId; }
|
||||
@ -156,21 +165,31 @@ namespace Esyur.Resource.Template
|
||||
|
||||
foreach (var pi in propsInfo)
|
||||
{
|
||||
var ps = (ResourceProperty[])pi.GetCustomAttributes(typeof(ResourceProperty), true);
|
||||
if (ps.Length > 0)
|
||||
var rp = pi.GetCustomAttribute<ResourceProperty>(true);
|
||||
|
||||
if (rp != null)
|
||||
{
|
||||
var pt = new PropertyTemplate(this, i++, pi.Name, ps[0].ReadExpansion, ps[0].WriteExpansion, ps[0].Storage);
|
||||
var pt = new PropertyTemplate(this, i++, pi.Name, rp.ReadExpansion, rp.WriteExpansion, rp.Storage);
|
||||
pt.Info = pi;
|
||||
pt.Serilize = ps[0].Serialize;
|
||||
pt.Serilize = rp.Serialize;
|
||||
properties.Add(pt);
|
||||
}
|
||||
|
||||
var ra = pi.GetCustomAttribute<ResourceAttribute>(true);
|
||||
|
||||
if (ra != null)
|
||||
{
|
||||
var at = new AttributeTemplate(this, i++, pi.Name);
|
||||
at.Info = pi;
|
||||
attributes.Add(at);
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
foreach (var ei in eventsInfo)
|
||||
{
|
||||
var es = (ResourceEvent[])ei.GetCustomAttributes(typeof(ResourceEvent), true);
|
||||
var es = ei.GetCustomAttributes<ResourceEvent>(true).ToArray();
|
||||
if (es.Length > 0)
|
||||
{
|
||||
var et = new EventTemplate(this, i++, ei.Name, es[0].Expansion);
|
||||
@ -181,7 +200,7 @@ namespace Esyur.Resource.Template
|
||||
i = 0;
|
||||
foreach (MethodInfo mi in methodsInfo)
|
||||
{
|
||||
var fs = (ResourceFunction[])mi.GetCustomAttributes(typeof(ResourceFunction), true);
|
||||
var fs = mi.GetCustomAttributes<ResourceFunction>(true).ToArray();
|
||||
if (fs.Length > 0)
|
||||
{
|
||||
var ft = new FunctionTemplate(this, i++, mi.Name, mi.ReturnType == typeof(void), fs[0].Expansion);
|
||||
|
Reference in New Issue
Block a user