Quantcast
Channel: xInterop C++ .NET Bridge
Viewing all articles
Browse latest Browse all 31

Calling .NET from Native C++: How to receive C# event

$
0
0

There are a few other technologies we can use to call .NET from native C++ as shown in Introduction to Native C++ to .NET Bridge, such as C++/CLI, COM, Reverse P/Invoke, Unmanaged DllExport, but none of them are easy to implement receiving events from .NET as xInterop Native C++ to .NET Bridge is.

Let’s write a sample assembly to demonstrate how we can receive C# .NET events from .NET using native C/C++ code. The sample assembly is quite simple, it has only one class named SimpleWebClient which implements a method named DownloadStringAsync and an event named DownloadStringCompletedEventHandler, as you see, SimpleWebClient basically wraps method and even from the class of WebClient.

using System;
using System.Net;

namespace EventSample
{
    public class SimpleWebClient
    {
        private WebClient webClient;

        // Occurs when an asynchronous resource-download operation completes.
        public event DownloadStringCompletedEventHandler DownloadStringCompleted;

        public SimpleWebClient()
        {
            webClient = new WebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCompletedNotified);
        }

        //
        // Summary:
        //     Downloads the resource specified as a System.Uri. This method does not block
        //     the calling thread.
        //
        // Parameters:
        //   address:
        //     A System.Uri containing the URI to download.
        //
        // Exceptions:
        //   T:System.ArgumentNullException:
        //     The address parameter is null.
        //
        //   T:System.Net.WebException:
        //     The URI formed by combining System.Net.WebClient.BaseAddress and address is invalid.-or-
        //     An error occurred while downloading the resource.
        public void DownloadStringAsync(Uri address)
        {
            webClient.DownloadStringAsync(address);
        }

        private void DownloadStringCompletedNotified(object sender, DownloadStringCompletedEventArgs e)
        {
            if (DownloadStringCompleted != null)
            {
                DownloadStringCompleted(sender, e);
            }
        }
    }
}

With Native C++ to .NET Bridge, we can easily create the native C++ bridge DLL and a testing application to test the resulting native DLL.

The following is the corresponding C++ native bridge class, EventSample::SimpleWebClient which bridges to the C# class, SimpleWebClient.

///////////////////////////////////////////////////////////////////////////////
// 
// C++ class SimpleWebClient for C# class definition
//
///////////////////////////////////////////////////////////////////////////////

namespace EventSample
{
	class SimpleWebClient : public System::Object
	{

	public:

		EVENTSAMPLEBRIDGE_API SimpleWebClient();

		EVENTSAMPLEBRIDGE_API virtual ~SimpleWebClient();

		#ifdef add_DownloadStringCompleted
		#pragma push_macro("add_DownloadStringCompleted")
		#undef add_DownloadStringCompleted
		#define XINTEROP_add_DownloadStringCompleted
		#endif

		EVENTSAMPLEBRIDGE_API void add_DownloadStringCompleted(class System::Net::DownloadStringCompletedEventHandler * value);

		#ifdef XINTEROP_add_DownloadStringCompleted
		#pragma pop_macro("add_DownloadStringCompleted")
		#endif



		#ifdef remove_DownloadStringCompleted
		#pragma push_macro("remove_DownloadStringCompleted")
		#undef remove_DownloadStringCompleted
		#define XINTEROP_remove_DownloadStringCompleted
		#endif

		EVENTSAMPLEBRIDGE_API void remove_DownloadStringCompleted(class System::Net::DownloadStringCompletedEventHandler * value);

		#ifdef XINTEROP_remove_DownloadStringCompleted
		#pragma pop_macro("remove_DownloadStringCompleted")
		#endif



		#ifdef DownloadStringAsync
		#pragma push_macro("DownloadStringAsync")
		#undef DownloadStringAsync
		#define XINTEROP_DownloadStringAsync
		#endif

		EVENTSAMPLEBRIDGE_API void DownloadStringAsync(class System::Uri * address);

		#ifdef XINTEROP_DownloadStringAsync
		#pragma pop_macro("DownloadStringAsync")
		#endif



		#ifdef ToSimpleWebClient
		#pragma push_macro("ToSimpleWebClient")
		#undef ToSimpleWebClient
		#define XINTEROP_ToSimpleWebClient
		#endif

