At the simplest level you set it the same way you set the int property:
Assuming this class:
public class MyClass
{
internal Action<object> Simple { get; set; }
}
Setting the property:
var type = typeof(MyClass);
var action = new Action<object>((o) => Console.WriteLine("Invoked with {0}", o));
var obj = new MyClass();
type.GetProperty("Simple", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(obj, action);
If the delegate contains a type that is not public as an argument, you can still set it using object, depending on covariance/contravariance.
Assuming the class is as below, setting the property with Action<object> still works
public class MyClass
{
internal Action<Arg> Simple { get; set; }
}
internal class Arg { }
If the delegate type itself is internal you need to create an instance of that internal delegate type:
Assuming:
public class MyClass
{
internal Internal Simple { get; set; }
}
internal class Arg { }
internal delegate void Internal(Arg arg);
You can use:
var type = typeof(MyClass);
var prop = type.GetProperty("Simple", BindingFlags.NonPublic | BindingFlags.Instance);
var action = new Action<object>((o) => Console.WriteLine("Invoked with {0}", o));
var delegateInsrtance = Delegate.CreateDelegate(prop.PropertyType, action.Target, action.Method);
var obj = new MyClass();
prop.SetValue(obj, delegateInsrtance);
Note: The above code works, because we created a delegate (Action<object>) that can be compatible with the Internal delegate (the arguments do not need any explicit casting) and used the methodInfo of that delegate to create out new internal delegate. depending on the type of the delegate you want to create this may be trickier, but without more info, this is example should be a good starting point.