Пример #1
0
        private void OnError(DatatreeDotNet.dt_status_t status, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string msg, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string pos, IntPtr row, IntPtr col)
        {
            string _msg = "Datatree parsing error:" + Environment.NewLine;

            _msg += "  error code: " + status.ToString() + Environment.NewLine;
            _msg += "  error message: " + msg + Environment.NewLine;
            _msg += "  error pos: {row: " + row.ToString() + ", col: " + col.ToString() + "}" + Environment.NewLine;

            Error(_msg);
        }
Пример #2
0
 static void _on_parse_error(DatatreeDotNet.dt_status_t status, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string msg, [InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string pos, System.IntPtr row, System.IntPtr col)
 {
     Debug.Print("Parsing error.\nError code: {0}, error message: {1}\nRow: {2}, col: {3}\nText: {4}\n", status, msg, row, col, pos);
 }
Пример #3
0
        private void Add(Func <string> source)
        {
            if (treeView.SelectedNode == null)
            {
                Message("Nothing selected." + Environment.NewLine);
                return;
            }

            if (!(treeView.SelectedNode.Tag is ValueInfo))
            {
                Message("Cannot add to this node." + Environment.NewLine);
                return;
            }

            ValueInfo valueInfo = (ValueInfo)treeView.SelectedNode.Tag;

            DatatreeDotNet.dt_type_t t = DatatreeDotNet.dt_value_type(valueInfo.Value);
            if (t == DatatreeDotNet.dt_type_t.DT_ARRAY)
            {
                string ipt = source();

                IntPtr o = IntPtr.Zero;
                DatatreeDotNet.dt_create_value(datatree, ref o, OnError, ipt);
                uint idx = 0;
                DatatreeDotNet.dt_add_array_elem
                (
                    datatree,
                    DatatreeDotNet.dt_value_data(valueInfo.Value),
                    o,
                    ref idx
                );
            }
            else if (t == DatatreeDotNet.dt_type_t.DT_OBJECT)
            {
                string ipt = source();

                IntPtr k = IntPtr.Zero;
                IntPtr v = IntPtr.Zero;
                DatatreeDotNet.dt_create_value(datatree, ref k, OnError, ipt);
                DatatreeDotNet.dt_create_value(datatree, ref v, OnError, "null");
                uint idx = 0;
                DatatreeDotNet.dt_status_t status = DatatreeDotNet.dt_add_object_member
                                                    (
                    datatree,
                    DatatreeDotNet.dt_value_data(valueInfo.Value),
                    k,
                    v,
                    ref idx
                                                    );
                if (status == DatatreeDotNet.dt_status_t.DT_KEY_EXISTS)
                {
                    Message("A key-value pair with the same key already exists." + Environment.NewLine);
                    return;
                }
            }
            else
            {
                Message("Cannot add to this node." + Environment.NewLine);
                return;
            }

            treeView.SelectedNode.Nodes.Add(new TreeNode());

            UpdateNodes();

            EditState = EditStates.OpenedNotSaved;
        }