forked from dotnet/ResXResourceManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeReferenceConfiguration.cs
70 lines (56 loc) · 2.99 KB
/
CodeReferenceConfiguration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
namespace tomenglertde.ResXManager.Model
{
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Runtime.Serialization;
using JetBrains.Annotations;
[DataContract]
public sealed class CodeReferenceConfigurationItem : INotifyPropertyChanged
{
[DataMember, CanBeNull]
public string Extensions { get; set; }
[DataMember]
public bool IsCaseSensitive { get; set; }
[DataMember, CanBeNull]
public string Expression { get; set; }
[DataMember, CanBeNull]
public string SingleLineComment { get; set; }
[NotNull, ItemNotNull]
public IEnumerable<string> ParseExtensions()
{
Contract.Ensures(Contract.Result<IEnumerable<string>>() != null);
if (string.IsNullOrEmpty(Extensions))
return Enumerable.Empty<string>();
return Extensions.Split(',')
// ReSharper disable once PossibleNullReferenceException
.Select(ext => ext.Trim())
.Where(ext => !string.IsNullOrEmpty(ext));
}
#region INotifyPropertyChanged implementation
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator, UsedImplicitly]
private void OnPropertyChanged([NotNull] string propertyName)
{
Contract.Requires(propertyName != null);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
[KnownType(typeof(CodeReferenceConfigurationItem))]
[DataContract]
[TypeConverter(typeof(JsonSerializerTypeConverter<CodeReferenceConfiguration>))]
[UsedImplicitly]
public sealed class CodeReferenceConfiguration : ItemTrackingCollectionHost<CodeReferenceConfigurationItem>
{
public const string Default = @"{""Items"":[
{""Expression"":""\\W($File.$Key)\\W"",""Extensions"":"".cs,.xaml,.cshtml"",""IsCaseSensitive"":true,""SingleLineComment"":""\/\/""},
{""Expression"":""ResourceManager.GetString\\(\""($Key)\""\\)"",""Extensions"":"".cs"",""IsCaseSensitive"":true,""SingleLineComment"":""\/\/""},
{""Expression"":""typeof\\((\\w+\\.)*($File)\\).+\""($Key)\""|\""($Key)\"".+typeof\\((\\w+\\.)*($File)\\)"",""Extensions"":"".cs"",""IsCaseSensitive"":true,""SingleLineComment"":""\/\/""},
{""Expression"":""\\W($Key)\\W"",""Extensions"":"".vb"",""IsCaseSensitive"":false,""SingleLineComment"":""'""},
{""Expression"":""\\W($File::$Key)\\W"",""Extensions"":"".cpp,.c,.hxx,.h"",""IsCaseSensitive"":true,""SingleLineComment"":""\/\/""},
{""Expression"":""<%\\$\\s+Resources:\\s*($File)\\s*,\\s*($Key)\\s*%>"",""Extensions"":"".aspx,.ascx,.master"",""IsCaseSensitive"":true,""SingleLineComment"":null},
{""Expression"":""StringResourceKey\\.($Key)"",""Extensions"":"".cs"",""IsCaseSensitive"":true,""SingleLineComment"":""\/\/""}]}";
}
}