本文整理汇总了C#中System.Error.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Error.ToString方法的具体用法?C# Error.ToString怎么用?C# Error.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Error
的用法示例。
在下文中一共展示了Error.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToStringContainsMessagesCollection
private void ToStringContainsMessagesCollection()
{
var errorMessages = new ErrorMessage[] { new ErrorMessage("key1", "message1"), new ErrorMessage("key2", "message2") };
var error = new Error("id", errorMessages);
Assert.Contains("message1", error.ToString());
Assert.Contains("message2", error.ToString());
}
示例2: HandleError
private void HandleError(ISourceLocation errorLocation, Error error, params string[] messageParameters)
// ^ modifies this.scannerAndParserErrors;
//^ ensures this.currentToken == old(this.currentToken);
{
//^ Token oldToken = this.currentToken;
if (this.originalScannerAndParserErrors == this.scannerAndParserErrors) {
}
this.scannerAndParserErrors.Add(new SpecSharpErrorMessage(errorLocation, (long)error, error.ToString(), messageParameters));
//^ assume this.currentToken == oldToken;
}
示例3: HandleError
private void HandleError(Error error, params string[] messageParameters) {
if (this.endPos <= this.lastReportedErrorPos) return;
if (this.scannerErrors == null) return;
this.lastReportedErrorPos = this.endPos;
ISourceLocation errorLocation;
if (error == Error.BadHexDigit)
errorLocation = this.GetSourceLocation(this.endPos - 1, 1);
else
errorLocation = this.GetSourceLocation(this.startPos, this.endPos - this.startPos);
this.scannerErrors.Add(new SpecSharpErrorMessage(errorLocation, (long)error, error.ToString(), messageParameters));
}
示例4: GetMsg
/// <summary>
/// This method creates a formatted error message constructed using the format
/// string associated with the given error and the list of supplied arguments.
/// The number of arguments must match that of the format string.
/// </summary>
/// <param name="error">The error for which to return an error message.</param>
/// <param name="args">The arguments (if any) to use in formatting the message.</param>
/// <returns>The formatted error message.</returns>
public static string GetMsg( Error error, params object[] args )
{
lock( msgLock )
{
if( messages.ContainsKey( error.ToString() ) )
{
return FormatMessage( error, args );
}
else
{
return FormatNoMessage( args );
}
}
}
示例5: FormatMessage
// note: locking not required here since accessed only through public GetMsg method
private static string FormatMessage( Error error, params object[] args )
{
MessageAttribute ma = messages[ error.ToString() ] as MessageAttribute;
if( ma == null || args.Length != ma.ArgumentCount )
{
throw new GentleException( Error.Unspecified,
String.Format( "Unexpected argument count (passed {0}, expected {1}).",
args.Length, ma.ArgumentCount ) );
}
else
{
return Format( ma.Message, args );
}
}
示例6: OpenMediaCallback
private void OpenMediaCallback(
Error ec)
{
if (ec != Error.success)
{
ErrorOccurred(ec.ToString());
return;
}
Media media;
demuxer_.get_media(out media);
Dictionary<MediaSourceAttributesKeys, string> mediaSourceAttributes =
new Dictionary<MediaSourceAttributesKeys, string>();
mediaSourceAttributes[MediaSourceAttributesKeys.Duration] =
media.duration.ToString();
mediaSourceAttributes[MediaSourceAttributesKeys.CanSeek] =
(media.duration != ulong.MaxValue).ToString();
List<MediaStreamDescription> mediaStreamDescriptions =
new List<MediaStreamDescription>();
for (int i = 0; i < media.streams.Length; ++i)
{
Stream stream = media.streams[i];
Dictionary<MediaStreamAttributeKeys, string> mediaStreamAttributes =
new Dictionary<MediaStreamAttributeKeys, string>();
mediaStreamAttributes[MediaStreamAttributeKeys.CodecPrivateData] =
stream.codec_data.ToString();
if (stream.type == StreamType.video)
{
mediaStreamAttributes[MediaStreamAttributeKeys.VideoFourCC] =
FourCC[(int)stream.sub_type];
mediaStreamAttributes[MediaStreamAttributeKeys.Width] =
stream.video.width.ToString();
mediaStreamAttributes[MediaStreamAttributeKeys.Height] =
stream.video.height.ToString();
char[] CodecPrivateDataHex = new char[stream.codec_data.Length * 2];
int index = 0;
ToHexHelper(CodecPrivateDataHex, ref index, stream.codec_data); // ExtraData
//mediaStreamAttributes[MediaStreamAttributeKeys.CodecPrivateData] =
// new String(CodecPrivateDataHex);
MediaStreamDescription videoStreamDescription =
new MediaStreamDescription(MediaStreamType.Video, mediaStreamAttributes);
mediaStreamDescriptions.Add(videoStreamDescription);
mediaStreamTypes_.Add(MediaStreamType.Video);
mediaStreamDescriptions_[MediaStreamType.Video] = videoStreamDescription;
mediaStreamSamples_[MediaStreamType.Video] = new List<MediaStreamSample>();
//ParseAvcConfig(videoStreamDescription, mediaStreamSamples_[MediaStreamType.Video], stream.codec_data);
}
else if (stream.type == StreamType.audio)
{
char[] WaveFormatExHex = new char[9 * 4 + stream.codec_data.Length * 2];
int index = 0;
ToHexHelper(WaveFormatExHex, ref index, 2, 255); // FormatTag
ToHexHelper(WaveFormatExHex, ref index, 2, stream.audio.channel_count); // Channels
ToHexHelper(WaveFormatExHex, ref index, 4, stream.audio.sample_rate); // SamplesPerSec
ToHexHelper(WaveFormatExHex, ref index, 4, 0); // AverageBytesPerSecond
ToHexHelper(WaveFormatExHex, ref index, 2, 1); // BlockAlign
ToHexHelper(WaveFormatExHex, ref index, 2, stream.audio.sample_size); // BitsPerSample
ToHexHelper(WaveFormatExHex, ref index, 2, stream.codec_data.Length); // ExtraDataSize
ToHexHelper(WaveFormatExHex, ref index, stream.codec_data); // ExtraData
mediaStreamAttributes[MediaStreamAttributeKeys.CodecPrivateData] =
new String(WaveFormatExHex);
MediaStreamDescription audioStreamDescription =
new MediaStreamDescription(MediaStreamType.Audio, mediaStreamAttributes);
mediaStreamDescriptions.Add(audioStreamDescription);
mediaStreamTypes_.Add(MediaStreamType.Audio);
mediaStreamDescriptions_[MediaStreamType.Audio] = audioStreamDescription;
mediaStreamSamples_[MediaStreamType.Audio] = new List<MediaStreamSample>();
}
else
{
mediaStreamTypes_.Add(MediaStreamType.Script);
}
} // for
ReportOpenMediaCompleted(mediaSourceAttributes, mediaStreamDescriptions);
}
示例7: ToStringContainsId
private void ToStringContainsId()
{
var error = new Error("12345");
Assert.Contains("12345", error.ToString());
}
示例8: AstErrorMessage
/// <summary>
/// Allocates an object providing error information relating to a portion of a source document.
/// </summary>
/// <param name="sourceItem">The source item to which the error applies.</param>
/// <param name="error">An enumeration code that corresponds to this error. The enumeration identifier is used as the message key and the enumeration value is used as the code.</param>
/// <param name="relatedLocations">Zero ore more locations that are related to this error.</param>
/// <param name="messageArguments">Zero or more strings that are to be substituted for "{i}" sequences in the message string return by GetMessage.</param>
public AstErrorMessage(ISourceItem sourceItem, Error error, IEnumerable<ILocation> relatedLocations, params string[] messageArguments)
: base(sourceItem.SourceLocation, (long)error, error.ToString(), relatedLocations, messageArguments) {
}
示例9: HandleError
private void HandleError(ISourceLocation errorLocation, Error error, params string[] messageParameters)
// ^ modifies this.scannerAndParserErrors;
{
this.scannerAndParserErrors.Add(new SmallBasicErrorMessage(errorLocation, (long)error, error.ToString(), messageParameters));
}
示例10: FormatError
internal static string FormatError(Error code, int pos)
{
return string.Format(SR.ErrorFormat, code.ToString() , pos, (int)code);
}
示例11: HandleError
private void HandleError(Error error, params string[] messageParameters) {
if (this.endPos <= this.lastReportedErrorPos) return;
if (this.scannerErrors == null) return;
this.lastReportedErrorPos = this.endPos;
ISourceLocation errorLocation;
if (error == Error.BadHexDigit) {
//^ assume 0 <= this.offset+this.endPos-1; //no overflow
//^ assume 0 <= this.sourceLocation.StartIndex+this.offset+this.endPos-1; //no overflow
//^ assume this.sourceLocation.StartIndex+this.offset+this.endPos <= this.sourceLocation.Length; //from invariants
errorLocation = this.GetSourceLocation(this.offset+this.endPos-1, 1);
} else {
//^ assume 0 <= this.offset+this.startPos; //no overflow
//^ assume 0 <= this.sourceLocation.StartIndex+this.offset+this.startPos; //no overflow
//^ assume this.sourceLocation.StartIndex+this.offset+this.endPos <= this.sourceLocation.Length; //from invariants
errorLocation = this.GetSourceLocation(this.offset+this.startPos, this.endPos-this.startPos);
}
this.scannerErrors.Add(new SpecSharpErrorMessage(errorLocation, (long)error, error.ToString(), messageParameters));
}