// Copyright © 2012 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include "Stdafx.h"
#include "include/cef_v8.h"
#include "JavascriptCallbackRegistry.h"
using namespace System;
namespace CefSharp
{
private class TypeUtils
{
public:
///
/// Converts a .NET object to an (unmanaged) Chromium V8 object.
///
/// The .NET object that should be converted.
/// The type of the source object. If this parameter is a null reference, the type will be determined
/// automatically.
/// A corresponding V8 value.
static CefRefPtr ConvertToCef(Object^ obj, Type^ type);
///
/// Converts a Chromium V8 value to a (managed) .NET object
/// using a JavascriptCallbackRegistry param to convert any
/// anonymous function to IJavascriptCallback, if callbackRegistry
/// is nullptr will use nullptr to each anonymous function instead.
///
/// The V8 value that should be converted.
/// Instance of JavascriptCallbackRegistry to manage IJavascriptCallback instances.
/// A corresponding .NET object.
static Object^ ConvertFromCef(CefRefPtr obj, JavascriptCallbackRegistry^ callbackRegistry);
///
/// Converts a Chromium V8 CefTime (Date) to a (managed) .NET DateTime.
///
/// The CefTime value that should be converted.
/// A corresponding .NET DateTime.
static DateTime ConvertCefTimeToDateTime(CefTime time);
///
/// Converts a a (managed) .NET DateTime to Chromium V8 CefTime (Date).
///
/// The DateTime value that should be converted.
/// A corresponding CefTime (epoch).
static CefTime ConvertDateTimeToCefTime(DateTime dateTime);
};
}