#pragma once #include #include #include namespace il2cpp { namespace winrt { template::type>::value> struct ReferenceCounter; template struct ReferenceCounter { static inline void AddRef(T& value) { } static inline void Release(T& value) { } }; template struct ReferenceCounter { static inline void AddRef(T& value) { if (value == nullptr) return; value->AddRef(); } static inline void Release(T& value) { if (value == nullptr) return; value->Release(); } }; template<> struct ReferenceCounter { static inline void AddRef(HSTRING& value) { if (value == nullptr) return; auto hr = WindowsDuplicateString(value, &value); Assert(SUCCEEDED(hr)); } static inline void Release(HSTRING& value) { if (value == nullptr) return; auto hr = WindowsDeleteString(value); Assert(SUCCEEDED(hr)); } }; } }