コード例 #1
0
        // .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));
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        // 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);
                }
            });
        }