1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using ICSharpCode.Core;
7
namespace SearchAndReplace
9
public enum SearchStrategyType {
15
public static class SearchOptions
17
const string searchPropertyKey = "SearchAndReplaceProperties";
19
static Properties properties;
21
public static Properties Properties {
26
static string findPattern = "";
27
static string replacePattern = "";
29
#region Search & Replace properties
30
public static string FindPattern {
35
if (value != FindPattern) {
37
string[] oldPatterns = FindPatterns;
38
string[] newPatterns = new string[oldPatterns.Length + 1];
39
oldPatterns.CopyTo(newPatterns, 1);
40
newPatterns[0] = value;
41
FindPatterns = newPatterns;
46
public static string CurrentFindPattern {
55
public static string[] FindPatterns {
57
if (!properties.Contains("FindPatterns")) {
58
return new string[] {};
60
return properties.Get("FindPatterns", "").Split('\xFF');
63
properties.Set("FindPatterns", String.Join("\xFF", value));
67
public static string ReplacePattern {
69
if (!properties.Contains("ReplacePatterns")) {
72
return replacePattern;
75
if (value != ReplacePattern) {
76
string[] oldPatterns = ReplacePatterns;
77
string[] newPatterns = new string[oldPatterns.Length + 1];
78
oldPatterns.CopyTo(newPatterns, 1);
79
newPatterns[0] = value;
80
ReplacePatterns = newPatterns;
81
replacePattern = value;
86
public static string[] ReplacePatterns {
88
if (!properties.Contains("ReplacePatterns")) {
89
return new string[] {};
92
return properties.Get("ReplacePatterns", "").Split('\xFF');
95
properties.Set("ReplacePatterns", String.Join("\xFF", value));
99
public static bool MatchCase {
101
return properties.Get("MatchCase", false);
104
properties.Set("MatchCase", value);
108
public static bool IncludeSubdirectories {
110
return properties.Get("IncludeSubdirectories", false);
113
properties.Set("IncludeSubdirectories", value);
117
public static bool MatchWholeWord {
119
return properties.Get("MatchWholeWord", false);
122
properties.Set("MatchWholeWord", value);
126
public static string LookIn {
128
return properties.Get("LookIn", @"C:\");
131
properties.Set("LookIn", value);
135
public static string LookInFiletypes {
137
return properties.Get("LookInFiletypes", "*.*");
140
properties.Set("LookInFiletypes", value);
144
public static DocumentIteratorType DocumentIteratorType {
146
return properties.Get("DocumentIteratorType", DocumentIteratorType.CurrentDocument);
149
if (!Enum.IsDefined(typeof(DocumentIteratorType), value))
150
throw new ArgumentException("invalid enum value");
151
properties.Set("DocumentIteratorType", value);
155
public static SearchStrategyType SearchStrategyType {
157
return properties.Get("SearchStrategyType", SearchStrategyType.Normal);
160
properties.Set("SearchStrategyType", value);
165
static SearchOptions()
167
properties = PropertyService.Get(searchPropertyKey, new Properties());