locked
Same signature for Platform::String^ file and Windows::Storage::Streams::IBuffer^ buffer

    Question

  • I wonder why 

    ref class Foo sealed {

    public: Foo(Platform::String^ name); Foo(Windows::Storage::Streams::IBuffer^ buffer); };


    generates the same signature. Calling them from JS will always call the String ctor even if the 1st parameter in JS is of type IBuffer.

    var foo = new Foo(buffer);



    • Edited by phil_ke Monday, April 16, 2012 12:49 PM
    Monday, April 16, 2012 12:48 PM

Answers

  • Hello,

    JavaScript has limited ability to differentiate overloaded methods.

    Therefore, you need to change the function name, or setting the Windows::Foundation::Metadata::DefaultOverloadAttribute to set the default overload function.

    At last, you can change the overload function name.
    [Windows::Foundation::Metadata::Overload("GetInt")]

    Please check the Overloaded methods section in this document
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441569(v=vs.110).aspx#Y3300

    Best regards,
    Jesse


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

    • Marked as answer by phil_ke Tuesday, April 17, 2012 8:27 AM
    Tuesday, April 17, 2012 6:32 AM

All replies

  • Hello,

    JavaScript has limited ability to differentiate overloaded methods.

    Therefore, you need to change the function name, or setting the Windows::Foundation::Metadata::DefaultOverloadAttribute to set the default overload function.

    At last, you can change the overload function name.
    [Windows::Foundation::Metadata::Overload("GetInt")]

    Please check the Overloaded methods section in this document
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh441569(v=vs.110).aspx#Y3300

    Best regards,
    Jesse


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

    • Marked as answer by phil_ke Tuesday, April 17, 2012 8:27 AM
    Tuesday, April 17, 2012 6:32 AM
  • Thanks Jesse! This link was very helpful indeed!

    So from what I read its not possible to have constructors with overloaded parameters like I have?

    Tuesday, April 17, 2012 8:28 AM