Click here to Skip to main content
15,921,028 members
Home / Discussions / C#
   

C#

 
GeneralRe: regex Pin
surfman1930-Aug-05 9:28
surfman1930-Aug-05 9:28 
GeneralRe: regex Pin
User 665830-Aug-05 10:18
User 665830-Aug-05 10:18 
GeneralRe: regex Pin
Susan Hernandez31-Aug-05 15:31
Susan Hernandez31-Aug-05 15:31 
Questionforeach DataSet Pin
samoore30-Aug-05 6:19
samoore30-Aug-05 6:19 
QuestionRe: foreach DataSet Pin
Guffa30-Aug-05 8:29
Guffa30-Aug-05 8:29 
AnswerRe: foreach DataSet Pin
samoore30-Aug-05 9:31
samoore30-Aug-05 9:31 
QuestionCustom Sinks Pin
esjq30-Aug-05 5:58
esjq30-Aug-05 5:58 
AnswerRe: Custom Sinks Pin
esjq30-Aug-05 21:37
esjq30-Aug-05 21:37 
The crucial thing here, is where the custom sink is intended to be placed. That is, before or after the formatter sink. If the custom sink is placed before the formatter, you work on the message. On the other hand, if the custom sink is placed after the formatter, you work on the stream.

My intentions was to have my custom sink "above" the formatter sink. And, if the first client sink shall be placed "above" the formatter sink, the IMessage interface needs to be implemented. This was why I had IMessageSink.SyncProcessMessage method in my class of course. In this situation you work on the message, and any manipulation to the message is done in the IMessageSink.SyncProcessMessage (or IMessageSink.AsyncProcessMessage) method. That's why the ProcessMessage method on the client side never was called.

This code snippet shows how to add some information to the message:

public IMessage SyncProcessMessage(IMessage msg)<br />
{<br />
     msg.Properties.Add("Animal", "Fox");<br />
     IMessage retMsg = ((IMessageSink) nextSink).SyncProcessMessage(msg);<br />
     return retMsg;<br />
}



If you rather have your custom sink after the formatter sink, then it is the ProcessMessage method you're supposed to use. If so, the IMessageSink.SyncProcessMessage is not called. In this case you manipulate the array header to pass information to the server side, as follows:

public void ProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, out ITransportHeaders responseHeaders, out System.IO.Stream responseStream)<br />
{<br />
     requestHeaders["Animal"] = "Fox";<br />
                     <br />
     nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out     responseStream);<br />
}



In both cases, the ProcessMessage method on the server side is responsible to get the added information. But you use requestHeaders if you working on the stream, or the requestMsg if you're working on the message.

public ProcessMessage(IServerChannelSinkStack sinkStack,      System.Runtime.Remoting.Messaging.IMessage requestMsg, ITransportHeaders requestHeaders,             System.IO.Stream requestStream, out System.Runtime.Remoting.Messaging.IMessage responseMsg, <br />
out ITransportHeaders responseHeaders, out System.IO.Stream responseStream)<br />
{<br />
    string msg = requestHeaders["Animal"] as string; // stream<br />
    msg = requestMsg.Properties["Animal"] as string; // message<br />
    ...<br />
    ...<br />
}<br />

QuestionTransparency not just in forms Pin
if_mel_yes_else_no30-Aug-05 5:57
if_mel_yes_else_no30-Aug-05 5:57 
QuestionInstalling application using C# Pin
Samar Aarkotti30-Aug-05 5:53
Samar Aarkotti30-Aug-05 5:53 
AnswerRe: Installing application using C# Pin
Guinness4Strength30-Aug-05 9:31
Guinness4Strength30-Aug-05 9:31 
GeneralRe: Installing application using C# Pin
Anonymous30-Aug-05 12:19
Anonymous30-Aug-05 12:19 
GeneralRe: Installing application using C# Pin
Guinness4Strength31-Aug-05 3:54
Guinness4Strength31-Aug-05 3:54 
QuestionQuestion about Mutex Pin
Alex Cutovoi30-Aug-05 5:17
Alex Cutovoi30-Aug-05 5:17 
AnswerRe: Question about Mutex Pin
Andy Brummer30-Aug-05 8:15
sitebuilderAndy Brummer30-Aug-05 8:15 
GeneralRe: Question about Mutex Pin
Alex Cutovoi30-Aug-05 9:25
Alex Cutovoi30-Aug-05 9:25 
GeneralRe: Question about Mutex Pin
Andy Brummer30-Aug-05 10:30
sitebuilderAndy Brummer30-Aug-05 10:30 
GeneralRe: Question about Mutex Pin
Alex Cutovoi30-Aug-05 14:17
Alex Cutovoi30-Aug-05 14:17 
GeneralRe: Question about Mutex Pin
Andy Brummer30-Aug-05 19:30
sitebuilderAndy Brummer30-Aug-05 19:30 
GeneralRe: Question about Mutex Pin
Alex Cutovoi31-Aug-05 2:53
Alex Cutovoi31-Aug-05 2:53 
GeneralRe: Question about Mutex Pin
Alex Cutovoi31-Aug-05 2:56
Alex Cutovoi31-Aug-05 2:56 
QuestionMDI Child with flicker Pin
enricrt30-Aug-05 5:15
enricrt30-Aug-05 5:15 
QuestionListView with column and images Pin
Sasuko30-Aug-05 4:36
Sasuko30-Aug-05 4:36 
AnswerRe: ListView with column and images Pin
Luis Alonso Ramos30-Aug-05 6:43
Luis Alonso Ramos30-Aug-05 6:43 
GeneralRe: ListView with column and images Pin
Sasuko30-Aug-05 7:56
Sasuko30-Aug-05 7:56 

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.