Enhanced C#
Language of your choice: library documentation
|
A message sink wrapper that has a default value for the context parameter, which is used when the context provided is null, and an optional message prefix which is inserted at the beginning of the format string. More...
A message sink wrapper that has a default value for the context parameter, which is used when the context provided is null, and an optional message prefix which is inserted at the beginning of the format string.
Alias for MessageSinkWithContext<object>.
TContext | : | class |
Properties | |
IMessageSink< TContext >?? | Target [get, set] |
TContext | DefaultContext [get, set] |
string | MessagePrefix [get, set] |
Public Member Functions | |
MessageSinkWithContext (IMessageSink< TContext > target, TContext defaultContext, string messagePrefix=null, bool scrubPrefix=true) | |
Initializes the wrapper. More... | |
bool | IsEnabled (Severity level) |
Returns true if messages of the specified type will actually be printed, or false if Write(type, ...) has no effect. More... | |
void | Write (Severity level, TContext context, string format) |
Writes a message to the target that this object represents. More... | |
void | Write (Severity level, TContext context, string format, params object[] args) |
void | Write (Severity level, TContext context, string format, object arg0, object arg1=null) |
MessageSinkWithContext (IMessageSink target, object defaultContext, string messagePrefix=null, bool scrubPrefix=true) | |
Public Member Functions inherited from Loyc.IMessageSink< TContext > | |
void | Write (Severity level, TContext context,[Localizable] string format) |
Writes a message to the target that this object represents. More... | |
void | Write (Severity level, TContext context,[Localizable] string format, object arg0, object arg1=null) |
void | Write (Severity level, TContext context,[Localizable] string format, params object[] args) |
bool | IsEnabled (Severity level) |
Returns true if messages of the specified type will actually be printed, or false if Write(type, ...) has no effect. More... | |
|
inline |
Initializes the wrapper.
target | Message sink to which all messages are forwarded. If this parameter is null, then messages are written to MessageSink.Default at the time a message is written. |
defaultContext | Default context object, used if Write is called with a context of null. |
messagePrefix | A prefix to prepend at the beginning of all messages written. |
scrubPrefix | Whether to replace "{" with ""{{" and "}" with "}}" in messagePrefix to avoid accidental misbehavior when the string is formatted. Note: in fact, messagePrefix should not contain braces at all, because message formatting is optional. Write(Severity, TContext, string) does not perform formatting while Write(Severity, TContext, string, object[]) does. Consequently, when calling the first overload, the scrubbing process will cause braces in messagePrefix to be doubled as in "{{" or "}}". We could fix this by storing two separate MessagePrefix strings in this object, one for each situation, but that's currently not implemented as it is simpler to just ask users not to put braces in prefixes. |
|
inline |
Returns true if messages of the specified type will actually be printed, or false if Write(type, ...) has no effect.
Implements Loyc.IMessageSink< in in TContext >.
References Loyc.IMessageSink< in in TContext >.IsEnabled().
Referenced by Loyc.MessageSinkWithContext< TContext >.Write().
|
inline |
Writes a message to the target that this object represents.
level | Severity or importance of the message; widely-used types include Error, Warning, Note, Debug, and Verbose. The special type Detail is intended to provide more information about a previous message. |
context | An object that the message is related to, or that represents the location that the message applies to. The message sink may try to convert this object to a string and include it in its output. See also MessageSink.ContextToString(). |
format | A message to display. If there are additional arguments, placeholders such as {0} and {1} refer to these arguments. |
Implements Loyc.IMessageSink< in in TContext >.
References Loyc.MessageSinkWithContext< TContext >.IsEnabled(), and Loyc.IMessageSink< in in TContext >.Write().