<commit_before>﻿using System.Collections.ObjectModel;
using System.Windows;
using Dyna.Core.Models;

namespace DynaApp.ViewModels
{
    public sealed class AggregateVariableViewModel : VariableViewModel
    {
        /// <summary>
        /// Initialize a new aggregate variable with a name and location.
        /// </summary>
        /// <param name="newVariableName">Variable name.</param>
        /// <param name="newVariableLocation">Location.</param>
        public AggregateVariableViewModel(string newVariableName, Point newVariableLocation)
            : base(newVariableName, newVariableLocation)
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel(newVariableName + "1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel(newVariableName, newVariableLocation);
        }

        /// <summary>
        /// Initialize a new aggregate variable with a name and location.
        /// </summary>
        /// <param name="newVariableName">Variable name.</param>
        /// <param name="size">Size of the aggregate.</param>
        /// <param name="domainExpression">Domain expression.</param>
        public AggregateVariableViewModel(string newVariableName, int size, VariableDomainExpressionViewModel domainExpression)
            : base(newVariableName)
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel(newVariableName+"1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel(newVariableName, size, domainExpression.Model);
        }

        /// <summary>
        /// Initialize a new aggregate variable with default values.
        /// </summary>
        public AggregateVariableViewModel()
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel("x" + "1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel();
        }

        /// <summary>
        /// Gets or sets the aggregate variable model.
        /// </summary>
        public new AggregateVariableModel Model { get; private set; }

        /// <summary>
        /// Gets the variables inside the aggregate.
        /// </summary>
        public ObservableCollection<VariableViewModel> Variables { get; private set; }

        /// <summary>
        /// Gets the variable count range expression.
        /// </summary>
        public string Range
        {
            get
            {
                return "1.."+this.Variables.Count;
            }
        }
    }
}<commit_msg>Fixes the AggregateVariableViewModel.Range property to handle having a variable count of zero.<commit_after>﻿using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using Dyna.Core.Models;

namespace DynaApp.ViewModels
{
    public sealed class AggregateVariableViewModel : VariableViewModel
    {
        /// <summary>
        /// Initialize a new aggregate variable with a name and location.
        /// </summary>
        /// <param name="newVariableName">Variable name.</param>
        /// <param name="newVariableLocation">Location.</param>
        public AggregateVariableViewModel(string newVariableName, Point newVariableLocation)
            : base(newVariableName, newVariableLocation)
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel(newVariableName + "1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel(newVariableName, newVariableLocation);
        }

        /// <summary>
        /// Initialize a new aggregate variable with a name and location.
        /// </summary>
        /// <param name="newVariableName">Variable name.</param>
        /// <param name="size">Size of the aggregate.</param>
        /// <param name="domainExpression">Domain expression.</param>
        public AggregateVariableViewModel(string newVariableName, int size, VariableDomainExpressionViewModel domainExpression)
            : base(newVariableName)
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel(newVariableName+"1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel(newVariableName, size, domainExpression.Model);
        }

        /// <summary>
        /// Initialize a new aggregate variable with default values.
        /// </summary>
        public AggregateVariableViewModel()
        {
            this.Variables = new ObservableCollection<VariableViewModel>();
            this.Variables.Add(new VariableViewModel("x" + "1", new VariableDomainExpressionViewModel()));
            this.Model = new AggregateVariableModel();
        }

        /// <summary>
        /// Gets or sets the aggregate variable model.
        /// </summary>
        public new AggregateVariableModel Model { get; private set; }

        /// <summary>
        /// Gets the variables inside the aggregate.
        /// </summary>
        public ObservableCollection<VariableViewModel> Variables { get; private set; }

        /// <summary>
        /// Gets the variable count range expression.
        /// </summary>
        public string Range
        {
            get
            {
                if (this.Variables.Any())
                    return "1.."+this.Variables.Count;
                return "0";
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1058303886925795, 'fraction_numerical': 0.0015901060070671379, 'mean_word_length': 2.32413388138579, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3744513', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1268, 'n_words': 335}