private JsValue CreateExternalObjectFromObject(object value) { GCHandle handle = GCHandle.Alloc(value); _externalObjects.Add(value); JsValue objValue = JsValue.CreateExternalObject( GCHandle.ToIntPtr(handle), _externalObjectFinalizeCallback); Type type = value.GetType(); ProjectFields(objValue, type, true); ProjectProperties(objValue, type, true); ProjectMethods(objValue, type, true); FreezeObject(objValue); return(objValue); }
private EmbeddedObject CreateEmbeddedObject(object obj) { GCHandle objHandle = GCHandle.Alloc(obj); IntPtr objPtr = GCHandle.ToIntPtr(objHandle); JsValue objValue = JsValue.CreateExternalObject(objPtr, _embeddedObjectFinalizeCallback); var embeddedObject = new EmbeddedObject(obj, objValue); var embeddingOptions = GetEmbeddingObjectOptions(obj); ProjectFields(embeddedObject, embeddingOptions); ProjectProperties(embeddedObject, embeddingOptions); ProjectMethods(embeddedObject, embeddingOptions); if (embeddingOptions.Freeze) { FreezeObject(objValue); } return(embeddedObject); }