// .net -> Nova internal static void SyncInstanceVariablesTo(NovaInstance NovaObject, object obj) { var _fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList(); _fields.ForEach(field => NovaObject.InstanceVariables[field.Name] = field.GetValue(obj)); }
public NovaException(NovaInstance 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 = Nova.Box(typeof(NovaException)); InnerObject = null; } }
private static bool HasParent(NovaInstance NovaObject, Type type) { var @class = NovaObject.Class; do { if (@class is NovaBoxedClass && ((NovaBoxedClass)@class).BoxedType == type) { return(true); } } while ((@class = @class.Parent) != null); return(false); }
// Nova -> .net internal static void SyncInstanceVariablesFrom(NovaInstance NovaObject, object obj) { var _fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).ToList(); NovaObject.InstanceVariables.Variables.Keys.ToList().ForEach(key => { var _fq = _fields.Where(field => field.Name == key); if (_fq.Any()) { var val = NovaObject.InstanceVariables[key]; if (val is NovaNumber) { val = NovaNumber.Convert(val); } _fq.First().SetValue(obj, val); } }); }