public IElementMultiplicity Element(string name, Action action)
            {
                var matcher = new Matcher <string>(_Parent, name, XmlNodeType.Element, pc => pc.Token.Name.ToMaybe(), x => action());

                Matchers.Add(matcher);

                return(matcher);
            }
            public IAttributeMultiplicity Attribute <T>(string name, Action <T> action)
            {
                var matcher = new Matcher <T>(_Parent, name, XmlNodeType.Attribute, pc => new Maybe <T>(Convert <string, T> .From(pc.Token.Value)), action);

                Matchers.Add(matcher);

                return(matcher);
            }
Beispiel #3
0
 public BodyMatcher(List <Gesture> gestureList, int precision = 15)
 {
     this.App       = null;
     this.Precision = precision;
     foreach (var gesture in gestureList)
     {
         var matcher = new GestureMatcher(gesture);
         Matchers.Add(matcher);
     }
 }
Beispiel #4
0
 public BodyMatcher(App app, int precision = 15)
 {
     this.App       = app;
     this.Precision = precision;
     foreach (var gesture in this.App.Gestures)
     {
         var matcher = new GestureMatcher(gesture);
         Matchers.Add(matcher);
     }
 }
            public IElementOptions ContentElement <T>(string name, Action <T> action)
            {
                Func <ParseContext, Maybe <T> > converter = pc =>
                {
                    var token = pc.Token;

                    if (pc.Token.IsEmptyElement)
                    {
                        pc.Panic();

                        string message = string.Format("Content element '{0}' must contain text.", name);
                        pc.Errors.Add(new ParseError(message, token));

                        return(Maybe <T> .NoValue);
                    }

                    pc.MoveNext();

                    if (pc.Token.Kind != XmlNodeType.Text)
                    {
                        pc.Panic();

                        string message = string.Format("Content element '{0}' must only contain text.", name);
                        pc.Errors.Add(new ParseError(message, token));

                        return(Maybe <T> .NoValue);
                    }

                    var data = Convert <string, T> .From(pc.Token.Value);

                    pc.MoveNext();

                    if (pc.Token.Kind != XmlNodeType.EndElement)
                    {
                        pc.Panic();

                        string message = string.Format("Content element '{0}' must only contain text.", name);
                        pc.Errors.Add(new ParseError(message, token));

                        return(Maybe <T> .NoValue);
                    }

                    return(new Maybe <T>(data));
                };

                var matcher = new Matcher <T>(_Parent, name, XmlNodeType.Element, converter, action);

                Matchers.Add(matcher);

                return(matcher);
            }
Beispiel #6
0
        public void GetMatchers()
        {
            switch (Element)
            {
            case MarbleType.Air:
                Matchers.Add(MarbleType.Air);
                Matchers.Add(MarbleType.Salt);
                break;

            case MarbleType.Water:
                Matchers.Add(MarbleType.Water);
                Matchers.Add(MarbleType.Salt);
                break;

            case MarbleType.Earth:
                Matchers.Add(MarbleType.Earth);
                Matchers.Add(MarbleType.Salt);
                break;

            case MarbleType.Fire:
                Matchers.Add(MarbleType.Fire);
                Matchers.Add(MarbleType.Salt);
                break;

            case MarbleType.Salt:
                Matchers.Add(MarbleType.Air);
                Matchers.Add(MarbleType.Water);
                Matchers.Add(MarbleType.Earth);
                Matchers.Add(MarbleType.Fire);
                Matchers.Add(MarbleType.Salt);
                break;

            case MarbleType.Vitae:
                Matchers.Add(MarbleType.Mors);
                break;

            case MarbleType.Mors:
                Matchers.Add(MarbleType.Vitae);
                break;

            case MarbleType.Quicksilver:
                Matchers.Add(MarbleType.Lead);
                Matchers.Add(MarbleType.Tin);
                Matchers.Add(MarbleType.Iron);
                Matchers.Add(MarbleType.Copper);
                Matchers.Add(MarbleType.Silver);
                Matchers.Add(MarbleType.Gold);
                break;

            case MarbleType.Lead:
                Matchers.Add(MarbleType.Quicksilver);
                break;

            case MarbleType.Tin:
                Matchers.Add(MarbleType.Quicksilver);
                break;

            case MarbleType.Iron:
                Matchers.Add(MarbleType.Quicksilver);
                break;

            case MarbleType.Copper:
                Matchers.Add(MarbleType.Quicksilver);
                break;

            case MarbleType.Silver:
                Matchers.Add(MarbleType.Quicksilver);
                break;

            case MarbleType.Gold:
                break;
            }
        }
Beispiel #7
0
        public void AddGesture(Gesture gesture)
        {
            var matcher = new GestureMatcher(gesture);

            Matchers.Add(matcher);
        }