Beispiel #1
0
 public override void Add(ref DictionaryStorage storage, object key, object value)
 {
     if (key is string strKey)
     {
         PythonOps.ScopeSetMember(_context.SharedContext, _scope, strKey, value);
     }
     else
     {
         PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope);
         ext.EnsureObjectKeys().Add(key, value);
     }
 }
Beispiel #2
0
        public override void Add(object key, object value)
        {
            string strKey = key as string;

            if (strKey != null)
            {
                PythonOps.ScopeSetMember(_context.SharedContext, _scope, strKey, value);
            }
            else
            {
                PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope);
                ext.EnsureObjectKeys().Add(key, value);
            }
        }
Beispiel #3
0
        public override bool TryGetValue(object key, out object value)
        {
            if (key is string strKey)
            {
                return(PythonOps.ScopeTryGetMember(_context.SharedContext, _scope, strKey, out value));
            }
            else
            {
                PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope);
                if (ext.ObjectKeys != null && ext.ObjectKeys.TryGetValue(key, out value))
                {
                    return(true);
                }
            }

            value = null;
            return(false);
        }
Beispiel #4
0
        private bool Remove(object key)
        {
            if (key is string strKey)
            {
                if (Contains(key))
                {
                    return(PythonOps.ScopeDeleteMember(_context.SharedContext, Scope, strKey));
                }
            }
            else
            {
                PythonScopeExtension ext = (PythonScopeExtension)_context.EnsureScopeExtension(_scope);

                return(ext.ObjectKeys != null && ext.ObjectKeys.Remove(key));
            }

            return(false);
        }