BadScript 2
Loading...
Searching...
No Matches
BadReflectedProperty.cs
Go to the documentation of this file.
1using System.Reflection;
2
6
8
13{
17 private readonly PropertyInfo m_Property;
18
23 public BadReflectedProperty(PropertyInfo property) : base(property.Name)
24 {
25 m_Property = property;
26 }
27
29 public override bool IsReadOnly => !m_Property.CanWrite;
30
32 public override BadObject Get(object instance)
33 {
34 return Wrap(m_Property.GetValue(instance));
35 }
36
38 public override void Set(object instance, BadObject o)
39 {
40 if (o is not IBadNative native || !m_Property.PropertyType.IsAssignableFrom(native.Type))
41 {
42 throw new BadRuntimeException("Invalid Reflection Set");
43 }
44
45 m_Property.SetValue(instance, native.Value);
46 }
47}
static BadObject Wrap(object? o)
Wraps an Object into a BadObject.
BadReflectedProperty(PropertyInfo property)
Creates a new BadReflectedProperty.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Defines properties for Native Types.
Definition IBadNative.cs:7
Contains the Error Objects for the BadScript2 Language.
Contains the Member Classes for Reflection Objects.
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6
Contains the Runtime Objects.
Definition BadArray.cs:10