<commit_before>﻿namespace tomenglertde.ResXManager.VSIX
{
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using System.Runtime.Serialization;

    using JetBrains.Annotations;

    using tomenglertde.ResXManager.Model;

    [DataContract]
    public sealed class MoveToResourceConfigurationItem : INotifyPropertyChanged
    {
        [DataMember, CanBeNull]
        public string Extensions { get; set; }

        [DataMember, CanBeNull]
        public string Patterns { 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(',')
                .Select(ext => ext.Trim())
                .Where(ext => !string.IsNullOrEmpty(ext));
        }

        [NotNull, ItemNotNull]
        public IEnumerable<string> ParsePatterns()
        {
            Contract.Ensures(Contract.Result<IEnumerable<string>>() != null);

            if (string.IsNullOrEmpty(Patterns))
                return Enumerable.Empty<string>();

            return Patterns.Split('|')
                .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(MoveToResourceConfigurationItem))]
    [DataContract]
    [TypeConverter(typeof(JsonSerializerTypeConverter<MoveToResourceConfiguration>))]
    [UsedImplicitly]
    public class MoveToResourceConfiguration : ItemTrackingCollectionHost<MoveToResourceConfigurationItem>
    {
        public const string Default = @"{""Items"":
[{""Extensions"":"".cs,.vb"",""Patterns"":""$Namespace.$File.$Key|$File.$Key|StringResourceKey.$Key|$Namespace.StringResourceKey.$Key|nameof($File.$Key), ResourceType = typeof($File)|ErrorMessageResourceType = typeof($File), ErrorMessageResourceName = nameof($File.$Key)""}
,{""Extensions"":"".cshtml,.vbhtml"",""Patterns"":""@$Namespace.$File.$Key|@$File.$Key|@StringResourceKey.$Key|@$Namespace.StringResourceKey.$Key""}
,{""Extensions"":"".cpp,.c,.hxx,.h"",""Patterns"":""$File::$Key""}
,{""Extensions"":"".aspx,.ascx"",""Patterns"":""&lt;%$ Resources:$File,$Key %&gt;""}
,{""Extensions"":"".xaml"",""Patterns"":""\""{x:Static properties:$File.$Key}\""""}]}";
    }
}<commit_msg>Fix #135: MoveToResource patterns for aspx - fix existing pattern and add alternatives.<commit_after>﻿namespace tomenglertde.ResXManager.VSIX
{
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using System.Runtime.Serialization;

    using JetBrains.Annotations;

    using tomenglertde.ResXManager.Model;

    [DataContract]
    public sealed class MoveToResourceConfigurationItem : INotifyPropertyChanged
    {
        [DataMember, CanBeNull]
        public string Extensions { get; set; }

        [DataMember, CanBeNull]
        public string Patterns { 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(',')
                .Select(ext => ext.Trim())
                .Where(ext => !string.IsNullOrEmpty(ext));
        }

        [NotNull, ItemNotNull]
        public IEnumerable<string> ParsePatterns()
        {
            Contract.Ensures(Contract.Result<IEnumerable<string>>() != null);

            if (string.IsNullOrEmpty(Patterns))
                return Enumerable.Empty<string>();

            return Patterns.Split('|')
                .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(MoveToResourceConfigurationItem))]
    [DataContract]
    [TypeConverter(typeof(JsonSerializerTypeConverter<MoveToResourceConfiguration>))]
    [UsedImplicitly]
    public class MoveToResourceConfiguration : ItemTrackingCollectionHost<MoveToResourceConfigurationItem>
    {
        public const string Default = @"{""Items"":
[{""Extensions"":"".cs,.vb"",""Patterns"":""$Namespace.$File.$Key|$File.$Key|StringResourceKey.$Key|$Namespace.StringResourceKey.$Key|nameof($File.$Key), ResourceType = typeof($File)|ErrorMessageResourceType = typeof($File), ErrorMessageResourceName = nameof($File.$Key)""}
,{""Extensions"":"".cshtml,.vbhtml"",""Patterns"":""@$Namespace.$File.$Key|@$File.$Key|@StringResourceKey.$Key|@$Namespace.StringResourceKey.$Key""}
,{""Extensions"":"".cpp,.c,.hxx,.h"",""Patterns"":""$File::$Key""}
,{""Extensions"":"".aspx,.ascx"",""Patterns"":""<%$ Resources:$File,$Key >|<%= $File.$Key >|<%= $Namespace.$File.$Key >""}
,{""Extensions"":"".xaml"",""Patterns"":""\""{x:Static properties:$File.$Key}\""""}]}";
    }
}
{'fraction_non_alphanumeric': 0.1514586160108548, 'fraction_numerical': 0.0005088195386702849, 'mean_word_length': 3.501526717557252, 'pattern_counts': {'":': 22, '<': 26, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4433087', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1611, 'n_words': 244}