Platform::Array<unsigned char>^ and Platform::String^ have same signature to JS?

Answered Platform::Array<unsigned char>^ and Platform::String^ have same signature to JS?

  • Mittwoch, 14. März 2012 13:23
     
      Enthält Code

    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!


    • Bearbeitet phil_ke Mittwoch, 14. März 2012 13:23
    •  

Alle Antworten

  • Donnerstag, 15. März 2012 07:59
    Moderator
     
     

    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,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

  • Donnerstag, 15. März 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.

  • Donnerstag, 10. Mai 2012 10:54
     
     Vorgeschlagene Antwort

    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);

  • Freitag, 11. Mai 2012 01:15
    Moderator
     
     

    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/

  • Freitag, 11. Mai 2012 13:38
     
     
    Thanks, I will try that out! :) Although I found a workaround using static functions already.
  • Freitag, 11. Mai 2012 15:09
     
     
    No, unfortunately it does not work. The String method is called everytime.
  • Samstag, 12. Mai 2012 01:29
     
     
    did you call it through FooArray or Foo?
  • Samstag, 12. Mai 2012 08:56
     
     
    Ah, right, I did not di that. Will try again.
  • Donnerstag, 7. Juni 2012 23:18
     
     Beantwortet

    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