Created
June 5, 2022 14:01
-
-
Save emoacht/ac77ee791f8324015d74c3a4a83320d3 to your computer and use it in GitHub Desktop.
MarkupExtension to construct an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MarkupExtensionReturnType(typeof(object[]))] | |
public class ArrayConstructorExtension : MarkupExtension | |
{ | |
private readonly object[] _elements; | |
public ArrayConstructorExtension(object a) => _elements = new[] { a }; | |
public ArrayConstructorExtension(object a, object b) => _elements = new[] { a, b }; | |
public ArrayConstructorExtension(object a, object b, object c) => _elements = new[] { a, b, c }; | |
public ArrayConstructorExtension(object a, object b, object c, object d) => _elements = new[] { a, b, c, d }; | |
public ArrayConstructorExtension(object a, object b, object c, object d, object e) => _elements = new[] { a, b, c, d, e }; | |
public override object ProvideValue(IServiceProvider serviceProvider) | |
{ | |
return _elements; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment