Use collection expressions

This commit is contained in:
Jason Nelson 2024-03-15 11:01:20 -07:00 committed by BobLd
parent 524b235502
commit d19e6ad510
5 changed files with 29 additions and 30 deletions

View File

@ -169,7 +169,7 @@
if (A < Amin)
{
Amin = A;
MBR = new[] { R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y };
MBR = [R0X, R0Y, R1X, R1Y, R2X, R2Y, R3X, R3Y];
}
}

View File

@ -538,7 +538,7 @@
for (var i = 0; i < decoded.Count; i += NumberOfColorComponents)
{
int key = 0;
double[] comps = new double[NumberOfColorComponents];
var comps = new double[NumberOfColorComponents];
for (int n = 0; n < NumberOfColorComponents; n++)
{
byte b = decoded[i + n];
@ -832,7 +832,7 @@
internal override double[] Process(params double[] values)
{
var (R, _, _) = colorSpaceTransformer.TransformToRGB((values[0], values[0], values[0]));
return new double[] { R };
return [R];
}
/// <inheritdoc/>
@ -1114,7 +1114,7 @@
double Z = WhitePoint[2] * g(N);
var (R, G, B) = colorSpaceTransformer.TransformToRGB((X, Y, Z));
return new double[] { R, G, B };
return [R, G, B];
}
/// <inheritdoc/>

View File

@ -9,24 +9,24 @@
/// </summary>
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineGridIndex = new Dictionary<int, int[]>
{
{ 1, new []{ 0 } },
{ 2, new []{ 0 } },
{ 3, new []{ 4 } },
{ 4, new []{ 0, 4 } },
{ 5, new []{ 2, 6 } },
{ 6, new[] { 0, 2, 4, 6 } },
{ 7, new[] { 1, 3, 5, 7 } }
{ 1, [0] },
{ 2, [0] },
{ 3, [4] },
{ 4, [0, 4] },
{ 5, [2, 6] },
{ 6, [0, 2, 4, 6] },
{ 7, [1, 3, 5, 7] }
};
private static readonly IReadOnlyDictionary<int, int[]> PassToScanlineColumnIndex = new Dictionary<int, int[]>
{
{ 1, new []{ 0 } },
{ 2, new []{ 4 } },
{ 3, new []{ 0, 4 } },
{ 4, new []{ 2, 6 } },
{ 5, new []{ 0, 2, 4, 6 } },
{ 6, new []{ 1, 3, 5, 7 } },
{ 7, new []{ 0, 1, 2, 3, 4, 5, 6, 7 } }
{ 1, [0] },
{ 2, [4] },
{ 3, [0, 4] },
{ 4, [2, 6] },
{ 5, [0, 2, 4, 6] },
{ 6, [1, 3, 5, 7] },
{ 7, [0, 1, 2, 3, 4, 5, 6, 7] }
};
/*

View File

@ -47,7 +47,7 @@
else
{
// optional - Default value: the identity matrix [1 0 0 1 0 0]
matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 });
matrix = TransformationMatrix.FromArray([1, 0, 0, 1, 0, 0]);
}
DictionaryToken patternExtGState = null;

View File

@ -15,8 +15,8 @@
{
public static Shading Create(IToken shading, IPdfTokenScanner scanner, IResourceStore resourceStore, ILookupFilterProvider filterProvider)
{
DictionaryToken shadingDictionary = null;
StreamToken shadingStream = null;
DictionaryToken? shadingDictionary = null;
StreamToken? shadingStream = null;
if (shading is StreamToken fs)
{
@ -28,8 +28,7 @@
shadingDictionary = fd;
}
ShadingType shadingType;
if (shadingDictionary.TryGet<NumericToken>(NameToken.ShadingType, scanner, out var shadingTypeToken))
if (shadingDictionary.TryGet<NumericToken>(NameToken.ShadingType, scanner, out ShadingType shadingTypeToken))
{
// Shading types 4 to 7 shall be defined by a stream containing descriptive data characterizing
// the shading's gradient fill.
@ -140,7 +139,7 @@
else
{
// Optional - Default value: [0.0 1.0 0.0 1.0].
domain = new double[] { 0.0, 1.0, 0.0, 1.0 };
domain = [0.0, 1.0, 0.0, 1.0];
}
TransformationMatrix matrix;
@ -151,7 +150,7 @@
else
{
// Optional - Default value: the identity matrix [1 0 0 1 0 0]
matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 });
matrix = TransformationMatrix.FromArray([1, 0, 0, 1, 0, 0]);
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@ -185,7 +184,7 @@
else
{
// set default values
domain = new double[] { 0, 1 };
domain = [0, 1];
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@ -207,7 +206,7 @@
private static RadialShading CreateRadialShading(DictionaryToken shadingDictionary, ColorSpaceDetails colorSpace,
double[] background, PdfRectangle? bbox, bool antiAlias, IPdfTokenScanner scanner, ILookupFilterProvider filterProvider)
{
double[] coords = null;
double[]? coords = null;
if (shadingDictionary.TryGet<ArrayToken>(NameToken.Coords, scanner, out var coordsToken))
{
coords = coordsToken.Data.OfType<NumericToken>().Select(v => v.Double).ToArray();
@ -225,7 +224,7 @@
else
{
// set default values
domain = new double[] { 0, 1 };
domain = [0, 1];
}
if (!shadingDictionary.ContainsKey(NameToken.Function))
@ -235,7 +234,7 @@
PdfFunction[] functions = GetFunctions(shadingDictionary.Data[NameToken.Function], scanner, filterProvider);
bool[] extend = new bool[] { false, false }; // Default values
bool[] extend = [false, false]; // Default values
if (shadingDictionary.TryGet<ArrayToken>(NameToken.Extend, scanner, out var extendToken))
{
extend = extendToken.Data.OfType<BooleanToken>().Select(v => v.Data).ToArray();
@ -287,7 +286,7 @@
throw new ArgumentNullException($"{NameToken.Decode} is required for shading type '{ShadingType.FreeFormGouraud}'.");
}
PdfFunction[] functions = null; // Optional
PdfFunction[]? functions = null; // Optional
if (shadingStream.StreamDictionary.ContainsKey(NameToken.Function))
{
functions = GetFunctions(shadingStream.StreamDictionary.Data[NameToken.Function], scanner, filterProvider);