예제 #1
0
 public object Deserialize(StructuredText node)
 {
     //TODO エラーハンドリング弱い
     if (node.ChildCount != 2)
     {
         return(null);
     }
     return(new MRUItem(
                (ITerminalParameter)_serializeService.Deserialize(node.GetChildOrNull(0)),
                (ITerminalSettings)_serializeService.Deserialize(node.GetChildOrNull(1))));
 }
        public object Deserialize(StructuredText node) {
            PipeTerminalSettings ts = new PipeTerminalSettings();

            StructuredText baseNode = node.GetChildOrNull(0);
            if (baseNode != null) {
                TerminalSettings baseTs = PipePlugin.Instance.SerializeService.Deserialize(baseNode) as TerminalSettings;
                if (baseTs != null) {
                    ts.Import(baseTs);
                }
            }
            return ts;
        }
예제 #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;
        }
예제 #4
0
 public object Deserialize(StructuredText node) {
     //TODO エラーハンドリング弱い
     if (node.ChildCount != 2)
         return null;
     return new MRUItem(
         (ITerminalParameter)_serializeService.Deserialize(node.GetChildOrNull(0)),
         (ITerminalSettings)_serializeService.Deserialize(node.GetChildOrNull(1)));
 }