locked
How do you create a ref base class that you can derive from?

    Question

  • Source code: http://www.Global-Webnet.net/Forums/ClientManager.zip (81meg)

    Since the thread for "can a ref class be inherited, if can how?" has been marked as answered I'll have to start a new thread as the answers don't cover my scenario (the following quotes are from that thread).



    [Jesse] "that inherits from Dependency Object"
    (ref figure 3)

    Everything compiles and runs with the exception (no pun intended) of Unit Test - my test fails (ref figure 1), I suspect because something is happening on the UI thread...



    [NishAnt] "or introduce a dummy base class that's private just so you can derive A from that and then make it public"
    (ref figure 2)

    If I attempt to make a base class private the compiler complains that "Base is less accessible than 'PresenterBase'".  My attempts to find a base class for my Presenter that will compile and run for both the application and unit test are not going well - any suggestions would be appreciated!




    Figure 1

    #pragma once
    
    #include "IPresenter.h"
    
    namespace WUX = Windows::UI::Xaml;
    namespace WFM = Windows::Foundation::Metadata;
    
    namespace MvpVmWrc{
    	namespace MvpVm 
    	{
    		private ref class Base : IPresenter
    		{
    		}
    
    		[WFM::WebHostHidden] // TypeName is WebHostHidden
    		public ref  class PresenterBase : Base, IPresenter
    		{
    		internal:
    			PresenterBase(){}
    
    		public:
    			TypeName GetPresenterView();
    			void SetArguments(Platform::String^ arguments);
    			property Platform::String^ Arguments;
    		};
    
    		[WFM::WebHostHidden] // TypeName in base is WebHostHidden
    		public ref class UserPresenter sealed: MvpVmWrc::MvpVm::PresenterBase
    		{
    		public:
    			UserPresenter(){}
    		};
    	}
    }
    Figure 2
    #pragma once
    
    #include "IPresenter.h"
    
    namespace WUX = Windows::UI::Xaml;
    namespace WFM = Windows::Foundation::Metadata;
    
    namespace MvpVmWrc{
    	namespace MvpVm 
    	{
    		[WFM::WebHostHidden] // TypeName is WebHostHidden
    		public ref  class PresenterBase : WUX::DependencyObject, IPresenter
    		{
    		internal:
    			PresenterBase(){}
    
    		public:
    			TypeName GetPresenterView();
    			void SetArguments(Platform::String^ arguments);
    			property Platform::String^ Arguments;
    		};
    
    		[WFM::WebHostHidden] // TypeName in base is WebHostHidden
    		public ref class UserPresenter sealed: MvpVmWrc::MvpVm::PresenterBase
    		{
    		public:
    			UserPresenter(){}
    		};
    	}
    }
    
    Figure 3

    MCAD.NET C# - http://www.Global-webnet.com/Blog


    • Edited by BillKrat1 Saturday, August 25, 2012 1:27 PM Formatting (being anal)
    Saturday, August 25, 2012 1:07 PM

Answers

  • After much research and understanding the environment more I came up with "A solution"
    I blog about it HERE


    MCAD.NET C# - http://www.Global-webnet.com/Blog

    • Marked as answer by BillKrat1 Sunday, August 26, 2012 5:16 PM
    Sunday, August 26, 2012 5:16 PM

All replies

  • After much research and understanding the environment more I came up with "A solution"
    I blog about it HERE


    MCAD.NET C# - http://www.Global-webnet.com/Blog

    • Marked as answer by BillKrat1 Sunday, August 26, 2012 5:16 PM
    Sunday, August 26, 2012 5:16 PM
  • Thanks for sharing the solution.

    Best regards,
    Jesse


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

    Monday, August 27, 2012 7:29 AM