Platform::Array<unsigned char>^ and Platform::String^ have same signature to JS?
-
mercoledì 14 marzo 2012 13:23
Given this class:
public ref class Foo sealed { public: Foo(Platform::String^ filePath); Foo(Platform::Array<unsigned char>^ buffer); }
The call in JavaScript
Foo('some file path')
and
Foo([1,2,3])
result in ctor Foo(Platform::String^ pdfFile); being called. How can I force JS to call the array ctor when I am using an array?
Thanks!- Modificato phil_ke mercoledì 14 marzo 2012 13:23
Tutte le risposte
-
giovedì 15 marzo 2012 07:59Moderatore
No, the first letter should be lowercase.
If your JavaScript code doesn't seem to recognize the public properties or methods in the component, make sure that in JavaScript you are using camel casing. For example, the ComputeResult C++ method must be referenced as computeResult in JavaScript.
From:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh755833(v=vs.110).aspx
Best regards,
JesseJesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
giovedì 15 marzo 2012 08:53
As you can see Jesse, the first letter has to be uppercase since this is the ctor method I am calling. Any other ideas?
My JS recognizes the public Foo ctor it just always calls the String^ Variant even when called with a byte array as I described.
-
giovedì 10 maggio 2012 10:54
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441569(v=vs.110).aspx
Do not know if it works on ctor overloading..
[Windows::Foundation::Metadata::Overload("FooArray")]
Foo(Platform::Array<unsigned char>^ buffer);
[Windows::Foundation::Metadata::Overload("FooString")]
Foo(Platform::String^ filePath);- Proposto come risposta James Dailey - MSFTMicrosoft Employee, Moderator venerdì 11 maggio 2012 23:17
-
venerdì 11 maggio 2012 01:15Moderatore
Hello phil,
Did adewang82's post answer your question? It looks to me like it should. If you still have questions please let us know.
-James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
-
venerdì 11 maggio 2012 13:38Thanks, I will try that out! :) Although I found a workaround using static functions already.
-
venerdì 11 maggio 2012 15:09No, unfortunately it does not work. The String method is called everytime.
-
sabato 12 maggio 2012 01:29did you call it through FooArray or Foo?
-
sabato 12 maggio 2012 08:56Ah, right, I did not di that. Will try again.
-
giovedì 7 giugno 2012 23:18
This probably does not help but, I did file a bug on this issue.
The response was: functions need to have different arities to be overloaded and be seen from JS.
and since I had to look up arities(http://en.wikipedia.org/wiki/Arities).... it is the number of arguments or operands that the function takes
Thanks
Derek- Contrassegnato come risposta DavidLambMicrosoft Employee, Moderator mercoledì 11 luglio 2012 18:42

