Ignore:
Timestamp:
3/30/2012 5:52:34 AM (3 years ago)
Author:
lowjoel
Message:

Switch the Default Plugin's erasure targets to follow the new IXmlSerializable interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/XmlTaskLists/Eraser.DefaultPlugins/ErasureTargets/FolderErasureTarget.cs

    r2561 r2584  
    2626 
    2727using System.Text.RegularExpressions; 
    28 using System.Runtime.Serialization; 
     28using System.Xml; 
     29using System.Xml.Serialization; 
    2930using System.Runtime.InteropServices; 
    30 using System.Security.Permissions; 
    3131using System.IO; 
     32using System.Globalization; 
    3233 
    3334using Eraser.Util; 
     
    4546    { 
    4647        #region Serialization code 
    47         protected FolderErasureTarget(SerializationInfo info, StreamingContext context) 
    48             : base(info, context) 
    49         { 
    50             IncludeMask = (string)info.GetValue("IncludeMask", typeof(string)); 
    51             ExcludeMask = (string)info.GetValue("ExcludeMask", typeof(string)); 
    52             DeleteIfEmpty = (bool)info.GetValue("DeleteIfEmpty", typeof(bool)); 
    53         } 
    54  
    55         [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] 
    56         public override void GetObjectData(SerializationInfo info, StreamingContext context) 
    57         { 
    58             base.GetObjectData(info, context); 
    59             info.AddValue("IncludeMask", IncludeMask); 
    60             info.AddValue("ExcludeMask", ExcludeMask); 
    61             info.AddValue("DeleteIfEmpty", DeleteIfEmpty); 
     48        public override void ReadXml(XmlReader reader) 
     49        { 
     50            base.ReadXml(reader); 
     51            IncludeMask = reader.GetAttribute("includeMask"); 
     52            ExcludeMask = reader.GetAttribute("excludeMask"); 
     53 
     54            if (reader.HasAttributes) 
     55            { 
     56                bool deleteIfEmpty = true; 
     57                bool.TryParse(reader.GetAttribute("deleteIfEmpty"), out deleteIfEmpty); 
     58                DeleteIfEmpty = deleteIfEmpty; 
     59            } 
     60        } 
     61 
     62        public override void WriteXml(XmlWriter writer) 
     63        { 
     64            base.WriteXml(writer); 
     65            writer.WriteAttributeString("includeMask", IncludeMask); 
     66            writer.WriteAttributeString("excludeMask", ExcludeMask); 
     67            writer.WriteAttributeString("deleteIfEmpty", 
     68                DeleteIfEmpty.ToString(CultureInfo.InvariantCulture)); 
    6269        } 
    6370        #endregion 
Note: See TracChangeset for help on using the changeset viewer.