private static object ReadArray(NodeReference node, Type columnType)
        {
            var arrayLengthsString = node.GetString(EnumerableLengthsSubscriptName);

            if (string.IsNullOrEmpty(arrayLengthsString))
            {
                return(null);
            }

            var elementType  = columnType.GetElementType();
            var arrayLengths = ToArrayIndexes(arrayLengthsString);
            var instance     = Array.CreateInstance(elementType, arrayLengths);

            var subscript = node.NextSubscript(EnumerableLengthsSubscriptName);

            while (!subscript.Equals(""))
            {
                node.AppendSubscript(subscript);

                var item    = ReadNode(node, elementType);
                var indexes = ToArrayIndexes(subscript);

                instance.SetValue(item, indexes);

                subscript = node.NextSubscript();
                node.SetSubscriptCount(node.GetSubscriptCount() - 1);
            }

            return(instance);
        }
        internal static int GetEnumerableCount(NodeReference node)
        {
            var arrayLengthsString = node.GetString(EnumerableLengthsSubscriptName);
            var indexes            = ToArrayIndexes(arrayLengthsString);

            return(indexes.Aggregate(1, (current, index) => current * index));
        }
Exemple #3
0
    public static void Main(String[] args)
    {
        Connection myConn = ConnectionContext.GetConnection();

        try {
            myConn.Connect("User", "_SYSTEM", "SYS");
            NodeReference nodeRef = myConn.CreateNodeReference("myGlobal");
            // Read both existing nodes
            Console.WriteLine("Value of ^myGlobal is " + nodeRef.GetString());
            Console.WriteLine("Value of ^myGlobal(\"sub1\") is " + nodeRef.GetString("sub1"));
            nodeRef.Kill(); // delete entire array
            nodeRef.Close();
            myConn.Close();
        }
        catch (GlobalsException e) { Console.WriteLine(e.Message); }
    } // end Main()
Exemple #4
0
        public ValueType PropertyType(string property_name)
        {
            if (_DocNodeRef.GetString() != "GlDoc")
            {
                return(ValueType.UNKNOWN);
            }
            switch (_DocNodeRef.GetString(property_name, DATA_TYPE_SUBSCRIPT))
            {
            case STRING_DATATYPE_FLAG:
                return(ValueType.STRING);

            case DOC_DATATYPE_FLAG:
                return(ValueType.DOCUMENT);

            default:
                return(ValueType.UNKNOWN);
            }
        }
Exemple #5
0
        // compile a list of all global names in the current namespace, either
        // just for "graph" globals, or for everything.
        public static List <string> AllGlobals(bool just_the_docsets)
        {
            List <string>    working_list  = new List <string>();
            GlobalsDirectory all_node_refs = ActiveConnection().CreateGlobalsDirectory();

            all_node_refs.Refresh();

            string loop_name = all_node_refs.NextGlobalName();

            while (loop_name != "")
            {
                NodeReference loop_node = ActiveConnection().CreateNodeReference(loop_name);
                if (loop_node.GetString() == GL_DOCS_FLAG || !just_the_docsets) // if we only want graphs, is it a "graph" global?
                {
                    working_list.Add(loop_name);
                }

                loop_name = all_node_refs.NextGlobalName();
            }

            return(working_list);
        }
Exemple #6
0
        public void DisplayForSubscripts(params object[] working_subscripts)
        {
            string prefix = Environment.NewLine + working_noderef.GetName();

            if (working_subscripts.Length > 0)
            {
                for (int ix = 0; ix < working_subscripts.Length; ix++)
                {
                    prefix += "[" + working_subscripts[ix].ToString() + "]";
                }
            }
            prefix += " = ";


            try
            {
                string current_val = working_noderef.GetString(working_subscripts);
                if (current_val != null)
                {
                    if (current_val != "")
                    {
                        textDocContents.AppendText(prefix + current_val);
                    }
                }
            }
            catch
            { }

            try
            {
                if (working_noderef.HasSubnodes(working_subscripts))
                {
                    int      count      = 0;
                    object[] sub_params = new object[working_subscripts.Length + 1];
                    for (int loop_index = 0; loop_index < working_subscripts.Length; loop_index++)
                    {
                        sub_params[loop_index] = working_subscripts[loop_index];
                    }

                    sub_params[working_subscripts.Length] = "";

                    string loop_sub = working_noderef.NextSubscript(sub_params);

                    while (loop_sub != "")
                    {
                        count++;
                        if (count > 10)
                        {
                            textDocContents.AppendText(Environment.NewLine + "...");
                            break;
                        }
                        sub_params[working_subscripts.Length] = loop_sub;
                        DisplayForSubscripts(sub_params);

                        loop_sub = working_noderef.NextSubscript(sub_params);
                    }
                }
            }
            catch //(Exception e)
            {
                MessageBox.Show("Error displaying data");
                return;
            }
        }