示例#1
0
        public TopLevelTypeName(string reflectionName)
        {
            int pos = reflectionName.LastIndexOf('.');

            if (pos < 0)
            {
                namespaceName = string.Empty;
                name          = reflectionName;
            }
            else
            {
                namespaceName = reflectionName.Substring(0, pos);
                name          = reflectionName.Substring(pos + 1);
            }
            name = SRMExtensions.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount);
        }
示例#2
0
        /// <summary>
        /// Constructs a FullTypeName by parsing the given reflection name.
        /// Note that FullTypeName can only represent type definition names. If the reflection name
        /// might refer to a parameterized type or array etc., use
        /// <see cref="ReflectionHelper.ParseReflectionName(string)"/> instead.
        /// </summary>
        /// <remarks>
        /// Expected syntax: <c>NamespaceName '.' TopLevelTypeName ['`'#] { '+' NestedTypeName ['`'#] }</c>
        /// where # are type parameter counts
        /// </remarks>
        public FullTypeName(string reflectionName)
        {
            int pos = reflectionName.IndexOf('+');

            if (pos < 0)
            {
                // top-level type
                this.topLevelType = new TopLevelTypeName(reflectionName);
                this.nestedTypes  = null;
            }
            else
            {
                // nested type
                string[] parts = reflectionName.Split('+');
                this.topLevelType = new TopLevelTypeName(parts[0]);
                this.nestedTypes  = new NestedTypeName[parts.Length - 1];
                for (int i = 0; i < nestedTypes.Length; i++)
                {
                    int    tpc;
                    string name = SRMExtensions.SplitTypeParameterCountFromReflectionName(parts[i + 1], out tpc);
                    nestedTypes[i] = new NestedTypeName(name, tpc);
                }
            }
        }