예제 #1
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Retrieves a ClrInstanceTypeWrapper object from the cache, if possible, or creates it
        /// otherwise.
        /// </summary>
        /// <param name="engine"> The associated script engine. </param>
        /// <param name="type"> The CLR type to wrap. </param>
        public static ClrInstanceTypeWrapper FromCache(ScriptEngine engine, Type type)
        {
            ClrInstanceTypeWrapper cachedInstance;
            if (engine.InstanceTypeWrapperCache.TryGetValue(type, out cachedInstance) == true)
                return cachedInstance;
            var newInstance = new ClrInstanceTypeWrapper(engine, type);
            engine.InstanceTypeWrapperCache.Add(type, newInstance);
            return newInstance;
        }
예제 #2
0
 /// <summary>
 /// Returns an object instance to serve as the next object in the prototype chain.
 /// </summary>
 /// <param name="engine"> The associated script engine. </param>
 /// <param name="instance"> The CLR object instance to wrap. </param>
 /// <returns> The next object in the prototype chain. </returns>
 private static ObjectInstance GetPrototypeObject(ScriptEngine engine, object instance)
 {
     if (engine == null)
     {
         throw new ArgumentNullException(nameof(engine));
     }
     if (instance == null)
     {
         throw new ArgumentNullException(nameof(instance));
     }
     return(ClrInstanceTypeWrapper.FromCache(engine, instance.GetType()));
 }
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Retrieves a ClrInstanceTypeWrapper object from the cache, if possible, or creates it
        /// otherwise.
        /// </summary>
        /// <param name="engine"> The associated script engine. </param>
        /// <param name="type"> The CLR type to wrap. </param>
        public static ClrInstanceTypeWrapper FromCache(ScriptEngine engine, Type type)
        {
            if (!engine.EnableExposedClrTypes)
                throw new JavaScriptException(engine, "TypeError", "Unsupported type: CLR types are not supported.  Enable CLR types by setting the ScriptEngine's EnableExposedClrTypes property to true.");

            ClrInstanceTypeWrapper cachedInstance;
            if (engine.InstanceTypeWrapperCache.TryGetValue(type, out cachedInstance) == true)
                return cachedInstance;
            var newInstance = new ClrInstanceTypeWrapper(engine, type);
            engine.InstanceTypeWrapperCache.Add(type, newInstance);
            return newInstance;
        }
예제 #4
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Retrieves a ClrInstanceTypeWrapper object from the cache, if possible, or creates it
        /// otherwise.
        /// </summary>
        /// <param name="engine"> The associated script engine. </param>
        /// <param name="type"> The CLR type to wrap. </param>
        public static ClrInstanceTypeWrapper FromCache(ScriptEngine engine, Type type)
        {
            ClrInstanceTypeWrapper cachedInstance;

            if (engine.InstanceTypeWrapperCache.TryGetValue(type, out cachedInstance) == true)
            {
                return(cachedInstance);
            }
            var newInstance = new ClrInstanceTypeWrapper(engine, type);

            engine.InstanceTypeWrapperCache.Add(type, newInstance);
            return(newInstance);
        }
예제 #5
0
 /// <summary>
 /// Returns an object instance to serve as the next object in the prototype chain.
 /// </summary>
 /// <param name="engine"> The associated script engine. </param>
 /// <param name="type"> The CLR type to wrap. </param>
 /// <returns> The next object in the prototype chain. </returns>
 private static ObjectInstance GetPrototypeObject(ScriptEngine engine, Type type)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type.BaseType == null)
     {
         return(null);
     }
     return(ClrInstanceTypeWrapper.FromCache(engine, type.BaseType));
 }
예제 #6
0
        //     INITIALIZATION
        //_________________________________________________________________________________________

        /// <summary>
        /// Retrieves a ClrInstanceTypeWrapper object from the cache, if possible, or creates it
        /// otherwise.
        /// </summary>
        /// <param name="engine"> The associated script engine. </param>
        /// <param name="type"> The CLR type to wrap. </param>
        public static ClrInstanceTypeWrapper FromCache(ScriptEngine engine, Type type)
        {
            if (!engine.EnableExposedClrTypes)
            {
                throw new JavaScriptException(engine, ErrorType.TypeError, "Unsupported type: CLR types are not supported.  Enable CLR types by setting the ScriptEngine's EnableExposedClrTypes property to true.");
            }

            ClrInstanceTypeWrapper cachedInstance;

            if (engine.InstanceTypeWrapperCache.TryGetValue(type, out cachedInstance) == true)
            {
                return(cachedInstance);
            }
            var newInstance = new ClrInstanceTypeWrapper(engine, type);

            engine.InstanceTypeWrapperCache.Add(type, newInstance);
            return(newInstance);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="clrInstanceTypeWrapper">The displayed object</param>
 public ClrInstanceTypeWrapperDebugView(ClrInstanceTypeWrapper clrInstanceTypeWrapper)
 {
     this.clrInstanceTypeWrapper = clrInstanceTypeWrapper;
 }