Example #1
0
        public static RuntimeObject FromType(Type type)
        {
            SharedObjectHandle sharedValue = default;

            if (hashtable[type] is SharedObjectHandle o)
            {
                sharedValue = o;
            }
            else
            {
                lock (hashtable) {
                    if (hashtable[type] is SharedObjectHandle o2)
                    {
                        sharedValue = o2;
                    }
                    else
                    {
                        using (RuntimeRealm.SharedObjectContainer container = new RuntimeRealm.SharedObjectContainer()) {
                            RuntimeObject o3 = new ReflectedNativeObjectPrototype(container, type, false);
                            sharedValue     = container.Add(o3);
                            hashtable[type] = sharedValue;
                        }
                    }
                }
            }
            return(RuntimeRealm.Current.GetRuntimeObject(sharedValue));
        }
Example #2
0
 public ReflectedNativeObject(object target)
     : base(target)
 {
     SetPrototypeOf(ReflectedNativeObjectPrototype.FromType(target.GetType()));
     this.Target = target;
 }