加入自动类型转换

This commit is contained in:
2025-10-16 10:24:59 +08:00
parent 70051b46a5
commit 3866cdd525
3 changed files with 139 additions and 48 deletions

View File

@@ -11,7 +11,34 @@ namespace Convention.RScript
public struct RScriptVariableEntry
{
public Type type;
public object data;
public object data
{
readonly get
{
return internalData;
}
set
{
if (type == null)
{
type = value.GetType();
internalData = value;
return;
}
internalData = Convert.ChangeType(value, type);
}
}
private object internalData;
public RScriptVariableEntry(object data) : this()
{
this.data = data;
}
public RScriptVariableEntry(Type type, object data) : this()
{
this.type = type;
this.data = data;
}
}
public class RScriptVariables : IDictionary<string, RScriptVariableEntry>
{