Click here to Skip to main content
15,868,087 members
Home / Discussions / C#
   

C#

 
AnswerRe: the action cannot be completed because the file is open in w3wp.exe Pin
Pete O'Hanlon12-Jul-16 22:49
subeditorPete O'Hanlon12-Jul-16 22:49 
AnswerRe: the action cannot be completed because the file is open in w3wp.exe Pin
F-ES Sitecore12-Jul-16 23:40
professionalF-ES Sitecore12-Jul-16 23:40 
GeneralRe: the action cannot be completed because the file is open in w3wp.exe Pin
Rocky Nandu29-Jul-16 1:48
Rocky Nandu29-Jul-16 1:48 
QuestionHow To Wire Up This Event Pin
Kevin Marois12-Jul-16 14:42
professionalKevin Marois12-Jul-16 14:42 
AnswerRe: How To Wire Up This Event Pin
Super Lloyd12-Jul-16 16:43
Super Lloyd12-Jul-16 16:43 
GeneralRe: How To Wire Up This Event Pin
Kevin Marois13-Jul-16 6:14
professionalKevin Marois13-Jul-16 6:14 
GeneralRe: How To Wire Up This Event Pin
Super Lloyd13-Jul-16 7:07
Super Lloyd13-Jul-16 7:07 
GeneralRe: How To Wire Up This Event Pin
Kevin Marois13-Jul-16 7:10
professionalKevin Marois13-Jul-16 7:10 
Ok, so I modified your approach just a bit:
public abstract class BaseViewModel
{
    //  Property to specify the View's type. Needs to be set in each VM subclass.
    public ViewTypes ViewType { get; protected set; }

    // CTOR
    public BaseViewModel()
    {
        ViewType = ViewTypes.None;
        AppCore.DataReceived += AppCore_DataReceived;
    }

    // Listens for Data Received.
    public void AppCore_DataReceived(object sender, DataReceivedArgs args)
    {
        // If the ViewModel matches the data model's type...
        if (CanHandleDataReceived(args))
        {
            // Call DataReceived in the subclass
            DataReceived(args);
        }
    }

    // Determines if the subclass can handle the datas received event
    protected virtual bool CanHandleDataReceived(DataReceivedArgs args) 
    {
        return ViewType == args.ViewType; 
    }

    // Subclass method for receiving the data
    protected abstract void DataReceived(DataReceivedArgs args);
}

The subclasses now only need to set the ViewType property. Then this code checks for the type and if it matches, calls the abstract DataReceived.

What do ya think?
If it's not broken, fix it until it is

GeneralRe: How To Wire Up This Event Pin
Super Lloyd13-Jul-16 13:12
Super Lloyd13-Jul-16 13:12 
Questionapp.Exe.Config Location for Windows 7 & 10 Pin
Chuck Salerno12-Jul-16 13:54
Chuck Salerno12-Jul-16 13:54 
AnswerRe: app.Exe.Config Location for Windows 7 & 10 Pin
Garth J Lancaster12-Jul-16 16:01
professionalGarth J Lancaster12-Jul-16 16:01 
AnswerRe: app.Exe.Config Location for Windows 7 & 10 Pin
Dave Kreskowiak12-Jul-16 16:25
mveDave Kreskowiak12-Jul-16 16:25 
GeneralRe: app.Exe.Config Location for Windows 7 & 10 Pin
Chuck Salerno14-Jul-16 3:43
Chuck Salerno14-Jul-16 3:43 
GeneralRe: app.Exe.Config Location for Windows 7 & 10 Pin
Dave Kreskowiak14-Jul-16 3:56
mveDave Kreskowiak14-Jul-16 3:56 
QuestionHow can I get the index of immediate before special characters of a word in c# Pin
rohit kakria12-Jul-16 7:04
rohit kakria12-Jul-16 7:04 
AnswerRe: How can I get the index of immediate before special characters of a word in c# Pin
Richard Deeming12-Jul-16 7:13
mveRichard Deeming12-Jul-16 7:13 
GeneralRe: How can I get the index of immediate before special characters of a word in c# Pin
rohit kakria12-Jul-16 20:56
rohit kakria12-Jul-16 20:56 
GeneralRe: How can I get the index of immediate before special characters of a word in c# Pin
Richard MacCutchan12-Jul-16 21:23
mveRichard MacCutchan12-Jul-16 21:23 
Questionneed to recover password from this code Pin
Member 1155787712-Jul-16 4:27
Member 1155787712-Jul-16 4:27 
AnswerRe: need to recover password from this code Pin
Eddy Vluggen12-Jul-16 4:44
professionalEddy Vluggen12-Jul-16 4:44 
AnswerRe: need to recover password from this code Pin
Dave Kreskowiak12-Jul-16 5:17
mveDave Kreskowiak12-Jul-16 5:17 
AnswerRe: need to recover password from this code Pin
Patrice T12-Jul-16 8:43
mvePatrice T12-Jul-16 8:43 
AnswerRe: need to recover password from this code Pin
Gerry Schmitz12-Jul-16 11:48
mveGerry Schmitz12-Jul-16 11:48 
QuestionThe type or namespace name 'Form' could not be found (are you missing a using directive or an assembly reference?) Pin
Member 1224497212-Jul-16 2:47
Member 1224497212-Jul-16 2:47 
AnswerRe: The type or namespace name 'Form' could not be found (are you missing a using directive or an assembly reference?) Pin
Eddy Vluggen12-Jul-16 2:53
professionalEddy Vluggen12-Jul-16 2:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.