Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SignatureArrayType.cs « Reflection « System « shared « System.Private.CoreLib « netcore - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b02bd787f7a9914e0c51c23cf43f4691af227747 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;

namespace System.Reflection
{
    internal sealed class SignatureArrayType : SignatureHasElementType
    {
        internal SignatureArrayType(SignatureType elementType, int rank, bool isMultiDim)
            : base(elementType)
        {
            Debug.Assert(rank > 0);
            Debug.Assert(rank == 1 || isMultiDim);

            _rank = rank;
            _isMultiDim = isMultiDim;
        }

        protected sealed override bool IsArrayImpl() => true;
        protected sealed override bool IsByRefImpl() => false;
        protected sealed override bool IsPointerImpl() => false;

        public sealed override bool IsSZArray => !_isMultiDim;
        public sealed override bool IsVariableBoundArray => _isMultiDim;

        public sealed override int GetArrayRank() => _rank;

        protected sealed override string Suffix
        {
            get
            {
                if (!_isMultiDim)
                    return "[]";
                else if (_rank == 1)
                    return "[*]";
                else
                    return "[" + new string(',', _rank - 1) + "]";
            }
        }

        private readonly int _rank;
        private readonly bool _isMultiDim;
    }
}