		EVENTSAMPLEBRIDGE_API static std::shared_ptr<class EventSample::SimpleWebClient> ToSimpleWebClient(class System::Object * value);

		#ifdef XINTEROP_ToSimpleWebClient
		#pragma pop_macro("ToSimpleWebClient")
		#endif
	};
}

DownloadStringCompletedEventHandler

///////////////////////////////////////////////////////////////////////////////
// 
// The definition of the C++ bridge class of DownloadStringCompletedEventHandler for .NET delegate of System.Net.DownloadStringCompletedEventHandler
//
///////////////////////////////////////////////////////////////////////////////

namespace System
{
	namespace Net
	{


		///////////////////////////////////////////////////////////////////////////////
		// 
		// C++ callback interface IDownloadStringCompletedEventHandlerCallback for C# delegate DownloadStringCompletedEventHandler
		//
		///////////////////////////////////////////////////////////////////////////////

		class EVENTSAMPLEBRIDGE_API IDownloadStringCompletedEventHandlerCallback
		{

		public:

			virtual ~IDownloadStringCompletedEventHandlerCallback();

			virtual void OnCall(class System::Object * sender, class System::Net::DownloadStringCompletedEventArgs * e) = 0;

		};


		typedef void (*DownloadStringCompletedEventHandler__Callback)(class System::Object * sender, class System::Net::DownloadStringCompletedEventArgs * e);


		class DownloadStringCompletedEventHandler : public System::Object
		{

		public:

			EVENTSAMPLEBRIDGE_API DownloadStringCompletedEventHandler(std::function<void (class System::Object *, class System::Net::DownloadStringCompletedEventArgs *)> callback);

			EVENTSAMPLEBRIDGE_API virtual ~DownloadStringCompletedEventHandler();

		private:

			char reserved3[16];
			void* reserved4[2];

		};

	}
}

The following is the code demonstrating how we can receive the C# .NET event from native C++

// ----------------------------------------------------------------------------
// <copyright file="TestApp.cpp" company="xInterop Software, LLC">
// Copyright (c) 2016 xInterop Software, LLC. All rights reserved.
// http://www.xinterop.com
// </copyright>
//
// NOTICE:  All information contained herein is, and remains the property of 
// xInterop Software, LLC, if any. The intellectual and technical concepts 
// contained herein are proprietary to xInterop Software, LLC and may be 
// covered by U.S. and Foreign Patents, patents in process, and are protected 
// by trade secret or copyright law. Dissemination of this information or 
// reproduction of this material is strictly forbidden unless prior written 
// permission is obtained from xInterop Software, LLC. 
//
// This copyright header must be kept intact without any change under any circumstances.
//
// The source code of this file can NOT be re-distributed to any third parties
// unless certain OEM license has been arranged and written permission has been
// authorized by xInterop Software, LLC.
//
// ----------------------------------------------------------------------------

#include "stdafx.h"
#include <Ole2.h>
#include <functional>

#include "../Native/Include/EventSampleBridge.h"

#ifdef _WIN64
#pragma comment(lib, "../Native/Lib/x64/EventSampleBridge.lib")
#else
#pragma comment(lib, "../Native/Lib/win32/EventSampleBridge.lib")
#endif

using namespace::xinterop;

