OSDN Git Service

コード分析による警告へ対応
authorkomutan <t_komuta@nifty.com>
Fri, 25 Apr 2014 01:09:27 +0000 (10:09 +0900)
committerkomutan <t_komuta@nifty.com>
Fri, 25 Apr 2014 01:09:27 +0000 (10:09 +0900)
src/LibNMeCab/MeCabException.cs
src/LibNMeCab/MeCabFileFormatException.cs
src/LibNMeCab/MeCabInvalidFileException.cs

index 5f92fcc..3188210 100644 (file)
@@ -3,11 +3,11 @@
 //  Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
 //  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
 using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Runtime.Serialization;
 
 namespace NMeCab
 {
+    [Serializable]
     public class MeCabException : Exception
     {
         public MeCabException(string message)
@@ -17,5 +17,9 @@ namespace NMeCab
         public MeCabException(string message, Exception ex)
             : base(message, ex)
         { }
+
+        public MeCabException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        { }
     }
 }
index c54ecff..0dfdb03 100644 (file)
@@ -3,11 +3,13 @@
 //  Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
 //  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
 using System;
-using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
 using System.Text;
 
 namespace NMeCab
 {
+    [Serializable]
     public class MeCabFileFormatException : MeCabInvalidFileException
     {
         public int LineNo { get; private set; }
@@ -32,5 +34,20 @@ namespace NMeCab
             this.LineNo = lineNo;
             this.Line = line;
         }
+
+        public MeCabFileFormatException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            this.LineNo = info.GetInt32("LineNo");
+            this.Line = info.GetString("Line");
+        }
+
+        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("LineNo", this.LineNo);
+            info.AddValue("Line", this.Line);
+        }
     }
 }
index e8ba586..46a93ef 100644 (file)
@@ -3,11 +3,13 @@
 //  Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
 //  Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
 using System;
-using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Security.Permissions;
 using System.Text;
 
 namespace NMeCab
 {
+    [Serializable]
     public class MeCabInvalidFileException : MeCabException
     {
         public string FileName { get; private set; }
@@ -28,5 +30,18 @@ namespace NMeCab
         {
             this.FileName = fileName;
         }
+
+        public MeCabInvalidFileException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+            this.FileName = info.GetString("FileName");
+        }
+
+        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("FileName", this.FileName);
+        }
     }
 }