예제 #1
0
        void Read()
        {
            for (int i = 0; i < _file.Count; i++)
            {
                switch (_file[i])
                {
                case string s when s == "":
                    break;

                case string s when s[0] == '#':
                    _packer.Container.UnprocessedText.AddLine(_file[i]);
                    break;

                case string s when s.Contains("proc"):
                    var script = _helper.GetCodeToClosingBrace(_file.ToArray(), i, '{');

                    i = _helper.SearchClosingBraces(_file.ToArray(), '{', i);
                    _packer.Add(_scriptFactory.CreateScript(script));
                    break;

                case string s when s.Contains("Specify") && s.Contains("Atlas"):
                    var atlas = _helper.GetCodeToClosingBrace(_file.ToArray(), i, '{', '[');

                    i = _helper.SearchClosingBraces(_file.ToArray(), i, '{', '[');
                    _packer.Add(_atlasFactory.CreateAtlas(atlas));
                    break;

                case string s when s.Contains("Specify") && s.Contains("Mesh"):
                    var mesh = _helper.GetCodeToClosingBrace(_file.ToArray(), i, '{');

                    i = _helper.SearchClosingBraces(_file.ToArray(), i, '{');
                    _packer.Container.UnprocessedText.AddLines(mesh);
                    break;

                case string s when s.Contains("Specify") && s.Contains("Evolve"):
                    var evolve = _helper.GetCodeToClosingBrace(_file.ToArray(), i, '{');

                    i = _helper.SearchClosingBraces(_file.ToArray(), i, '{');
                    _packer.Container.UnprocessedText.AddLines(evolve);
                    break;

                case string s when s.Contains("Specify"):
                    var energyText = _helper.GetCodeToClosingBrace(_file.ToArray(), i, '{');

                    i = _helper.SearchClosingBraces(_file.ToArray(), i, '{');
                    var energy = _energyFactory.CreateEnergy(energyText);
                    if (energy != null)
                    {
                        _packer.Add(energy);
                    }
                    break;

                default:
                    _packer.Container.UnprocessedText.AddLine(_file[i]);
                    break;
                }
            }
        }
        public void CreateMultiatlasTest()
        {
            CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            var creator = new AtlasFactoryText();
            var text    = new string[] { "Specify Oxs_MultiAtlas:multiatlas1[subst {", "", "atlas { Oxs_ScriptAtlas: top {",
                                         " xrange { 0e-9 70e-9}", "yrange { 0e-9 70e-9}", "zrange { 2.1e-9 3.5e-9}", "regions { top emptytop}", "script_args { relpt }",
                                         "script EllipseZ", "} }", "", "atlas { Oxs_ScriptAtlas: spacer {", "xrange { 0e-9 70e-9}", "yrange { 0e-9 70e-9}", "zrange { 0.7e-9 2.1e-9}",
                                         "regions { spacer emptyspacer}", "script_args { relpt }", "script EllipseZ", "} }", "", "atlas { Oxs_ScriptAtlas: bottom {",
                                         "xrange { 0e-9 70e-9}", "yrange { 0e-9 70e-9}", "zrange { 0e-9 0.7e-9}", "regions { bottom emptybottom}", "script_args { relpt }",
                                         "script EllipseZ", "}", "", "}]" };
            var atlas = creator.CreateAtlas(text);

            Assert.IsType <MultiAtlas>(atlas);
        }