Click or drag to resize
RegExFilePreTweaker Class
An implementation of a FileTweaker that can be used by filters to perform the simple task of replacing text in a native file.
Inheritance Hierarchy
SystemObject
  Sdl.FileTypeSupport.Framework.Core.Utilities.NativeApiAbstractFilePreTweaker
    Sdl.FileTypeSupport.Framework.Core.Utilities.NativeApiRegExFilePreTweaker

Namespace: Sdl.FileTypeSupport.Framework.Core.Utilities.NativeApi
Assembly: Sdl.FileTypeSupport.Framework.Core.Utilities (in Sdl.FileTypeSupport.Framework.Core.Utilities.dll) Version: 1.0.0.0 (1.0.2551.0)
Syntax
public class RegExFilePreTweaker : AbstractFilePreTweaker

The RegExFilePreTweaker type exposes the following members.

Constructors
  NameDescription
Public methodRegExFilePreTweaker
Default constructor. If the object is created with this constructor, then ReplaceInfo should be set.
Public methodRegExFilePreTweaker(ListString, ListString)
Constructor that takes two ordered lists of strings that contain the match and replace values to apply to the file. The first item in the list of matches will be replace by the first item in the list of replacements, and so on.
Public methodRegExFilePreTweaker(String, String)
Simple constructor that can be used when there is only a single match/replace to be performed on the native file.
Top
Properties
  NameDescription
Public propertyEnabled
Controls whether the tweaker is run during parsing. Default is true.
(Inherited from AbstractFilePreTweaker.)
Public propertyMessageReporter
The default implementation stores the message reporter in a field.
(Inherited from AbstractFilePreTweaker.)
Protected propertyName
The property contains a name for the file tweaker that can be overridden in derived classes. This name is used in error messages.
(Inherited from AbstractFilePreTweaker.)
Public propertyReplaceInfo
The list of RegEx match and replace values. These values will be used during either the Tweak or UnTweak processes depending on whether the FileTweaker is added to the Extractor or to the Generator
Public propertyRequireValidEncoding
This property governs whether the File Tweaker requires encoding information before it will tweak a file. This may be needed to ensure that the file the tweaker uses the correct encoding.
(Inherited from AbstractFilePreTweaker.)
Top
Methods
  NameDescription
Protected methodTweak
The implementation of the Tweak method from the AbstractFilePreTweaker base class.
(Overrides AbstractFilePreTweakerTweak(IPersistentFileConversionProperties).)
Public methodTweakFilePreParsing
Default implementation of the INativeFileTweaker.TweakFilePreParsing method that will check to see if the file will be tweaked (see WillFileBeTweaked), and whether the encoding has been detected during sniffing if RequireValidEncoding is true and then call Tweak. Derived classes should normally override the Tweak method instead.
(Inherited from AbstractFilePreTweaker.)
Protected methodWillFileBeTweaked
The implementation of the WillFileBeTweaked method from the AbstractFilePreTweaker base class.
(Overrides AbstractFilePreTweakerWillFileBeTweaked(String).)
Top
Examples
Normally, this class would be derived from to create a specific implementation for a particular file type. E.g.:
     public class XmlFilePreTweaker : RegExFilePreTweaker
{
    public XmlFilePreTweaker()
    {
        List<Pair<string, string>> replaceInfo = new List<Pair<string, string>>();

        replaceInfo.Add(new Pair<string, string>("&lt;", "<SDL:lt />"));
        replaceInfo.Add(new Pair<string, string>("&gt;", "<SDL:gt />"));
        replaceInfo.Add(new Pair<string, string>("&quot;", "<SDL:quot />"));
        replaceInfo.Add(new Pair<string, string>("&apos;", "<SDL:apos />"));
        replaceInfo.Add(new Pair<string, string>("&amp;", "<SDL:amp />"));

        base.ReplaceInfo = replaceInfo;
    }
}
See Also
Community
Edit

Be the first to Edit the community content of this topic.
Comments