private SequenceRecognizer(SequenceOptions options)
 {
     RegisterModel(Culture.English, options.ToString(), new Dictionary <Type, IModel>
     {
         [typeof(PhoneNumberModel)] = new PhoneNumberModel(new PhoneNumberParser(), new PhoneNumberExtractor())
     });
 }
Пример #2
0
 public EnglishPhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = BasePhoneNumbers.WordBoundariesRegex;
     NonWordBoundariesRegex = BasePhoneNumbers.NonWordBoundariesRegex;
     EndWordBoundariesRegex = BasePhoneNumbers.EndWordBoundariesRegex;
 }
Пример #3
0
        protected override void OnSingleInitialization()
        {
            var seqOptions = attributes.GetAttribute <SeqAttribute>();

            options          = new SequenceOptions(seqOptions != null ? seqOptions.options : SeqOpt.None);
            options.Advanced = options.Advanced || attributes.AnyIs <AdvancedAttribute>();
            options.Readonly = options.Readonly || attributes.AnyIs <ReadonlyAttribute>();

            // Sequence name
            {
                var formatMember = attributes.GetAttribute <FormatMemberAttribute>();
                if (formatMember != null)
                {
                    sequenceName = formatMember.Format(niceName, memberType.GetNiceName());
                }
                else
                {
                    sequenceName = niceName + " (" + memberType.GetNiceName() + ")";
                }

                if (options.Readonly)
                {
                    sequenceName += " (Readonly)";
                }
            }

            advancedKey          = id + sequenceName + "advanced";
            perItemDrawing       = attributes.AnyIs <PerItemAttribute>();
            shouldDrawAddingArea = !options.Readonly && elementType.IsA <UnityObject>();
        }
 public ChinesePhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = PhoneNumbersDefinitions.WordBoundariesRegex;
     NonWordBoundariesRegex = PhoneNumbersDefinitions.NonWordBoundariesRegex;
     EndWordBoundariesRegex = PhoneNumbersDefinitions.EndWordBoundariesRegex;
 }
Пример #5
0
        public TestSequenceRecognizerInitialization()
        {
            var config = new SequenceOptions();

            controlModel = new PhoneNumberModel(
                new English.PhoneNumberParser(),
                new BasePhoneNumberExtractor(new EnglishPhoneNumberExtractorConfiguration(config)));
        }
Пример #6
0
 public SqlServerSequence(SequenceOptions options) : this()
 {
     StartAt      = options.StartAt;
     CurrentValue = StartAt;
     Increment    = options.Increment;
     MaxValue     = options.MaxValue;
     MinValue     = options.MinValue;
     Cycle        = options.Cycle;
 }
 public ChinesePhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = PhoneNumbersDefinitions.WordBoundariesRegex;
     NonWordBoundariesRegex = PhoneNumbersDefinitions.NonWordBoundariesRegex;
     EndWordBoundariesRegex = PhoneNumbersDefinitions.EndWordBoundariesRegex;
     ColonPrefixCheckRegex  = new Regex(PhoneNumbersDefinitions.ColonPrefixCheckRegex);
     ForbiddenPrefixMarkers = (List <char>)PhoneNumbersDefinitions.ForbiddenPrefixMarkers;
 }
Пример #8
0
 public Sequence(SequenceOptions options):this()
 {
     StartAt = options.StartAt;
     CurrentValue = StartAt;
     Increment = options.Increment;
     MaxValue = options.MaxValue;
     MinValue = options.MinValue;
     Cycle = options.Cycle;
 }
Пример #9
0
 public SequenceTableEntity(SequenceOptions options) : this()
 {
     StartAt      = options.StartAt;
     CurrentValue = StartAt;
     Increment    = options.Increment;
     MaxValue     = options.MaxValue;
     MinValue     = options.MinValue;
     Cycle        = options.Cycle;
 }
Пример #10
0
 public BasePhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = BasePhoneNumbers.WordBoundariesRegex;
     NonWordBoundariesRegex = BasePhoneNumbers.NonWordBoundariesRegex;
     EndWordBoundariesRegex = BasePhoneNumbers.EndWordBoundariesRegex;
     ColonPrefixCheckRegex  = new Regex(BasePhoneNumbers.ColonPrefixCheckRegex);
     ColonMarkers           = (List <char>)BasePhoneNumbers.ColonMarkers;
     ForbiddenPrefixMarkers = (List <char>)BasePhoneNumbers.ForbiddenPrefixMarkers;
     ForbiddenSuffixMarkers = (List <char>)BasePhoneNumbers.ForbiddenSuffixMarkers;
 }
 public BasePhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = BasePhoneNumbers.WordBoundariesRegex;
     NonWordBoundariesRegex = BasePhoneNumbers.NonWordBoundariesRegex;
     EndWordBoundariesRegex = BasePhoneNumbers.EndWordBoundariesRegex;
     ColonPrefixCheckRegex  = new Regex(BasePhoneNumbers.ColonPrefixCheckRegex);
     ColonMarkers           = (List <char>)BasePhoneNumbers.ColonMarkers;
     ForbiddenPrefixMarkers = (List <char>)BasePhoneNumbers.ForbiddenPrefixMarkers;
     ForbiddenSuffixMarkers = (List <char>)BasePhoneNumbers.ForbiddenSuffixMarkers;
     AmbiguityFiltersDict   = AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(BasePhoneNumbers.AmbiguityFiltersDict);
 }
