Click here to Skip to main content
15,895,256 members
Home / Discussions / C#
   

C#

 
Answer[Cross Post]Re: Making scrol lbox custom controls using compact framework sdk Pin
Scott Dorman22-Jun-08 10:34
professionalScott Dorman22-Jun-08 10:34 
QuestionHelp. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
TheFoZ22-Jun-08 8:04
TheFoZ22-Jun-08 8:04 
AnswerRe: Help. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
User 665822-Jun-08 8:22
User 665822-Jun-08 8:22 
GeneralRe: Help. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
TheFoZ22-Jun-08 8:25
TheFoZ22-Jun-08 8:25 
GeneralRe: Help. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
Harvey Saayman22-Jun-08 8:56
Harvey Saayman22-Jun-08 8:56 
GeneralRe: Help. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
TheFoZ22-Jun-08 9:16
TheFoZ22-Jun-08 9:16 
GeneralRe: Help. I'm Lost. How to retrieve the selected row information from a DataGridView Pin
Paul Conrad22-Jun-08 9:36
professionalPaul Conrad22-Jun-08 9:36 
QuestionHow to call base class methods automatically? Pin
Metal7622-Jun-08 7:34
Metal7622-Jun-08 7:34 
Hi, as you might know from an older post (here) I'm working on a communication protocol driver in C#.

Protocol messages can be of two types (commands and responses) so I chose the following class structure:

public abstract class Message
{
    // Properties & methods representing fields common to all messages
    protected byte[] CompileCommonPacketPart()
    {
         // Compiles a part of the packet from the common fields
    }
}

public abstract class Command : Message
{
    // Additional fields and methods available for all commands
    protected byte[] CompileCommandPacketPart()
    { 
         // Compiles a part of the packet from command-specific data
    }
}

public abstract class Response : Message
{
    // Additional fields and methods available for all responses
    protected byte[] CompileResponsePacketPart()
    { 
         // Compiles a part of the packet from response-specific data
    }
}

public class MyCommand : Command
{
    // Concrete command class, adds data 
    // specific to this particular command
    public byte[] CompilePacket()
    { 
         // Compiles the generic parts of the command
         CompileCommonPacketPart();
         CompileCommandPacketPart();
         
         // Adds parts specific to this command
         ...
    }
}


As you see, at the moment CompilePacket() explicitly includes calls to the base methods in order to compile the generic parts of the packet, and every time I define a new command I must manually insert these calls.

This could be error-prone (I have to deal with a lot of commands...) and I feel that there should be a way to factor out this common behaviour...

Is there any way to perform these calls automatically (not explicitly)?

Thanks in advance for your support!

Andrea
AnswerRe: How to call base class methods automatically? Pin
Scott Dorman22-Jun-08 7:50
professionalScott Dorman22-Jun-08 7:50 
AnswerRe: How to call base class methods automatically? [modified] Pin
User 665822-Jun-08 8:09
User 665822-Jun-08 8:09 
AnswerRe: How to call base class methods automatically? Pin
S. Senthil Kumar22-Jun-08 10:17
S. Senthil Kumar22-Jun-08 10:17 
AnswerRe: How to call base class methods automatically? Pin
Joe Woodbury22-Jun-08 13:27
professionalJoe Woodbury22-Jun-08 13:27 
GeneralRe: How to call base class methods automatically? Pin
Metal7623-Jun-08 4:05
Metal7623-Jun-08 4:05 
QuestionGet Class Info Pin
half-life22-Jun-08 5:45
half-life22-Jun-08 5:45 
AnswerRe: Get Class Info Pin
zafersavas22-Jun-08 5:57
zafersavas22-Jun-08 5:57 
GeneralRe: Get Class Info Pin
0x3c022-Jun-08 6:15
0x3c022-Jun-08 6:15 
GeneralRe: Get Class Info Pin
half-life23-Jun-08 8:26
half-life23-Jun-08 8:26 
QuestionConverting Firefox's icon string to the image !!! Pin
Mohammad Dayyan22-Jun-08 3:58
Mohammad Dayyan22-Jun-08 3:58 
AnswerRe: Converting Firefox's icon string to the image !!! Pin
User 665822-Jun-08 4:03
User 665822-Jun-08 4:03 
GeneralRe: Converting Firefox's icon string to the image !!! Pin
Mohammad Dayyan22-Jun-08 4:14
Mohammad Dayyan22-Jun-08 4:14 
QuestionHow to stop running thread ? Pin
Yanshof22-Jun-08 3:29
Yanshof22-Jun-08 3:29 
AnswerRe: How to stop running thread ? Pin
Guffa22-Jun-08 3:33
Guffa22-Jun-08 3:33 
AnswerRe: How to stop running thread ? Pin
half-life22-Jun-08 5:03
half-life22-Jun-08 5:03 
GeneralRe: How to stop running thread ? Pin
N a v a n e e t h22-Jun-08 5:39
N a v a n e e t h22-Jun-08 5:39 
AnswerRe: How to stop running thread ? Pin
N a v a n e e t h22-Jun-08 5:37
N a v a n e e t h22-Jun-08 5:37 

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.