Exemplo n.º 1
0
        public bool Extract(Rule rule)
        {
            if (!JsRulesHandled.Contains(rule.Property))
            {
                return(false);
            }

            if (!AutoValues.TryGetValue(Name, out var value))
            {
                value = new AutoValue
                {
                    Name = Name,
                };
                AutoValues.Add(Name, value);
            }

            switch (rule.Property)
            {
            case "ZIndex":
                value.ZIndex = rule.InvariantScript;
                break;

            default:
                throw new Exception($"Rule Property {rule.Property} not defined for AutoValueExtractor.Extract");
            }

            rule.InvariantScript = "AutoValue";
            return(true);
        }
Exemplo n.º 2
0
        public void Inject(Rule rule, string controlPath)
        {
            if (!JsRulesHandled.Contains(rule.Property))
            {
                return;
            }

            var name = string.Join(Environment.NewLine, Path.GetRelativePath(RootCodePath, Path.GetDirectoryName(controlPath)).Split(new[] { Path.DirectorySeparatorChar }));

            if (!AutoValues.TryGetValue(name, out var value))
            {
                throw  new KeyNotFoundException($"Unable to find auto value for rule {rule.Property} at {controlPath}");
            }

            switch (rule.Property)
            {
            case "ZIndex":
                rule.InvariantScript = value.ZIndex;
                break;

            default:
                throw new Exception($"Rule Property {rule.Property} not defined for AutoValueExtractor.Inject");
            }
        }