Esempio n. 1
0
        public static string GetTypeID(Type type)
        {
            var name = FormatType(type);

            name = name.Replace(", ", ",");
            var builder = new StringBuilder();

            for (var i = 0; i < name.Length; ++i)
            {
                var cat = CharUnicodeInfo.GetUnicodeCategory(name, i);
                var cp  = DataUtilities.CodePointAt(name, i);
                if (cp >= 0x10000)
                {
                    ++i;
                }
                if (cat == UnicodeCategory.UppercaseLetter ||
                    cat == UnicodeCategory.LowercaseLetter ||
                    cat == UnicodeCategory.TitlecaseLetter ||
                    cat == UnicodeCategory.OtherLetter ||
                    cat == UnicodeCategory.DecimalDigitNumber ||
                    cp == '_' || cp == '.')
                {
                    if (cp >= 0x10000)
                    {
                        builder.Append(name, i, 2);
                    }
                    else
                    {
                        builder.Append(name[i]);
                    }
                }
                else
                {
                    builder.Append(' ');
                }
            }
            name = builder.ToString();
            name = name.Trim();
            name = name.Replace(' ', '-');
            return(name);
        }