mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 04:22:58 +00:00
Template
This commit is contained in:
parent
735a19cda3
commit
b198101e2d
@ -76,6 +76,12 @@ export default class AutoList extends IEventHandler
|
||||
return this.list[index];
|
||||
}
|
||||
|
||||
first(selector){
|
||||
for(var el of this.list)
|
||||
if (selector(el))
|
||||
return el;
|
||||
}
|
||||
|
||||
remove(value)
|
||||
{
|
||||
this.removeAt(this.list.indexOf(value));
|
||||
|
@ -1918,12 +1918,12 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
let parsed = Codec.parse(content, 0, this, null, transmissionType);
|
||||
|
||||
parsed.Then(results =>
|
||||
parsed.then(results =>
|
||||
{
|
||||
// un hold the socket to send data immediately
|
||||
this.socket.unhold();
|
||||
|
||||
var fi = ft.MethodInfo;
|
||||
var fi = ft.methodInfo;
|
||||
|
||||
if (fi == null)
|
||||
{
|
||||
|
@ -3,8 +3,11 @@ import Warehouse from "../Resource/Warehouse.js";
|
||||
export default class ResourceProxy {
|
||||
static cache = {};
|
||||
|
||||
static getBase(type) {
|
||||
if (type.baseType != null)
|
||||
static getBaseType(type) {
|
||||
if (type == null)
|
||||
throw new Error("Type can't be null.");
|
||||
|
||||
if (type.baseType != null)
|
||||
return type.baseType;
|
||||
|
||||
return type;
|
||||
|
@ -137,7 +137,7 @@ export default class TypeTemplate {
|
||||
|
||||
var list = [];
|
||||
|
||||
list.add(template);
|
||||
list.push(template);
|
||||
|
||||
var getDependenciesFunc = null;
|
||||
|
||||
@ -161,11 +161,11 @@ export default class TypeTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
var args = ft.methodInfo.parameters;
|
||||
var args = ft.methodInfo.args;
|
||||
|
||||
for(let j = 0; j < args.length - 1; j++)
|
||||
{
|
||||
var fpt = Warehouse.getTemplateByType(args[j].parameterType);
|
||||
var fpt = Warehouse.getTemplateByType(args[j].type);
|
||||
if (fpt != null)
|
||||
{
|
||||
if (!bag.includes(fpt))
|
||||
@ -180,9 +180,9 @@ export default class TypeTemplate {
|
||||
if (args.length > 0)
|
||||
{
|
||||
var last = args[args.length - 1];
|
||||
if (last.parameterType == DistributedConnection)
|
||||
if (last.type == DistributedConnection)
|
||||
{
|
||||
let fpt = Warehouse.getTemplateByType(last.parameterType);
|
||||
let fpt = Warehouse.getTemplateByType(last.type);
|
||||
if (fpt != null)
|
||||
{
|
||||
if (!bag.includes(fpt))
|
||||
@ -200,7 +200,7 @@ export default class TypeTemplate {
|
||||
for (let i = 0; i < tmp.properties.length; i++)
|
||||
{
|
||||
var p = tmp.properties[i];
|
||||
var pt = Warehouse.getTemplateByType(p.propertyInfo.propertyType);
|
||||
var pt = Warehouse.getTemplateByType(p.propertyInfo.type);
|
||||
if (pt != null)
|
||||
{
|
||||
if (!bag.includes(pt))
|
||||
@ -215,13 +215,13 @@ export default class TypeTemplate {
|
||||
for(let i = 0; i < tmp.events.length; i++)
|
||||
{
|
||||
var e = tmp.events[i];
|
||||
var et = Warehouse.getTemplateByType(e.eventInfo.eventHandlerType);
|
||||
var et = Warehouse.getTemplateByType(e.eventInfo.type);
|
||||
|
||||
if (et != null)
|
||||
{
|
||||
if (!bag.includes(et))
|
||||
{
|
||||
bag.Add(et);
|
||||
bag.add(et);
|
||||
getDependenciesFunc(et, bag);
|
||||
}
|
||||
}
|
||||
|
@ -312,51 +312,32 @@ export class WH extends IEventHandler
|
||||
|
||||
getTemplateByType(type)
|
||||
{
|
||||
if (type == null)
|
||||
|
||||
let baseType = ResourceProxy.getBaseType(type);
|
||||
|
||||
if (baseType == IResource || baseType == IRecord || baseType == IEnum)
|
||||
return null;
|
||||
|
||||
// search our records
|
||||
|
||||
let template = this.templates.first(x=> x.defineType == type);
|
||||
if (template != null)
|
||||
return template;
|
||||
|
||||
let templateType;
|
||||
|
||||
if (type.prototype instanceof IResource)
|
||||
if (baseType.prototype instanceof IResource)
|
||||
templateType = TemplateType.Resource;
|
||||
else if (type.prototype instanceof IRecord)
|
||||
else if (baseType.prototype instanceof IRecord)
|
||||
templateType = TemplateType.Record;
|
||||
else if (type.prototype instanceof IEnum)
|
||||
else if (baseType.prototype instanceof IEnum)
|
||||
templateType = TemplateType.Enum;
|
||||
else
|
||||
return null;
|
||||
|
||||
if (type == IResource
|
||||
|| type == IRecord)
|
||||
return null;
|
||||
let template = this.templates.item(templateType).first(x=> x.definedType == baseType);
|
||||
if (template != null)
|
||||
return template;
|
||||
|
||||
template = new TypeTemplate(baseType, true);
|
||||
TypeTemplate.getDependencies(template);
|
||||
|
||||
if (!(type.prototype instanceof IResource
|
||||
|| type.prototype instanceof IRecord))
|
||||
return false;
|
||||
|
||||
// let className = type.prototype.constructor.name;
|
||||
|
||||
// if (className.startsWith("E_"))
|
||||
// className = className.substr(2);
|
||||
|
||||
// className = type.template.namespace + "." + (type.template.className ?? className);
|
||||
|
||||
// var templates = this.templates.get(templateType);
|
||||
|
||||
|
||||
// // loaded ?
|
||||
// for(var i = 0; i < templates.length; i++)
|
||||
// if (templates.at(i).className == className)
|
||||
// return templates.at(i);
|
||||
|
||||
template = new TypeTemplate(type, true);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user