Пример #12
0
        public void Parse_sequence_verb_with_multi_instance_returns_verb_instance()
        {
            var expected = new SequenceOptions {
                LongSequence = new long[] { }, StringSequence = new[] { "s1", "s2" }
            };
            var result = InvokeChoose(
                new[] { typeof(Add_Verb), typeof(Commit_Verb), typeof(Clone_Verb), typeof(SequenceOptions) },
                new[] { "sequence", "-s", "s1", "-s", "s2" },
                true);

            Assert.IsType <SequenceOptions>(((Parsed <object>)result).Value);
            expected.Should().BeEquivalentTo(((Parsed <object>)result).Value);
        }
 public EnglishQuotedTextExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     QuotedTextRegex1 = new Regex(QuotedTextDefinitions.QuotedTextRegex1, RegexOptions.Compiled);
     QuotedTextRegex2 = new Regex(QuotedTextDefinitions.QuotedTextRegex2, RegexOptions.Compiled);
     QuotedTextRegex3 = new Regex(QuotedTextDefinitions.QuotedTextRegex3, RegexOptions.Compiled);
     QuotedTextRegex4 = new Regex(QuotedTextDefinitions.QuotedTextRegex4, RegexOptions.Compiled);
     QuotedTextRegex5 = new Regex(QuotedTextDefinitions.QuotedTextRegex5, RegexOptions.Compiled);
     QuotedTextRegex6 = new Regex(QuotedTextDefinitions.QuotedTextRegex6, RegexOptions.Compiled);
     QuotedTextRegex7 = new Regex(QuotedTextDefinitions.QuotedTextRegex7, RegexOptions.Compiled);
     QuotedTextRegex8 = new Regex(QuotedTextDefinitions.QuotedTextRegex8, RegexOptions.Compiled);
     QuotedTextRegex9 = new Regex(QuotedTextDefinitions.QuotedTextRegex9, RegexOptions.Compiled);
 }
Пример #14
0
        private static async Task <ISequence> CreateSequence(IStateProvider stateProvider, int increment = 1, int startAt = 0, long maxValue = long.MaxValue,
                                                             long minValue = long.MinValue, bool cycle = false)
        {
            var options = new SequenceOptions {
                Increment = increment,
                StartAt   = startAt,
                MaxValue  = maxValue,
                Cycle     = cycle,
                MinValue  = minValue
            };
            var sequence = await stateProvider.NewAsync(options);

            return(sequence);
        }
Пример #15
0
        private static async Task<ISequence> CreateSequence(IStateProvider stateProvider, int increment = 1, int startAt = 0, long maxValue = long.MaxValue,
            long minValue = long.MinValue,bool cycle = false )
        {
            var options = new SequenceOptions { 
                    Increment = increment,
                   StartAt = startAt,
                 MaxValue = maxValue,
                   Cycle = cycle,
                    MinValue = minValue
            };

            var sequence = await stateProvider.NewAsync(options);

            return sequence;
        }
Пример #16
0
        protected override void Initialize()
        {
            var displayAttr = attributes.GetAttribute <DisplayAttribute>();

            _options = new SequenceOptions(displayAttr != null ? displayAttr.SeqOpt : Seq.None);

            if (_options.Readonly)
            {
                displayText += " (Readonly)";
            }

            _advancedKey          = RuntimeHelper.CombineHashCodes(id, "advanced");
            _perItemDrawing       = attributes.AnyIs <PerItemAttribute>();
            _shouldDrawAddingArea = !_options.Readonly && _elementType.IsA <UnityObject>();
        }
Пример #17
0
        public void Parse_sequence_verb_returns_verb_instance()
        {
            // Fixture setup
            var expected = new SequenceOptions {
                LongSequence = new long[] { }, StringSequence = new[] { "aa", "b" }
            };

            // Exercize system
            var result = InvokeChoose(
                new[] { typeof(Add_Verb), typeof(Commit_Verb), typeof(Clone_Verb), typeof(SequenceOptions) },
                new[] { "sequence", "-s", "aa", "b" });

            // Verify outcome
            Assert.IsType <SequenceOptions>(((Parsed <object>)result).Value);
            expected.Should().BeEquivalentTo(((Parsed <object>)result).Value);
            // Teardown
        }
Пример #18
0
        public void Parse_sequence_verb_with_separator_returns_verb_instance(string[] arguments, string[] expectedString)
        {
            // Fixture setup
            var expected = new SequenceOptions {
                LongSequence = new long[] { }, StringSequence = expectedString
            };

            // Exercize system
            var result = InvokeChoose(
                new[] { typeof(Add_Verb), typeof(Commit_Verb), typeof(Clone_Verb), typeof(SequenceOptions) },
                arguments);

            // Verify outcome
            Assert.IsType <SequenceOptions>(((Parsed <object>)result).Value);
            expected.Should().BeEquivalentTo(((Parsed <object>)result).Value);
            // Teardown
        }
