Beispiel #1
0
        public object GetValueOrNull(string name)
        {
            if (_NamespaceType != null)
            {
                if (QsFunction.IsItFunctionSymbolicName(name))
                {
                    if (HardCodedMethods == null)
                    {
                        HardCodedMethods = GetQsNamespaceMethods();
                    }

                    if (HardCodedMethods.ContainsKey(name))
                    {
                        return(HardCodedMethods[name]);
                    }
                }
                else
                {
                    var prop = _NamespaceType.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);
                    if (prop != null)
                    {
                        return(Root.NativeToQsConvert(prop.GetValue(null, null)));
                    }
                }
            }

            // try in values hash

            object o;

            Values.TryGetValue(name, out o);

            return(o);
        }
Beispiel #2
0
        /// <summary>
        /// It tries to get the value of the given key.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public object GetValue(string name)
        {
            if (_NamespaceType != null)
            {
                if (QsFunction.IsItFunctionSymbolicName(name))
                {
                    if (HardCodedMethods == null)
                    {
                        HardCodedMethods = GetQsNamespaceMethods();
                    }

                    if (HardCodedMethods.ContainsKey(name))
                    {
                        return(HardCodedMethods[name]);
                    }
                }
                else
                {
                    var prop = _NamespaceType.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);
                    if (prop != null)
                    {
                        return(Root.NativeToQsConvert(prop.GetValue(null, null)));
                    }
                }
            }

            // try in values hash

            object o;

            Values.TryGetValue(name, out o);

            if (o == null)
            {
                throw new QsVariableNotFoundException("Variable '" + name + "' not found in '" + this.Name + "' namespace.");
            }
            return(o);
        }