General fixes tweaks and things
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Upsilon.BaseTypes;
|
||||
|
||||
namespace Upsilon.BoundTypes
|
||||
@@ -38,6 +39,10 @@ namespace Upsilon.BoundTypes
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static BoundTypeDefinition GetTypeDefinition(System.Type type)
|
||||
{
|
||||
return _typeDefinitions.Values.FirstOrDefault(x => x.ValidInternalTypes.Contains(type));
|
||||
}
|
||||
|
||||
public static void LoadUserDataTypeDefinition(UserDataBoundTypeDefinition def)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Upsilon.BaseTypes;
|
||||
|
||||
namespace Upsilon.BoundTypes
|
||||
@@ -12,6 +13,38 @@ namespace Upsilon.BoundTypes
|
||||
: base(Type.UserData, backingType)
|
||||
{
|
||||
Name = backingType.Name;
|
||||
Properties = new Dictionary<string, UserDataBoundProperty>();
|
||||
var fields = backingType.GetFields().Select(x => new UserDataBoundProperty()
|
||||
{
|
||||
Name = x.Name,
|
||||
ActualType = x.FieldType.Name,
|
||||
Type = x.FieldType.GetScriptType(),
|
||||
});
|
||||
foreach (var f in fields)
|
||||
{
|
||||
Properties.Add(f.Name.ToLowerInvariant(), f);
|
||||
}
|
||||
var properties = backingType.GetProperties().Select(x => new UserDataBoundProperty()
|
||||
{
|
||||
Name = x.Name,
|
||||
ActualType = x.PropertyType.Name,
|
||||
Type = x.PropertyType.GetScriptType(),
|
||||
});
|
||||
foreach (var f in properties)
|
||||
{
|
||||
Properties.Add(f.Name.ToLowerInvariant(), f);
|
||||
}
|
||||
var methods = backingType.GetMethods().Select(x => new UserDataBoundMethod()
|
||||
{
|
||||
Name = x.Name,
|
||||
Type = Type.Function,
|
||||
ResultType = x.ReturnType.GetScriptType()
|
||||
});
|
||||
foreach (var f in methods)
|
||||
{
|
||||
Properties.Add(f.Name.ToLowerInvariant(), f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UserDataBoundTypeDefinition(string name, Dictionary<string, UserDataBoundProperty> properties)
|
||||
@@ -26,7 +59,14 @@ namespace Upsilon.BoundTypes
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Type Type { get; set; }
|
||||
public string ActualType { get; set; }
|
||||
public virtual string ActualType { get; set; }
|
||||
public string Comment { get; set; }
|
||||
}
|
||||
|
||||
public class UserDataBoundMethod: UserDataBoundProperty
|
||||
{
|
||||
public override string ActualType => "Function";
|
||||
public Type ResultType { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user