public static bool IsStrongBox(object target) { Type t = CompilerHelpers.GetType(target); return(IsStrongBox(t)); }
public override object Build(CodeContext context, object[] args) { object arg = args[Index]; if (arg == null) { throw RuntimeHelpers.SimpleTypeError("expected StrongBox, but found null"); } Type argType = arg.GetType(); if (!argType.IsGenericType || argType.GetGenericTypeDefinition() != typeof(StrongBox <>)) { throw RuntimeHelpers.SimpleTypeError("expected StrongBox<>"); } if (argType.GetGenericArguments()[0] != _elementType) { throw RuntimeHelpers.SimpleTypeError(String.Format("Expected type {0}, got {1}", typeof(StrongBox <>).MakeGenericType(_elementType).FullName, CompilerHelpers.GetType(arg).FullName)); } object value = ((IStrongBox)arg).Value; if (value == null) { return(null); } return(context.LanguageContext.Binder.Convert(value, _elementType)); }