mslavchev / chakra-win10uap

2 stars 0 forks source link

How to create class definition in C# #1

Open pallammadhukar opened 9 years ago

pallammadhukar commented 9 years ago

Hi,

  1. I have class name(string), namespace (string), methods(string[]), properties(string[]). Now I want to create class definition with it. How do I dynamically register a class with methods & properties?
  2. How todo below sample in C#

JsErrorCode err; Microsoft::WRL::ComPtr obj; HStringWrap classId(L"WindowsRuntimeComponent1.Greeter"); Microsoft::WRL::ComPtr factory; HRESULT hr = RoGetActivationFactory(classId, IID_IActivationFactory, reinterpret_cast<void**>(factory.GetAddressOf())); assert(SUCCEEDED(hr)); hr = factory->ActivateInstance(&obj); assert(SUCCEEDED(hr)); JsValueRef ret = nullptr; err = JsInspectableToObject(obj.Get(), &ret); assert(JsNoError == err);

Thanks, Pallam Madhukar

mslavchev commented 9 years ago

I guess you are looking for JsProjectWinRTNamespace function. Using this function you can project a WinRT namespace into the current Chakra context. Here is an exmaple https://github.com/mslavchev/chakra-win10uap/blob/master/src/App1/ChakraDemo.cpp#L74