Пример #1
0
        public static MetricNode TryParse(ConfigNode node)
        {
            if (node != null)
            {
                var name = Metric.TryParse(node.GetValue("name"));
                var enable = node.TryParse<bool>("enable") ?? true;
                var unit = node.TryParse<Unit>("unit");

                if (name != null && unit != null)
                {
                    return new MetricNode(name, enable, unit.Value);
                }
            }

            Log.Warning($"Could not parse config node:{Environment.NewLine}{node}");
            return null;
        }
Пример #2
0
        public static StopNode TryParse(ConfigNode node)
        {
            if (node != null)
            {
                var name = node.GetValue("name");
                var value = Expression.TryParse(node.GetValue("value"));
                var factor = node.TryParse<double>("factor") ?? 1.0;
                var color = TryParseColor(node.GetValue("color"));
                var alpha = node.TryParse<float>("alpha");

                if (name != null && value != null && (color != null || alpha != null))
                {
                    return new StopNode(name, value, factor, color, alpha);
                }
            }

            Log.Warning($"Could not parse config node:{Environment.NewLine}{node}");
            return null;
        }
Пример #3
0
        public static OverlayNode TryParse(ConfigNode node)
        {
            if (node != null)
            {
                var enable = node.TryParse<bool>("enable") ?? true;
                var enableScrenMessage = node.TryParse<bool>("enableScreenMessage") ?? true;
                var metric = Metric.TryParse(node.GetValue("metric"));
                var metrics = node
                    .GetNodes("METRIC")
                    .Where(i => !i.GetValue("name").EndsWith("Template"))
                    .Select(MetricNode.TryParse)
                    .Where(i => i != null)
                    .ToArray();

                if (metric != null)
                {
                    return new OverlayNode(enable, enableScrenMessage, metric, metrics);
                }
            }

            Log.Warning($"Could not parse config node:{Environment.NewLine}{node}");
            return null;
        }
Пример #4
0
        public static GradientNode TryParse(ConfigNode node)
        {
            if (node != null)
            {
                var name = node.GetValue("name");
                var min = Expression.TryParse(node.GetValue("min"));
                var max = Expression.TryParse(node.GetValue("max"));
                var onConflict = node.TryParse<OnConflict>("onConflict") ?? OnConflict.Ignore;
                var stops = node
                    .GetNodes("STOP")
                    .Where(i => !i.GetValue("name").EndsWith("Template"))
                    .Select(StopNode.TryParse)
                    .Where(i => i != null)
                    .ToArray();

                if (name != null && min != null && max != null)
                {
                    return new GradientNode(name, min, max, onConflict, stops);
                }
            }

            Log.Warning($"Could not parse config node:{Environment.NewLine}{node}");
            return null;
        }