コード例 #1
0
        /// <summary>
        /// Initializes an instance of the <see cref="ShellConfiguration"/> class.
        /// </summary>
        /// <param name="element">The parent element.</param>
        /// <param name="values">An ordered collection of shells.</param>
        public ShellConfiguration(Element element, int[] values)
        {
            Shells  = new Collection <Shell>();
            Element = element;

            for (var i = 0; i < values.Length; i++)
            {
                int value = values[i];

                if (value > ChemistryUtils.GetShellCapacity(i) || value < 0)
                {
                    throw new IndexOutOfRangeException(nameof(value));
                }

                Shells.Add(new Shell(ChemistryUtils.ShellLabels[i], value));
            }

            Populate();
        }
コード例 #2
0
        /// <summary>
        /// Initializes an instance of the <see cref="ShellConfiguration"/> class.
        /// </summary>
        /// <param name="element">The parent element.</param>
        /// <param name="values">An ordered dictionary of shells.</param>
        public ShellConfiguration(Element element, Dictionary <char, int> values)
        {
            Shells  = new Collection <Shell>();
            Element = element;

            for (var i = 0; i < values.Count; i++)
            {
                int capacity = ChemistryUtils.GetShellCapacity(i);
                KeyValuePair <char, int> current = values.ToList()[i];

                if (current.Value > capacity || current.Value < 0)
                {
                    throw new IndexOutOfRangeException(nameof(current.Value));
                }

                Shells.Add(new Shell(current.Key, current.Value));
            }

            Populate();
        }