int _tmain(int argc, _TCHAR* argv[])
{	
	///////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Notes:
	//
	// This file was created when "Load .NET bridge assembly automatically" option was turned on.
	//
	// The C# bridge assembly shall be loaded and initialized automatically when any c++ 	
	// class of the C++ bridge DLL is accessed.
	//
	// The C# bridge assembly can also be loaded and initialized by calling xiInitializeBridgeAssembly.
	//
	///////////////////////////////////////////////////////////////////////////////////////////////

	CoInitializeEx(0, COINIT_APARTMENTTHREADED);

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Add your code here.
	///////////////////////////////////////////////////////////////////////////////////////////////

	System::Uri webUri(_T("http://www.xinterop.com"));

	bool completed = false;

        // using Lambda Expressions in C++ to create a function.
	auto callback([](class System::Object * sender, class System::Net::DownloadStringCompletedEventArgs * e)
	{
		auto result = e->get_Result();
		wprintf(L"1 %s\n", result.c_str());
	});

	System::Net::DownloadStringCompletedEventHandler downloadStringCompletedEventHandler(callback);	

	EventSample::SimpleWebClient webClient;
	webClient.add_DownloadStringCompleted(&downloadStringCompletedEventHandler);
	webClient.DownloadStringAsync(&webUri);

	while (!completed)
	{
		// A simple loop waiting for the DownloadStringAsync to complete.
		Sleep(100);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// End of your code.
	///////////////////////////////////////////////////////////////////////////////////////////////

	CoUninitialize();

	exit(0);

	return 0;
}

I am also posting the Uri bridge class if you are interested.

///////////////////////////////////////////////////////////////////////////////
// 
// C++ class Uri for C# class definition
//
///////////////////////////////////////////////////////////////////////////////

namespace System
{
	class Uri : public System::Object
	{

	public:

		EVENTSAMPLEBRIDGE_API Uri(const wchar_t * uriString);

		EVENTSAMPLEBRIDGE_API Uri(const wchar_t * uriString, System::UriKind uriKind);

		EVENTSAMPLEBRIDGE_API Uri(class System::Uri * baseUri, const wchar_t * relativeUri);

		EVENTSAMPLEBRIDGE_API Uri(class System::Uri * baseUri, class System::Uri * relativeUri);

		EVENTSAMPLEBRIDGE_API virtual ~Uri();

		#ifdef get_AbsolutePath
		#pragma push_macro("get_AbsolutePath")
		#undef get_AbsolutePath
		#define XINTEROP_get_AbsolutePath
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_AbsolutePath();

		#ifdef XINTEROP_get_AbsolutePath
		#pragma pop_macro("get_AbsolutePath")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_AbsolutePath)) std::wstring AbsolutePath;



		#ifdef get_AbsoluteUri
		#pragma push_macro("get_AbsoluteUri")
		#undef get_AbsoluteUri
		#define XINTEROP_get_AbsoluteUri
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_AbsoluteUri();

		#ifdef XINTEROP_get_AbsoluteUri
		#pragma pop_macro("get_AbsoluteUri")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_AbsoluteUri)) std::wstring AbsoluteUri;



		#ifdef get_LocalPath
		#pragma push_macro("get_LocalPath")
		#undef get_LocalPath
		#define XINTEROP_get_LocalPath
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_LocalPath();

		#ifdef XINTEROP_get_LocalPath
		#pragma pop_macro("get_LocalPath")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_LocalPath)) std::wstring LocalPath;



		#ifdef get_Authority
		#pragma push_macro("get_Authority")
		#undef get_Authority
		#define XINTEROP_get_Authority
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_Authority();

		#ifdef XINTEROP_get_Authority
		#pragma pop_macro("get_Authority")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Authority)) std::wstring Authority;



		#ifdef get_HostNameType
		#pragma push_macro("get_HostNameType")
		#undef get_HostNameType
		#define XINTEROP_get_HostNameType
		#endif

		EVENTSAMPLEBRIDGE_API System::UriHostNameType get_HostNameType();

		#ifdef XINTEROP_get_HostNameType
		#pragma pop_macro("get_HostNameType")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_HostNameType)) System::UriHostNameType HostNameType;



		#ifdef get_IsDefaultPort
		#pragma push_macro("get_IsDefaultPort")
		#undef get_IsDefaultPort
		#define XINTEROP_get_IsDefaultPort
		#endif

		EVENTSAMPLEBRIDGE_API bool get_IsDefaultPort();

		#ifdef XINTEROP_get_IsDefaultPort
		#pragma pop_macro("get_IsDefaultPort")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_IsDefaultPort)) bool IsDefaultPort;



		#ifdef get_IsFile
		#pragma push_macro("get_IsFile")
		#undef get_IsFile
		#define XINTEROP_get_IsFile
		#endif

		EVENTSAMPLEBRIDGE_API bool get_IsFile();

		#ifdef XINTEROP_get_IsFile
		#pragma pop_macro("get_IsFile")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_IsFile)) bool IsFile;



		#ifdef get_IsLoopback
		#pragma push_macro("get_IsLoopback")
		#undef get_IsLoopback
		#define XINTEROP_get_IsLoopback
		#endif

		EVENTSAMPLEBRIDGE_API bool get_IsLoopback();

		#ifdef XINTEROP_get_IsLoopback
		#pragma pop_macro("get_IsLoopback")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_IsLoopback)) bool IsLoopback;



		#ifdef get_PathAndQuery
		#pragma push_macro("get_PathAndQuery")
		#undef get_PathAndQuery
		#define XINTEROP_get_PathAndQuery
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_PathAndQuery();

		#ifdef XINTEROP_get_PathAndQuery
		#pragma pop_macro("get_PathAndQuery")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_PathAndQuery)) std::wstring PathAndQuery;



		#ifdef get_IsUnc
		#pragma push_macro("get_IsUnc")
		#undef get_IsUnc
		#define XINTEROP_get_IsUnc
		#endif

		EVENTSAMPLEBRIDGE_API bool get_IsUnc();

		#ifdef XINTEROP_get_IsUnc
		#pragma pop_macro("get_IsUnc")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_IsUnc)) bool IsUnc;



		#ifdef get_Host
		#pragma push_macro("get_Host")
		#undef get_Host
		#define XINTEROP_get_Host
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_Host();

		#ifdef XINTEROP_get_Host
		#pragma pop_macro("get_Host")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Host)) std::wstring Host;



		#ifdef get_Port
		#pragma push_macro("get_Port")
		#undef get_Port
		#define XINTEROP_get_Port
		#endif

		EVENTSAMPLEBRIDGE_API int get_Port();

		#ifdef XINTEROP_get_Port
		#pragma pop_macro("get_Port")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Port)) int Port;



		#ifdef get_Query
		#pragma push_macro("get_Query")
		#undef get_Query
		#define XINTEROP_get_Query
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_Query();

		#ifdef XINTEROP_get_Query
		#pragma pop_macro("get_Query")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Query)) std::wstring Query;



		#ifdef get_Fragment
		#pragma push_macro("get_Fragment")
		#undef get_Fragment
		#define XINTEROP_get_Fragment
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_Fragment();

		#ifdef XINTEROP_get_Fragment
		#pragma pop_macro("get_Fragment")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Fragment)) std::wstring Fragment;



		#ifdef get_Scheme
		#pragma push_macro("get_Scheme")
		#undef get_Scheme
		#define XINTEROP_get_Scheme
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_Scheme();

		#ifdef XINTEROP_get_Scheme
		#pragma pop_macro("get_Scheme")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_Scheme)) std::wstring Scheme;



		#ifdef get_OriginalString
		#pragma push_macro("get_OriginalString")
		#undef get_OriginalString
		#define XINTEROP_get_OriginalString
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_OriginalString();

		#ifdef XINTEROP_get_OriginalString
		#pragma pop_macro("get_OriginalString")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_OriginalString)) std::wstring OriginalString;



		#ifdef get_DnsSafeHost
		#pragma push_macro("get_DnsSafeHost")
		#undef get_DnsSafeHost
		#define XINTEROP_get_DnsSafeHost
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_DnsSafeHost();

		#ifdef XINTEROP_get_DnsSafeHost
		#pragma pop_macro("get_DnsSafeHost")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_DnsSafeHost)) std::wstring DnsSafeHost;



		#ifdef get_IsAbsoluteUri
		#pragma push_macro("get_IsAbsoluteUri")
		#undef get_IsAbsoluteUri
		#define XINTEROP_get_IsAbsoluteUri
		#endif

		EVENTSAMPLEBRIDGE_API bool get_IsAbsoluteUri();

		#ifdef XINTEROP_get_IsAbsoluteUri
		#pragma pop_macro("get_IsAbsoluteUri")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_IsAbsoluteUri)) bool IsAbsoluteUri;



		#ifdef get_UserEscaped
		#pragma push_macro("get_UserEscaped")
		#undef get_UserEscaped
		#define XINTEROP_get_UserEscaped
		#endif

		EVENTSAMPLEBRIDGE_API bool get_UserEscaped();

		#ifdef XINTEROP_get_UserEscaped
		#pragma pop_macro("get_UserEscaped")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_UserEscaped)) bool UserEscaped;



		#ifdef get_UserInfo
		#pragma push_macro("get_UserInfo")
		#undef get_UserInfo
		#define XINTEROP_get_UserInfo
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring get_UserInfo();

		#ifdef XINTEROP_get_UserInfo
		#pragma pop_macro("get_UserInfo")
		#endif



		// Simulates .NET property.
		__declspec(property(get = get_UserInfo)) std::wstring UserInfo;



		#ifdef CheckHostName
		#pragma push_macro("CheckHostName")
		#undef CheckHostName
		#define XINTEROP_CheckHostName
		#endif

		EVENTSAMPLEBRIDGE_API static System::UriHostNameType CheckHostName(const wchar_t * name);

		#ifdef XINTEROP_CheckHostName
		#pragma pop_macro("CheckHostName")
		#endif



		#ifdef GetLeftPart
		#pragma push_macro("GetLeftPart")
		#undef GetLeftPart
		#define XINTEROP_GetLeftPart
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring GetLeftPart(System::UriPartial part);

		#ifdef XINTEROP_GetLeftPart
		#pragma pop_macro("GetLeftPart")
		#endif



		#ifdef HexEscape
		#pragma push_macro("HexEscape")
		#undef HexEscape
		#define XINTEROP_HexEscape
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring HexEscape(wchar_t character);

		#ifdef XINTEROP_HexEscape
		#pragma pop_macro("HexEscape")
		#endif



		#ifdef HexUnescape
		#pragma push_macro("HexUnescape")
		#undef HexUnescape
		#define XINTEROP_HexUnescape
		#endif

		EVENTSAMPLEBRIDGE_API static wchar_t HexUnescape(const wchar_t * pattern, int & index);

		#ifdef XINTEROP_HexUnescape
		#pragma pop_macro("HexUnescape")
		#endif



		#ifdef IsHexEncoding
		#pragma push_macro("IsHexEncoding")
		#undef IsHexEncoding
		#define XINTEROP_IsHexEncoding
		#endif

		EVENTSAMPLEBRIDGE_API static bool IsHexEncoding(const wchar_t * pattern, int index);

		#ifdef XINTEROP_IsHexEncoding
		#pragma pop_macro("IsHexEncoding")
		#endif



		#ifdef CheckSchemeName
		#pragma push_macro("CheckSchemeName")
		#undef CheckSchemeName
		#define XINTEROP_CheckSchemeName
		#endif

		EVENTSAMPLEBRIDGE_API static bool CheckSchemeName(const wchar_t * schemeName);

		#ifdef XINTEROP_CheckSchemeName
		#pragma pop_macro("CheckSchemeName")
		#endif



		#ifdef IsHexDigit
		#pragma push_macro("IsHexDigit")
		#undef IsHexDigit
		#define XINTEROP_IsHexDigit
		#endif

		EVENTSAMPLEBRIDGE_API static bool IsHexDigit(wchar_t character);

		#ifdef XINTEROP_IsHexDigit
		#pragma pop_macro("IsHexDigit")
		#endif



		#ifdef FromHex
		#pragma push_macro("FromHex")
		#undef FromHex
		#define XINTEROP_FromHex
		#endif

		EVENTSAMPLEBRIDGE_API static int FromHex(wchar_t digit);

		#ifdef XINTEROP_FromHex
		#pragma pop_macro("FromHex")
		#endif



		#ifdef MakeRelativeUri
		#pragma push_macro("MakeRelativeUri")
		#undef MakeRelativeUri
		#define XINTEROP_MakeRelativeUri
		#endif

		EVENTSAMPLEBRIDGE_API std::shared_ptr<class System::Uri> MakeRelativeUri(class System::Uri * uri);

		#ifdef XINTEROP_MakeRelativeUri
		#pragma pop_macro("MakeRelativeUri")
		#endif



		#ifdef TryCreate
		#pragma push_macro("TryCreate")
		#undef TryCreate
		#define XINTEROP_TryCreate
		#endif

		EVENTSAMPLEBRIDGE_API static bool TryCreate(const wchar_t * uriString, System::UriKind uriKind, class System::Uri * result);

		#ifdef XINTEROP_TryCreate
		#pragma pop_macro("TryCreate")
		#endif



		#ifdef TryCreate
		#pragma push_macro("TryCreate")
		#undef TryCreate
		#define XINTEROP_TryCreate
		#endif

		EVENTSAMPLEBRIDGE_API static bool TryCreate(class System::Uri * baseUri, const wchar_t * relativeUri, class System::Uri * result);

		#ifdef XINTEROP_TryCreate
		#pragma pop_macro("TryCreate")
		#endif



		#ifdef TryCreate
		#pragma push_macro("TryCreate")
		#undef TryCreate
		#define XINTEROP_TryCreate
		#endif

		EVENTSAMPLEBRIDGE_API static bool TryCreate(class System::Uri * baseUri, class System::Uri * relativeUri, class System::Uri * result);

		#ifdef XINTEROP_TryCreate
		#pragma pop_macro("TryCreate")
		#endif



		#ifdef GetComponents
		#pragma push_macro("GetComponents")
		#undef GetComponents
		#define XINTEROP_GetComponents
		#endif

		EVENTSAMPLEBRIDGE_API std::wstring GetComponents(System::UriComponents components, System::UriFormat format);

		#ifdef XINTEROP_GetComponents
		#pragma pop_macro("GetComponents")
		#endif



		#ifdef Compare
		#pragma push_macro("Compare")
		#undef Compare
		#define XINTEROP_Compare
		#endif

		EVENTSAMPLEBRIDGE_API static int Compare(class System::Uri * uri1, class System::Uri * uri2, System::UriComponents partsToCompare, System::UriFormat compareFormat, System::StringComparison comparisonType);

		#ifdef XINTEROP_Compare
		#pragma pop_macro("Compare")
		#endif



		#ifdef IsWellFormedOriginalString
		#pragma push_macro("IsWellFormedOriginalString")
		#undef IsWellFormedOriginalString
		#define XINTEROP_IsWellFormedOriginalString
		#endif

		EVENTSAMPLEBRIDGE_API bool IsWellFormedOriginalString();

		#ifdef XINTEROP_IsWellFormedOriginalString
		#pragma pop_macro("IsWellFormedOriginalString")
		#endif



		#ifdef IsWellFormedUriString
		#pragma push_macro("IsWellFormedUriString")
		#undef IsWellFormedUriString
		#define XINTEROP_IsWellFormedUriString
		#endif

		EVENTSAMPLEBRIDGE_API static bool IsWellFormedUriString(const wchar_t * uriString, System::UriKind uriKind);

		#ifdef XINTEROP_IsWellFormedUriString
		#pragma pop_macro("IsWellFormedUriString")
		#endif



		#ifdef UnescapeDataString
		#pragma push_macro("UnescapeDataString")
		#undef UnescapeDataString
		#define XINTEROP_UnescapeDataString
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring UnescapeDataString(const wchar_t * stringToUnescape);

		#ifdef XINTEROP_UnescapeDataString
		#pragma pop_macro("UnescapeDataString")
		#endif



		#ifdef EscapeUriString
		#pragma push_macro("EscapeUriString")
		#undef EscapeUriString
		#define XINTEROP_EscapeUriString
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring EscapeUriString(const wchar_t * stringToEscape);

		#ifdef XINTEROP_EscapeUriString
		#pragma pop_macro("EscapeUriString")
		#endif



		#ifdef EscapeDataString
		#pragma push_macro("EscapeDataString")
		#undef EscapeDataString
		#define XINTEROP_EscapeDataString
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring EscapeDataString(const wchar_t * stringToEscape);

		#ifdef XINTEROP_EscapeDataString
		#pragma pop_macro("EscapeDataString")
		#endif



		#ifdef IsBaseOf
		#pragma push_macro("IsBaseOf")
		#undef IsBaseOf
		#define XINTEROP_IsBaseOf
		#endif

		EVENTSAMPLEBRIDGE_API bool IsBaseOf(class System::Uri * uri);

		#ifdef XINTEROP_IsBaseOf
		#pragma pop_macro("IsBaseOf")
		#endif



		#ifdef get_UriSchemeFile
		#pragma push_macro("get_UriSchemeFile")
		#undef get_UriSchemeFile
		#define XINTEROP_get_UriSchemeFile
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeFile();

		#ifdef XINTEROP_get_UriSchemeFile
		#pragma pop_macro("get_UriSchemeFile")
		#endif



		#ifdef get_UriSchemeFtp
		#pragma push_macro("get_UriSchemeFtp")
		#undef get_UriSchemeFtp
		#define XINTEROP_get_UriSchemeFtp
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeFtp();

		#ifdef XINTEROP_get_UriSchemeFtp
		#pragma pop_macro("get_UriSchemeFtp")
		#endif



		#ifdef get_UriSchemeGopher
		#pragma push_macro("get_UriSchemeGopher")
		#undef get_UriSchemeGopher
		#define XINTEROP_get_UriSchemeGopher
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeGopher();

		#ifdef XINTEROP_get_UriSchemeGopher
		#pragma pop_macro("get_UriSchemeGopher")
		#endif



		#ifdef get_UriSchemeHttp
		#pragma push_macro("get_UriSchemeHttp")
		#undef get_UriSchemeHttp
		#define XINTEROP_get_UriSchemeHttp
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeHttp();

		#ifdef XINTEROP_get_UriSchemeHttp
		#pragma pop_macro("get_UriSchemeHttp")
		#endif



		#ifdef get_UriSchemeHttps
		#pragma push_macro("get_UriSchemeHttps")
		#undef get_UriSchemeHttps
		#define XINTEROP_get_UriSchemeHttps
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeHttps();

		#ifdef XINTEROP_get_UriSchemeHttps
		#pragma pop_macro("get_UriSchemeHttps")
		#endif



		#ifdef get_UriSchemeMailto
		#pragma push_macro("get_UriSchemeMailto")
		#undef get_UriSchemeMailto
		#define XINTEROP_get_UriSchemeMailto
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeMailto();

		#ifdef XINTEROP_get_UriSchemeMailto
		#pragma pop_macro("get_UriSchemeMailto")
		#endif



		#ifdef get_UriSchemeNews
		#pragma push_macro("get_UriSchemeNews")
		#undef get_UriSchemeNews
		#define XINTEROP_get_UriSchemeNews
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeNews();

		#ifdef XINTEROP_get_UriSchemeNews
		#pragma pop_macro("get_UriSchemeNews")
		#endif



		#ifdef get_UriSchemeNntp
		#pragma push_macro("get_UriSchemeNntp")
		#undef get_UriSchemeNntp
		#define XINTEROP_get_UriSchemeNntp
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeNntp();

		#ifdef XINTEROP_get_UriSchemeNntp
		#pragma pop_macro("get_UriSchemeNntp")
		#endif



		#ifdef get_UriSchemeNetTcp
		#pragma push_macro("get_UriSchemeNetTcp")
		#undef get_UriSchemeNetTcp
		#define XINTEROP_get_UriSchemeNetTcp
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeNetTcp();

		#ifdef XINTEROP_get_UriSchemeNetTcp
		#pragma pop_macro("get_UriSchemeNetTcp")
		#endif



		#ifdef get_UriSchemeNetPipe
		#pragma push_macro("get_UriSchemeNetPipe")
		#undef get_UriSchemeNetPipe
		#define XINTEROP_get_UriSchemeNetPipe
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_UriSchemeNetPipe();

		#ifdef XINTEROP_get_UriSchemeNetPipe
		#pragma pop_macro("get_UriSchemeNetPipe")
		#endif



		#ifdef get_SchemeDelimiter
		#pragma push_macro("get_SchemeDelimiter")
		#undef get_SchemeDelimiter
		#define XINTEROP_get_SchemeDelimiter
		#endif

		EVENTSAMPLEBRIDGE_API static std::wstring get_SchemeDelimiter();

		#ifdef XINTEROP_get_SchemeDelimiter
		#pragma pop_macro("get_SchemeDelimiter")
		#endif



		#ifdef ToUri
		#pragma push_macro("ToUri")
		#undef ToUri
		#define XINTEROP_ToUri
		#endif

		EVENTSAMPLEBRIDGE_API static std::shared_ptr<class System::Uri> ToUri(class System::Object * value);

		#ifdef XINTEROP_ToUri
		#pragma pop_macro("ToUri")
		#endif

	};
}

 

The post Calling .NET from Native C++: How to receive C# event appeared first on xInterop C++ .NET Bridge.


Viewing all articles
Browse latest Browse all 31

Trending Articles