public ValueContainer Evaluate(IValueEnvironment env)
        {
            //TODO: Make it so no casting is needed
            DictionaryKeyValueObserver<string, ValueContainer> repeatVariables = ((Environment.ValueEnvironment)env).GetRange(Name);
            ValueContainer value = new ValueContainer(0);

            Action onValueChanged = () =>
            {
                int count = 0;
                double sum = 0;

                foreach (ValueContainer item in repeatVariables.Where(v => !v.Inactive))
                {
                    count++;
                    sum += Convert.ToDouble(item.Value);
                }

                value.Value = count > 0 ? sum / count : 0;
            };

            Action onCollectionChange = () =>
            {
                foreach (ValueContainer item in repeatVariables)
                {
                    item.ValueChanged += onValueChanged;
                }

                onValueChanged();
            };
            repeatVariables.FilterResultChanged += onCollectionChange;
            onCollectionChange();

            return value;
        }
        public FrameworkElement BuildElement(ValueContainer value, bool editable)
        {
            FrameworkElement elem = BuildElement(value);
            elem.IsEnabled = editable;

            elem.IsVisibleChanged += (s, e) =>
            {
                value.Inactive = !elem.IsVisible;
            };

            return elem;
        }
        protected override FrameworkElement BuildElement(ValueContainer value)
        {
            TextBox tb = new TextBox() { Width = 200 };
            tb.TextChanged += (s, e) =>
            {
                value.Value = tb.Text;
            };

            Action onValueChanged = () =>
            {
                tb.Text = Convert.ToString(value.Value);
            };
            value.ValueChanged += onValueChanged;
            onValueChanged();

            return tb;
        }
        protected override FrameworkElement BuildElement(ValueContainer value)
        {
            IntegerUpDown iud = new IntegerUpDown() { Width = 200 };
            iud.ValueChanged += (s, e) =>
            {
                value.Value = iud.Value;
            };

            Action onValueChanged = () =>
            {
                iud.Value = Convert.ToInt32(value.Value);
            };
            value.ValueChanged += onValueChanged;
            onValueChanged();

            return iud;
        }
        protected override FrameworkElement BuildElement(ValueContainer value)
        {
            DoubleUpDown dud = new DoubleUpDown() { Width = 200, Increment = 0.1 };
            dud.ValueChanged += (s, e) =>
            {
                value.Value = dud.Value;
            };

            Action onValueChanged = () =>
            {
                dud.Value = Convert.ToDouble(value.Value);
            };
            value.ValueChanged += onValueChanged;
            onValueChanged();

            return dud;
        }
        protected override FrameworkElement BuildElement(ValueContainer value)
        {
            DatePicker dp = new DatePicker() { Width = 200 };
            dp.SelectedDateChanged += (s, e) =>
            {
                value.Value = dp.SelectedDate;
            };

            Action onValueChanged = () =>
            {
                dp.SelectedDate = Convert.ToDateTime(value.Value);
            };
            value.ValueChanged += onValueChanged;
            onValueChanged();

            return dp;
        }
        protected override FrameworkElement BuildElement(ValueContainer value)
        {
            CheckBox cb = new CheckBox();
            cb.Checked += (s, e) =>
            {
                value.Value = true;
            };
            cb.Unchecked += (s, e) =>
            {
                value.Value = false;
            };

            Action onValueChanged = () =>
            {
                cb.IsChecked = Convert.ToBoolean(value.Value);
            };
            value.ValueChanged += onValueChanged;
            onValueChanged();

            return cb;
        }
 protected override object Evaluate(ValueContainer expr1Value, ValueContainer expr2Value)
 {
     return Math.Pow(Convert.ToDouble(expr1Value.Value), Convert.ToDouble(expr2Value.Value));
 }
 protected override object Evaluate(ValueContainer expr1Value, ValueContainer expr2Value)
 {
     return Convert.ToDouble(expr1Value.Value) % Convert.ToDouble(expr2Value.Value);
 }
 protected override object Evaluate(ValueContainer expr1Value, ValueContainer expr2Value)
 {
     return expr1Value.Value.Equals(expr2Value.Value);
 }
 protected virtual FrameworkElement BuildElement(ValueContainer value)
 {
     return null;
 }
 protected override object Evaluate(ValueContainer expr1Value, ValueContainer expr2Value)
 {
     return Convert.ToBoolean(expr1Value.Value) || Convert.ToBoolean(expr2Value.Value);
 }