public object Deserialize(StructuredText node) {
            PipeTerminalParameter tp = new PipeTerminalParameter();

            tp.ExeFilePath = node.Get("exeFilePath", null);
            tp.CommandLineOptions = node.Get("commandLineOptions", null);
            List<PipeTerminalParameter.EnvironmentVariable> envList = new List<PipeTerminalParameter.EnvironmentVariable>();
            foreach (StructuredText s in node.FindMultipleNote("environmentVariable")) {
                string name = s.Get("name", null);
                string value = s.Get("value", null);
                if (name != null && value != null) {
                    envList.Add(new PipeTerminalParameter.EnvironmentVariable(name, value));
                }
            }
            tp.EnvironmentVariables = (envList.Count > 0) ? envList.ToArray() : null;
            tp.InputPipePath = node.Get("inputPipePath", null);
            tp.OutputPipePath = node.Get("outputPipePath", null);
            tp.SetTerminalName(node.Get("terminal-type", "vt100"));
            tp.AutoExecMacroPath = node.Get("autoexec-macro", null);
            return tp;
        }
Example #2
0
        public object Deserialize(StructuredText node)
        {
            PipeTerminalParameter tp = new PipeTerminalParameter();

            tp.ExeFilePath        = node.Get("exeFilePath", null);
            tp.CommandLineOptions = node.Get("commandLineOptions", null);
            List <PipeTerminalParameter.EnvironmentVariable> envList = new List <PipeTerminalParameter.EnvironmentVariable>();

            foreach (StructuredText s in node.FindMultipleNote("environmentVariable"))
            {
                string name  = s.Get("name", null);
                string value = s.Get("value", null);
                if (name != null && value != null)
                {
                    envList.Add(new PipeTerminalParameter.EnvironmentVariable(name, value));
                }
            }
            tp.EnvironmentVariables = (envList.Count > 0) ? envList.ToArray() : null;
            tp.InputPipePath        = node.Get("inputPipePath", null);
            tp.OutputPipePath       = node.Get("outputPipePath", null);
            tp.SetTerminalName(node.Get("terminal-type", "vt100"));
            tp.AutoExecMacroPath = node.Get("autoexec-macro", null);
            return(tp);
        }
Example #3
0
        internal void LoadFrom(StructuredText node)
        {
            bool dirty       = false;
            int  child_index = 0;
            int  data_index  = 0;

            while (child_index < _children.Count)
            {
                IPreferenceItemBase   child     = (IPreferenceItemBase)_children[child_index];
                PreferenceFolder      ch_folder = child as PreferenceFolder;
                PreferenceFolderArray ch_array  = child as PreferenceFolderArray;
                PreferenceItem        ch_item   = child as PreferenceItem;
                PreferenceLooseNode   ch_loose  = child as PreferenceLooseNode;

                //TODO 以下の分岐汚すぎ、何とかする

                if (ch_folder != null)
                {
                    StructuredText ch_data = node.GetChildOrNull(data_index);                     //大抵はうまく整列しているので検索の手間を省く
                    if (ch_data == null || ch_data.Name != ch_folder.Id)
                    {
                        dirty   = true;
                        ch_data = node.FindChild(ch_folder.Id);
                    }
                    else
                    {
                        data_index++;
                    }

                    if (ch_data == null)
                    {
                        ch_folder.ResetValue();
                    }
                    else
                    {
                        ch_folder.LoadFrom(ch_data);
                    }
                }
                else if (ch_item != null)
                {
                    StructuredText.Entry ch_data = node.GetEntryOrNull(data_index);                     //大抵はうまく整列しているので検索の手間を省く
                    if (ch_data == null || ch_data.name != ch_item.Id)
                    {
                        dirty   = true;
                        ch_data = node.FindEntry(ch_item.Id);
                    }
                    else
                    {
                        data_index++;
                    }

                    if (ch_data == null)
                    {
                        ch_item.ResetValue();
                    }
                    else
                    {
                        ch_item.TryToParse(ch_data.value, PreferenceItem.ErrorMode.Reset);
                    }
                }
                else if (ch_array != null)
                {
                    ArrayList      ch_data = new ArrayList();
                    StructuredText t       = node.GetChildOrNull(data_index);
                    if (t == null || t.Name != ch_array.Id)
                    {
                        dirty = true;
                        ch_data.Clear();
                        ch_data.AddRange(node.FindMultipleNote(ch_array.Id));
                    }
                    else                       //最初の一つが合格だったら継続して読み続ける
                    {
                        data_index++;
                        while (t != null && t.Name == ch_array.Id)
                        {
                            ch_data.Add(t);
                            t = node.GetChildOrNull(data_index++);
                        }
                    }

                    ch_array.LoadFrom(ch_data);
                }
                else if (ch_loose != null)
                {
                    //TODO これはFolderのときと同じだ。まとめよう
                    StructuredText ch_data = node.GetChildOrNull(data_index);     //大抵はうまく整列しているので検索の手間を省く
                    if (ch_data == null || ch_data.Name != ch_loose.Id)
                    {
                        dirty   = true;
                        ch_data = node.FindChild(ch_loose.Id);
                    }
                    else
                    {
                        data_index++;
                    }

                    if (ch_data == null)
                    {
                        ch_loose.ResetValue();
                    }
                    else
                    {
                        ch_loose.LoadFrom(ch_data);
                    }
                }

                child_index++;                 //自分の子をステップ
            }

            //一度エラーなく読むことができていればdirtyはfalseのまま
            node.IsDirty = dirty;
        }