GetValue() public method

public GetValue ( string name ) : object
name string
return object
Exemplo n.º 1
0
        public void DefineMethod()
        {
            DynamicObject dynobj = new DynamicObject();

            ICommand body = new ReturnCommand(new VariableExpression("Name"));
            Function function = new Function(null, body);

            dynobj.SetValue("GetName", function);

            object result = dynobj.GetValue("GetName");

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ICallable));
            Assert.IsTrue(result == function);
        }
Exemplo n.º 2
0
 public void GetValueFromPrototypeAndSetValueInObject()
 {
     Function function = new Function(null, null);
     DynamicObject dynobj = new DynamicObject(function);
     DynamicObject prototype = new DynamicObject();
     function.SetValue("prototype", prototype);
     prototype.SetValue("x", 10);
     dynobj.SetValue("x", 20);
     Assert.AreEqual(20, dynobj.GetValue("x"));
     Assert.AreEqual(10, prototype.GetValue("x"));
 }
Exemplo n.º 3
0
 public void GetUndefinedForUndefinedValue()
 {
     DynamicObject dynobj = new DynamicObject();
     Assert.AreSame(Undefined.Instance, dynobj.GetValue("Foo"));
 }
Exemplo n.º 4
0
        public void UsePrototypeForGetValue()
        {
            Function function = new Function(null, null);
            DynamicObject dynobj = new DynamicObject(function);

            DynamicObject prototype = new DynamicObject();
            function.SetValue("prototype", prototype);
            prototype.SetValue("x", 10);

            Assert.AreEqual(10, dynobj.GetValue("x"));
        }
Exemplo n.º 5
0
        public void SetAndGetValue()
        {
            DynamicObject dynobj = new DynamicObject();

            dynobj.SetValue("Foo", "Bar");

            Assert.AreEqual("Bar", dynobj.GetValue("Foo"));
        }
Exemplo n.º 6
0
 public void RemoveValue()
 {
     DynamicObject dynobj = new DynamicObject();
     dynobj.SetValue("name", "Adam");
     Assert.IsTrue(dynobj.HasName("name"));
     dynobj.RemoveValue("name");
     Assert.IsFalse(dynobj.HasName("name"));
     Assert.AreSame(Undefined.Instance, dynobj.GetValue("name"));
 }
Exemplo n.º 7
0
 public void GetValueFromPrototypeAndSetValueInObject()
 {
     DynamicObject prototype = new DynamicObject();
     this.function.SetValue("prototype", prototype);
     prototype.SetValue("x", 10);
     this.dynobj.SetValue("x", 20);
     Assert.AreEqual(20, this.dynobj.GetValue("x"));
     Assert.AreEqual(10, prototype.GetValue("x"));
 }