public void TestFriendlyOperationException()
 {
     ExceptionInfo info = null;
     try
     {
         throw new ArgumentException("arg");
     }
     catch (Exception e)
     {
         info = new ExceptionInfo(e);
     }
     FriendlyOperationException exception = new FriendlyOperationException(info);
     IFormatter formatter = new BinaryFormatter();
     byte[] bin = null;
     using (MemoryStream stream = new MemoryStream())
     {
         formatter.Serialize(stream, exception);
         bin = stream.ToArray();
     }
     using (MemoryStream stream = new MemoryStream(bin))
     {
         FriendlyOperationException d = (FriendlyOperationException)formatter.Deserialize(stream);
         Assert.AreEqual(d.ExceptionInfo.ExceptionType, exception.ExceptionInfo.ExceptionType);
         Assert.AreEqual(d.ExceptionInfo.HelpLink, exception.ExceptionInfo.HelpLink);
         Assert.AreEqual(d.ExceptionInfo.Message, exception.ExceptionInfo.Message);
         Assert.AreEqual(d.ExceptionInfo.Source, exception.ExceptionInfo.Source);
         Assert.AreEqual(d.ExceptionInfo.StackTrace, exception.ExceptionInfo.StackTrace);
     }
 }
 protected FriendlyOperationException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     _exceptionInfo = (ExceptionInfo)info.GetValue("_exceptionInfo", typeof(ExceptionInfo));
 }
 public FriendlyOperationException(ExceptionInfo info)
     : base(ExceptionInfoMessageFormat(info))
 {
     _exceptionInfo = info;
 }
 /// <summary>
 /// 例外情報をメッセージ文字列にするフォーマット。
 /// </summary>
 /// <param name="info">例外情報。</param>
 /// <returns>メッセージ文字列。</returns>
 static string ExceptionInfoMessageFormat(ExceptionInfo info)
 {
     if (string.IsNullOrEmpty(info.StackTrace))
     {
         return info.Message;
     }
     return string.Format(CultureInfo.CurrentCulture, Resources.ExceptionInfoFormat,
         info.Message,
         info.ExceptionType,
         info.Source,
         info.StackTrace,
         info.HelpLink);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="exception">例外情報。</param>
 public ReturnInfo(ExceptionInfo exception)
 {
     _exception = exception;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// <param name="exception">例外情報。</param>
 public ReturnInfo(ExceptionInfo exception)
 {
     _exception = exception;
 }