/// <summary> /// Initializes a new instance of the <see cref="BrailViewComponentContext"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="body">The body.</param> /// <param name="name">The name.</param> /// <param name="text">The text.</param> /// <param name="parameters">The parameters.</param> public BrailViewComponentContext(BrailBase parent, ICallable body, string name, TextWriter text, IDictionary parameters) { this.parent = parent; this.body = body; componentName = name; default_writer = text; componentParameters = IgnoreNull.ReplaceIgnoreNullsWithTargets(parameters); }
public static object Invoke(object target, string name, object[] args) { args = IgnoreNull.ReplaceIgnoreNullsWithTargets(args); var duck = target as IQuackFu; if (null != duck) { return(duck.QuackInvoke(name, args)); } var type = target as Type; if (null != type) { // static method return(type.InvokeMember(name, InvokeBindingFlags, null, null, args)); } if (target == null) { throw new NullReferenceException("Could not invoke method " + name + " on null target"); } var targetType = target.GetType(); if (args.Length == 2 && args[0] is string && name == "op_Addition") { return(((string)args[0]) + args[1]); } return(targetType.InvokeMember(name, ResolveFlagsToUse(targetType, InvokeBindingFlags), null, target, args)); }
public static object SetSlice(object target, string name, object[] args) { args = IgnoreNull.ReplaceIgnoreNullsWithTargets(args); var duck = target as IQuackFu; if (null != duck) { return(duck.QuackSet(name, (object[])RuntimeServices.GetRange2(args, 0, args.Length - 1), args[args.Length - 1])); } var type = target.GetType(); if ("" == name) { if (IsSetArraySlice(target, args)) { return(SetArraySlice(target, args)); } name = GetDefaultMemberName(type); } var member = SelectSliceMember(GetMember(type, name), ref args, SetOrGet.Set); return(SetSlice(target, member, args)); }