Extends System.Dynamic.DynamicObject
Implements IPhpObject.
A dynamic object that can hold any property, used for deserializing object notation while providing a way to access the specified classname.
Important:
PhpObjectDictionary only supports string keys. You can not deserialize PHP objects with integer keys using this type. This may be addressed in future releases.
Implementation of IPhpObject.SetClassName.
Implementation of IPhpObject.GetClassName.
Overrides System.Dynamic.DynamicObject.TryGetMember()
Overrides System.Dynamic.DynamicObject.TrySetMember()
Like with any dynamic object, you can just assign properties and read them:
dynamic myObject = new PhpDynamicObject();
myObject.Foo = "abc";
myObject.Bar = "def";
System.Console.WriteLine(myObject.Foo + myObject.Bar); // abcdef
You can also use it to construct arbitary PHP objects for serialization, including a classname.
dynamic myObject = new PhpDynamicObject();
myObject.firstname = "Joseph";
myObject.lastname = "Bishop";
myObject.SetClassName("Person");
PhpSerialization.Serialize(myObject);
// O:6:"Person":2:{s:9:"firstname";s:6:"Joseph";s:8:"lastname";s:6:"Bishop";}