Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Created Unassigned: Property with modifier [71]

0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images