Exemplo n.º 1
0
 public virtual ValueBase GetItem(string key)
 {
     if (Marshal.IsComObject(Value))
     {
         return(null);
     }
     try { return(ValueBase.GetValue(key, Engine.Instance.GetValue("getattr")(Value, key))); }
     catch { return(null); }
 }
Exemplo n.º 2
0
 public ValueTree(ValueBase value, bool expanded = false)
 {
     Name     = value.Name;
     Expanded = expanded;
     Value    = value;
     if (HasItems = Value.HasItems)
     {
         Id = _maxid++;
     }
 }
Exemplo n.º 3
0
        public static ValueTree GetValues(TraceBackFrame frame)
        {
            Scope  = Engine.Instance.CreateScope();
            _maxid = 0;
            _root  =
                new ValueTree(".", true, true)
            {
                new ValueTree("Globals", true, true),
                new ValueTree("Locals", true, true)
            };
            if (frame.f_globals != null)
            {
                foreach (var kv in frame.f_globals)
                {
                    string name  = kv.Key.ToString();
                    object value = kv.Value;
                    _root[0].Add(ValueBase.GetValue(name, value));
                    if (value != null)
                    {
                        Scope.SetVariable(name, value);
                    }
                }
            }

            if (frame.f_locals != null)
            {
                var dict = (PythonDictionary)frame.f_locals;
                foreach (var kv in (PythonDictionary)frame.f_locals)
                {
                    string  name  = kv.Key.ToString();
                    dynamic value = kv.Value;
                    if (value is ClosureCell)
                    {
                        if (name.EndsWith("1"))
                        {
                            var rname = name.Substring(0, name.Length - 1);
                            if (dict.keys().Cast <string>().Contains(rname))
                            {
                                name = rname;
                            }
                        }
                        try { value = value.cell_contents; }
                        catch { value = null; }
                        _root[1].Add(ValueBase.GetValue(name, value));
                        if (value != null)
                        {
                            Scope.SetVariable(name, value);
                        }
                    }
                }
            }
            return(_root);
        }
Exemplo n.º 4
0
        public override IEnumerable <ValueTree> GetItems()
        {
            List lst   = Engine.Instance.GetValue("clr").Dir(Value);
            var  names = lst.Cast <string>().Where(s => !s.StartsWith("_"));

            foreach (var name in names)
            {
                dynamic obj = null;
                try { obj = Engine.Instance.GetValue("getattr")(Value, name); }
                catch { }
                yield return(new ValueTree(ValueBase.GetValue(name, obj)));
            }
        }
Exemplo n.º 5
0
        public virtual IEnumerable <ValueTree> GetItems()
        {
            List lst = Engine.Instance.GetValue("clr").Dir(Value);

            if (lst != null)
            {
                foreach (string key in lst)
                {
                    dynamic obj = null;
                    try { obj = Engine.Instance.GetValue("getattr")(Value, key); }
                    catch { }
                    yield return(new ValueTree(ValueBase.GetValue(key, obj)));
                }
            }
        }
Exemplo n.º 6
0
 public void Add(ValueBase item, bool expanded = false)
 {
     Add(new ValueTree(item, expanded));
 }