예제 #1
0
        public void Remove(IPsbPlugin plugin)
        {
            if (plugin is IPsbImageFormatter f)
            {
                f.Extensions.ForEach(ext => ImageFormatters.Remove(ext));
            }

            if (plugin is IPsbAudioFormatter a)
            {
                a.Extensions.ForEach(ext => AudioFormatters.Remove(ext));
            }

            if (plugin is IPsbShell s)
            {
                Shells.Remove(s.Name);
            }

            if (plugin is IPsbSpecialType t)
            {
                SpecialTypes.Remove(t.TypeId);
            }

            if (plugin is IPsbKeyProvider)
            {
                _keyProvider = null;
            }

            _plugins.Remove(plugin);
        }
예제 #2
0
        public void Remove(IPsbPlugin plugin)
        {
            if (plugin is IPsbImageFormatter f)
            {
                f.Extensions.ForEach(ext => ImageFormatters.Remove(ext));
            }
            if (plugin is IPsbShell s)
            {
                Shells.Remove(s.Name);
            }

            if (plugin is IPsbKeyProvider)
            {
                _keyProvider = null;
            }
            _plugins.Remove(plugin);
        }
예제 #3
0
        /// <summary>
        /// Populates the current <see cref="ShellConfiguration"/> instance.
        /// </summary>
        public void Populate()
        {
            int left = Element.Electrons;

            for (var i = 0; i < ChemistryUtils.EnergyLevelConfiguration.Count; i++)
            {
                if (left == 0)
                {
                    break;
                }

                KeyValuePair <char, char[]> pair = ChemistryUtils.EnergyLevelConfiguration.ToList()[i];
                Shell shell = this[pair.Key];

                for (int x = 0; x < pair.Value.Length; x++)
                {
                    if (left == 0)
                    {
                        break;
                    }

                    Subshell subshell = shell[pair.Value[x]];

                    if (subshell.Electrons > 0)
                    {
                        continue;
                    }

                    if (left - subshell.Capacity < 0)
                    {
                        subshell.Populate(left);
                        left = 0;
                    }
                    else
                    {
                        subshell.Populate(subshell.Capacity);
                        left -= subshell.Capacity;
                    }

                    int stepsDown = x;
                    for (int z = 0; z < stepsDown; z++)
                    {
                        if (left == 0)
                        {
                            break;
                        }

                        Subshell diagonal = Shells.ToList()[i + z + 1].Subshells[x - (z + 1)];
                        if (left - diagonal.Capacity < 0)
                        {
                            diagonal.Populate(left);
                            left = 0;
                        }
                        else
                        {
                            diagonal.Populate(diagonal.Capacity);
                            left -= diagonal.Capacity;
                        }
                    }
                }
            }

            foreach (var shell in Shells.ToArray())
            {
                foreach (var subshell in shell.Subshells.ToArray())
                {
                    if (subshell.Electrons == 0)
                    {
                        shell.Subshells.Remove(subshell);
                    }
                }

                if (shell.Electrons == 0)
                {
                    Shells.Remove(shell);
                }
            }
        }