Пример #19
0
        public void Parse_sequence_verb_with_separator_returns_verb_instance(string[] arguments, string[] expectedString)
        {
            // Fixture setup
            var expected = new SequenceOptions {
                LongSequence = new long[] { }, StringSequence = expectedString
            };

            // Exercize system
            var result = InstanceChooser.Choose(
                new[] { typeof(AddOptions), typeof(CommitOptions), typeof(CloneOptions), typeof(SequenceOptions) },
                arguments,
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture);

            // Verify outcome
            Assert.IsType <SequenceOptions>(result.Value);
            expected.ShouldBeEquivalentTo(result.Value);
            // Teardown
        }
Пример #20
0
        protected override void Initialize()
        {
            var displayAttr = attributes.GetAttribute <DisplayAttribute>();

            _options = new SequenceOptions(displayAttr != null ? displayAttr.SeqOpt : Seq.None);

            if (_options.Readonly)
            {
                displayText += " (Readonly)";
            }

            _advancedKey          = RuntimeHelper.CombineHashCodes(id, "advanced");
            _shouldDrawAddingArea = !_options.Readonly && _elementType.IsA <UnityObject>();

            var perItem = attributes.GetAttribute <PerItemAttribute>();

            if (perItem != null)
            {
                if (perItem.ExplicitAttributes == null)
                {
                    _perItemAttributes = attributes.Where(x => !(x is PerItemAttribute)).ToArray();
                }
                else
                {
                    _perItemAttributes = attributes.Where(x => perItem.ExplicitAttributes.Contains(x.GetType().Name.Replace("Attribute", ""))).ToArray();
                }
            }

            if (_options.Filter)
            {
                _filter = new TextFilter(null, id, true, null);
            }

            _originalDisplay = displayText;

            if (memberValue == null)
            {
                memberValue = GetNew();
            }

            member.CollectionCount = memberValue.Count;
        }
Пример #21
0
        public void Parse_sequence_verb_returns_verb_instance()
        {
            // Fixture setup
            var expected = new SequenceOptions {
                LongSequence = new long[] { }, StringSequence = new[] { "aa", "b" }
            };

            // Exercize system
            var result = InstanceChooser.Choose(
                new[] { typeof(Add_Verb), typeof(Commit_Verb), typeof(Clone_Verb), typeof(SequenceOptions) },
                new[] { "sequence", "-s", "aa", "b" },
                StringComparer.Ordinal,
                CultureInfo.InvariantCulture,
                Enumerable.Empty <ErrorType>());

            // Verify outcome
            Assert.IsType <SequenceOptions>(((Parsed <object>)result).Value);
            expected.ShouldBeEquivalentTo(((Parsed <object>)result).Value);
            // Teardown
        }
Пример #22
0
 public ChineseIpExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     Ipv4Regex = RegexCache.Get(IpDefinitions.Ipv4Regex, RegexOptions.Compiled);
     Ipv6Regex = RegexCache.Get(IpDefinitions.Ipv6Regex, RegexOptions.Compiled);
 }
 public EnglishURLExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     IpUrlRegex = new Regex(BaseURL.IpUrlRegex, RegexOptions.Compiled);
     UrlRegex   = new Regex(BaseURL.UrlRegex, RegexOptions.Compiled);
 }
 public PhoneNumberConfiguration(SequenceOptions options = SequenceOptions.None)
 {
     Options = options;
 }
Пример #25
0
 public SpanishPhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     FalsePositivePrefixRegex = null;
 }
Пример #26
0
 public EnglishPhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     FalsePositivePrefixRegex = new Regex(PhoneNumbersDefinitions.FalsePositivePrefixRegex);
 }
Пример #27
0
 public URLConfiguration(SequenceOptions options = SequenceOptions.None)
 {
     Options = options;
 }
Пример #28
0
 private SequenceRecognizer(SequenceOptions options)
 {
     RegisterModel(Culture.English, options.ToString(), new Dictionary <Type, IModel>
     {
     });
 }
 public ChineseURLExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     UrlRegex   = RegexCache.Get(URLDefinitions.UrlRegex, RegexOptions.Compiled);
     IpUrlRegex = RegexCache.Get(URLDefinitions.IpUrlRegex, RegexOptions.Compiled);
 }
Пример #30
0
 public async Task <ISequence> NewAsync(SequenceOptions options)
 {
     return(await Task.FromResult(new SqlServerSequence(options)));
 }
Пример #31
0
 public async Task<ISequence> NewAsync(SequenceOptions options)
 {
     return await Task.FromResult(new Sequence(options));
 }
 public BaseSequenceConfiguration(SequenceOptions options = SequenceOptions.None)
 {
     Options = options;
 }
Пример #33
0
        public async Task <ISequence> NewAsync(SequenceOptions options)
        {
            var sequence = new SequenceTableEntity(options);

            return(await Task.FromResult(sequence));
        }