// .net -> Kuma internal static void SyncInstanceVariablesTo(KumaInstance KumaObject, object obj) { var _fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList(); _fields.ForEach(field => KumaObject.InstanceVariables[field.Name] = field.GetValue(obj)); }
public KumaException(KumaInstance obj) { var klass = obj.Class; var exceptionFound = false; var _class = obj.Class; do { if (_class.Name.Equals("Exception")) { exceptionFound = true; break; } _class = _class.Parent; } while (!exceptionFound && _class != null); if (exceptionFound) { ExceptionClass = klass; InnerObject = obj; } else { ExceptionClass = Kuma.Box(typeof(KumaException)); InnerObject = null; } }
private static bool HasParent(KumaInstance KumaObject, Type type) { var @class = KumaObject.Class; do { if (@class is KumaBoxedClass && ((KumaBoxedClass)@class).BoxedType == type) { return(true); } } while ((@class = @class.Parent) != null); return(false); }
// Kuma -> .net internal static void SyncInstanceVariablesFrom(KumaInstance KumaObject, object obj) { var _fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList(); KumaObject.InstanceVariables.Variables.Keys.ToList().ForEach(key => { var _fq = _fields.Where(field => field.Name == key); if (_fq.Any()) { var val = KumaObject.InstanceVariables[key]; if (val is KumaNumber) { val = KumaNumber.Convert(val); } _fq.First().SetValue(obj, val); } }); }