예제 #1
0
        public static MailAddressCollection GetAddresses(Field field)
        {
            IPattern addrSpecPattern =
                PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.AddrSpecPattern));
            MailAddressCollection addresses = null;

            if (addrSpecPattern.RegularExpression.IsMatch(field.Body))
            {
                //TODO: Make supprt for multiple addresses with names
                addresses = new MailAddressCollection();
                try
                {
                    MailAddress address = new MailAddress(field.Body);
                    addresses.Add(address);
                }
                catch (FormatException)
                {
                    MatchCollection matches = addrSpecPattern.RegularExpression.Matches(field.Body);
                    foreach (Match match in matches)
                    {
                        addresses.Add(match.Value);
                    }
                }
            }
            return(addresses);
        }
예제 #2
0
        public PhrasePattern()
        {
            IPattern wordPattern = PatternFactory.GetInstance().Get(typeof(WordPattern));

            m_TextPattern = wordPattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #3
0
 public PatternClient(GameObject item, Vector3 theStart, Vector3 theEnd)
 {
     start      = theStart;
     end        = theEnd;
     ptrn       = PatternFactory.getPattern(item);
     gameObject = MonoBehaviour.Instantiate(ptrn.GetPattern(), start, ptrn.GetPattern().transform.rotation);
 }
예제 #4
0
파일: Element.cs 프로젝트: csuffyy/FlaUI
 /// <summary>
 /// Constructor for a basic ui element
 /// </summary>
 /// <param name="automation">The automation instance where this element belongs to</param>
 /// <param name="nativeElement">The native element this instance wrapps</param>
 public Element(UIA3Automation automation, UIA.IUIAutomationElement nativeElement) : base(automation)
 {
     NativeElement  = nativeElement;
     PatternFactory = new PatternFactory(this);
     Cached         = new ElementInformation(this, true);
     Current        = new ElementInformation(this, false);
 }
예제 #5
0
        public DatePattern()
        {
            IPattern monthPattern = PatternFactory.GetInstance().Get(typeof(MonthPattern));

            m_TextPattern = "([0-9]{2,2}\x5C\x73" + monthPattern.TextPattern + "\x5C\x73[0-9]{2,4}){1,1}";
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #6
0
        public void IsFull()
        {
            var context        = new BoardProperties(4, 4, 5);
            var positions      = new PositionFactory().Create(context);
            var patterns       = new PatternFactory().Create();
            var matcher        = new PatternMatcher(patterns);
            var boardFactories = new IBoardFactory[]
            {
                new BoardFactory(context, positions),
                new PatternBoardFactory(context, positions, matcher)
            };

            foreach (var boardFactory in boardFactories)
            {
                IGame game = new GameFactory().CreateGame(
                    boardFactory,
                    new NextAvailablePlayer(positions),
                    new NextAvailablePlayer(positions),
                    new BasicJudge(context, positions)
                    );

                game.Start();

                foreach (var i in Enumerable.Range(0, context.RowSize * context.ColSize))
                {
                    Assert.AreEqual(game.GameStatus, GameStatus.NotEnd);
                    game.Run();
                }

                Assert.AreEqual(game.GameStatus, GameStatus.Tie);
                Assert.IsTrue(game.Board.IsFull());
            }
        }
예제 #7
0
        public CreationDateParmPattern()
        {
            IPattern quotedDatetimePattern = PatternFactory.GetInstance().Get(typeof(QuotedDateTimePattern));

            m_TextPattern = "creation-date=" + quotedDatetimePattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #8
0
 public CommandReader(string commands, Random random)
 {
     _animationFactory = new AnimationFactory(TypeSource <IAnimation> .FromThisAssembly());
     _patternFactory   = new PatternFactory(TypeSource <IPattern> .FromThisAssembly());
     _timingFactory    = new TimingFactory(TypeSource <ITiming> .FromThisAssembly());
     _commands         = commands;
 }
예제 #9
0
        public DomainPattern()
        {
            IPattern subDomainPattern = PatternFactory.GetInstance().Get(typeof(SubDomainPattern));

            m_TextPattern = "(" + subDomainPattern.TextPattern + "(?:\x5C\x2E" + subDomainPattern.TextPattern + ")*)";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #10
0
        public MIMEVersionPattern()
        {
            IPattern commentPattern = PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.CommentPattern));

            m_TextPattern = "(?i)MIME-Version:(?-i)([0-9]{1,1}|\\x2E{1,1}|" + commentPattern.TextPattern + ")*";
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #11
0
        public override void Initialize()
        {
            base.Initialize();
            _ruleChooser = new MajorityInOrderRuleChooser();

            CAPattern pattern;
            Point     insertPoint;

            pattern     = PatternFactory.GetPieceGridFromPatternFile("RuleFiles/PersianRugs.rle");
            insertPoint = new Point(5, 5);
            InsertPattern(pattern, insertPoint, 5);

            pattern     = PatternFactory.GetPieceGridFromPatternFile("RuleFiles/SpiralGrowth.rle");
            insertPoint = new Point(85, 45);
            InsertPattern(pattern, insertPoint, 4);

            pattern     = PatternFactory.GetPieceGridFromPatternFile("RuleFiles/JustFriendsBox50.rle");
            insertPoint = new Point(25, 25);
            InsertPattern(pattern, insertPoint, 0);

            pattern     = PatternFactory.GetPieceGridFromPatternFile("RuleFiles/GliderGunNE.rle");
            insertPoint = new Point(48, 31);
            InsertPattern(pattern, insertPoint, 1);

            pattern     = PatternFactory.GetPieceGridFromPatternFile("RuleFiles/SeedsSmall.rle");
            insertPoint = new Point(2, 2);
            InsertPattern(pattern, insertPoint, 3);
        }
예제 #12
0
        public ContentTransferEncodingPattern()
        {
            IPattern mechanismPattern = PatternFactory.GetInstance().Get(typeof(MechanismPattern));

            m_TextPattern = "(?i)Content-Transfer-Encoding(?i):[ ]*" + mechanismPattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #13
0
        public CharsetPattern()
        {
            IPattern tokenPattern = PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.TokenPattern));

            m_TextPattern = "(?<==\x5C?)" + tokenPattern.TextPattern + "(?=\x5C?)";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #14
0
        public DispositionTypePattern()
        {
            IPattern xtokenPattern = PatternFactory.GetInstance().Get(typeof(XTokenPattern));

            m_TextPattern = "(?i)(inline|Attachment|" + xtokenPattern.TextPattern + ")(?i)";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #15
0
        public XTokenPattern()
        {
            IPattern tokenPattern = PatternFactory.GetInstance().Get(typeof(MIMER.RFC822.Pattern.TokenPattern));

            m_TextPattern = "(X-|x-)" + tokenPattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #16
0
파일: ComboBox.cs 프로젝트: windygu/FlaUI
 public void Collapse()
 {
     if (!Current.IsEnabled || ExpandCollapseState != ExpandCollapseState.Expanded)
     {
         return;
     }
     if (FrameworkType == FrameworkType.WinForms)
     {
         // WinForms
         var openButton = FindFirstChild(ConditionFactory.ByControlType(ControlType.Button)).AsButton();
         if (IsEditable)
         {
             // WinForms editable combo box only closes on click and not on invoke
             openButton.Click();
         }
         else
         {
             openButton.Invoke();
         }
     }
     else
     {
         // WPF
         var ecp = PatternFactory.GetExpandCollapsePattern();
         ecp?.Collapse();
     }
     Helpers.WaitUntilResponsive(this);
 }
예제 #17
0
        public MailReader()
        {
            m_FieldParser = new FieldParser();
            m_FieldParser.CompilePattern();

            m_UnfoldPattern = PatternFactory.GetInstance().Get(typeof(Pattern.UnfoldPattern));
        }
예제 #18
0
        public QuotedDateTimePattern()
        {
            IPattern datetimePattern = PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.DateTimePattern));

            m_TextPattern = "\"" + datetimePattern.TextPattern + "\"";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #19
0
 public FieldParser()
 {
     m_UnfoldPattern     = PatternFactory.GetInstance().Get(typeof(UnfoldPattern));
     m_FieldPattern      = PatternFactory.GetInstance().Get(typeof(FieldPattern));
     m_HeaderNamePattern = PatternFactory.GetInstance().Get(typeof(FieldNamePattern));
     m_HeaderBodyPattern = PatternFactory.GetInstance().Get(typeof(FieldBodyPattern));
     m_DataReader        = new DataReader();
 }
예제 #20
0
        public LocalPartPattern()
        {
            IPattern wordPattern = PatternFactory.GetInstance().Get(typeof(WordPattern));

            m_TextPattern = "(" + wordPattern.TextPattern + "(?:\x5C\x2E" +
                            wordPattern.TextPattern + ")*)";
            m_Regex = new Regex(m_TextPattern);
        }
예제 #21
0
        public SubDomainPattern()
        {
            IPattern domainRefPattern     = PatternFactory.GetInstance().Get(typeof(DomainRefPattern));
            IPattern domainLiteralPattern = PatternFactory.GetInstance().Get(typeof(DomainLiteralPattern));

            m_TextPattern = "(?:(" + domainRefPattern.TextPattern + "|" + domainLiteralPattern.TextPattern + "))";
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #22
0
        public MechanismPattern()
        {
            IPattern xtokenPattern = PatternFactory.GetInstance().Get(typeof(XTokenPattern));

            m_TextPattern = "(?i)(7bit|8bit|binary|quoted-printable|base64|" +
                            xtokenPattern.TextPattern + ")(?i)"; //or ief-token
            m_Regex = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #23
0
        public void Creates_List_Of_Winning_Patterns_Based_On_Board_Size(int size, IEnumerable <string> expected)
        {
            var factory = new PatternFactory();

            var patterns = factory.Create(size);

            patterns.Should().BeEquivalentTo(expected);
        }
예제 #24
0
        public TimePattern()
        {
            IPattern hourPattern = PatternFactory.GetInstance().Get(typeof(HourPattern));
            IPattern zonePattern = PatternFactory.GetInstance().Get(typeof(ZonePattern));

            m_TextPattern = hourPattern.TextPattern + zonePattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #25
0
        public WordPattern()
        {
            IPattern atomPattern         = PatternFactory.GetInstance().Get(typeof(AtomPattern));
            IPattern quotedStringPattern = PatternFactory.GetInstance().Get(typeof(QuotedStringPattern));

            m_TextPattern = "(" + atomPattern.TextPattern + "|" + quotedStringPattern.TextPattern + ")";
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #26
0
        public AddrSpecPattern()
        {
            IPattern localPartPattern = PatternFactory.GetInstance().Get(typeof(LocalPartPattern));
            IPattern domainPattern    = PatternFactory.GetInstance().Get(typeof(DomainPattern));

            m_TextPattern = "(" + localPartPattern.TextPattern + "@" + domainPattern.TextPattern + ")";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled);
        }
예제 #27
0
        public TypePattern()
        {
            IPattern descritePattern  = PatternFactory.GetInstance().Get(typeof(DiscreteTypePattern));
            IPattern compositePattern = PatternFactory.GetInstance().Get(typeof(CompositeTypePattern));

            m_TextPattern = "(" + descritePattern.TextPattern + "|" + compositePattern.TextPattern + ")";
            m_Regex       = new Regex(m_TextPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
        }
        private static IJudge GetJudge()
        {
            var context     = new BoardProperties();
            var positions   = new PositionFactory().Create(context);
            var patternRepo = new PatternFactory().Create();

            return(new PatternJudge(positions, patternRepo, new PatternMatcher(patternRepo)));
        }
예제 #29
0
        public void Test_against_DataSet(TriStateMatrix input, MaskPatternType patternType, BitMatrix expected)
        {
            Pattern pattern = new PatternFactory().CreateByType(patternType);

            BitMatrix result = input.Apply(pattern, ErrorCorrectionLevel.H);

            expected.AssertEquals(result);
        }
예제 #30
0
        public ParameterPattern()
        {
            IPattern tokenPattern = PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.TokenPattern));
            IPattern valuePattern = PatternFactory.GetInstance().Get(typeof(ValuePattern));

            m_TextPattern = tokenPattern.TextPattern + "=" + valuePattern.TextPattern;
            m_Regex       = new Regex(m_TextPattern);
        }
예제 #31
0
        public void Before()
        {
            var networkFactory = new NetworkFactory();
            var patternFactory = new PatternFactory();
            var resultFactory = new ResultWeightFactory();

            snapNetworkTask = networkFactory.CreateFrom("network.json");
            patternsTask = patternFactory.CreateFrom("patterns.json");
        }
예제 #32
0
 internal static BitMatrix GetLowestPenaltyMatrix(this TriStateMatrix matrix, ErrorCorrectionLevel errorlevel)
 {
     PatternFactory patternFactory = new PatternFactory();
     int score = int.MaxValue;
     int tempScore;
     TriStateMatrix result = new TriStateMatrix(matrix.Width);
     TriStateMatrix triMatrix;
     foreach(Pattern pattern in patternFactory.AllPatterns())
     {
     	triMatrix = matrix.Apply(pattern, errorlevel);
     	tempScore = triMatrix.PenaltyScore();
     	if(tempScore < score)
     	{
     		score = tempScore;
     		result = triMatrix;
     	}
     }
     
     return result;
 }