/// <summary> /// Agrega sin verficar que no contenga la llave. Usarse solo si se verifico que no esten presentes los valores antes /// </summary> /// <param name="key"></param> /// <param name="value"></param> public void UnsafeAdd(string key, PyObj value) { key = key.ToLowerInvariant(); if (value.IsNull()) { Table[key] = new MemoryBlock(MyNull.GetInstance()); } if (value.IsPrimitive()) { Table[key] = new MemoryBlock(MyPrimitiveFactory.CreateCopy((MyPrimitive)value)); } else//Only option left is for value to be customInstance { Table[key] = new MemoryBlock(value); } }
/// <summary> /// Retorna false si no agrego el valor a la tabla de simbolos. Solo se agregan valores que no esten presentes /// </summary> /// <param name="type"></param /// <param name="value"></param> /// <returns></returns> public bool Add(string key, PyObj value) { key = key.ToLowerInvariant(); if (Table.ContainsKey(key)) { return(false); } if (value.IsNull()) { Table[key] = new MemoryBlock(MyNull.GetInstance()); } if (value.IsPrimitive()) { Table[key] = new MemoryBlock(MyPrimitiveFactory.CreateCopy((MyPrimitive)value)); } else//Only option left is for value to be customInstance { Table[key] = new MemoryBlock(value); } return(true); }
/// <summary> /// Retorna false si no se cambio el valor de la llave en la tabla de simbolos. Solo se cambian valores que ya estan presentes /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public bool Set(string key, PyObj value) { key = key.ToLowerInvariant(); MemoryBlock memoryBlock; if (!Table.TryGetValue(key, out memoryBlock)) { return(false); } if (value.IsNull()) { memoryBlock.Value = MyNull.GetInstance(); } if (value.IsPrimitive()) { memoryBlock.Value = MyPrimitiveFactory.CreateCopy((MyPrimitive)value); } else//Only option left is for value to be customInstance { memoryBlock.Value = value; } return(true); }