public JsInstance MarshalClrValue <T>(T value) { if ((object)value == null) { return((JsInstance)JsNull.Instance); } if ((object)value is JsInstance) { return((object)value as JsInstance); } if (!((object)value is Type)) { return(this.MarshalType(value.GetType()).Wrap <T>(value)); } Type reflectedType = (object)value as Type; if (!reflectedType.IsGenericTypeDefinition) { return((JsInstance)this.MarshalType((object)value as Type)); } NativeGenericType nativeGenericType = new NativeGenericType(reflectedType, this.m_typeType.PrototypeProperty); this.m_typeType.SetupNativeProperties((JsDictionaryObject)nativeGenericType); return((JsInstance)nativeGenericType); }
/// <summary> /// Marshals a native value to a JsInstance /// </summary> /// <typeparam name="T">A type of a native value</typeparam> /// <param name="value">A native value</param> /// <returns>A marshalled JsInstance</returns> public JsInstance MarshalClrValue <T>(T value) { if (value == null) { return(JsNull.Instance); } if (value is JsInstance) { return(value as JsInstance); } if (value is Type) { Type t = value as Type; if (t.IsGenericTypeDefinition) { // Generic defenitions aren't types in the meaning of js // but they are instances of System.Type var res = new NativeGenericType(t, m_typeType.PrototypeProperty); m_typeType.SetupNativeProperties(res); return(res); } else { return(MarshalType(value as Type)); } } else { return(MarshalType(value.GetType()).Wrap(value)); } }