コード例 #1
0
        void AppendSerializer(IProtoSerializer serializer, string description = "")
        {
            string name = serializer.GetType().Name;

            if (name.EndsWith("Serializer"))
            {
                name = name.Remove(name.Length - "Serializer".Length);
            }
            if (name.EndsWith("Decorator"))
            {
                name = name.Remove(name.Length - "Decorator".Length);
            }
            if (name.EndsWith("Value"))
            {
                name = name.Remove(name.Length - "Value".Length);
            }
            if ((name == "Property" || name == "Field") && !string.IsNullOrEmpty(description))
            {
                name = serializer.ExpectedType.Name + "." + description;
            }
            else
            {
                if (!string.Equals(name, serializer.ExpectedType.Name, StringComparison.OrdinalIgnoreCase))
                {
                    name += " : " + serializer.ExpectedType.Name;
                }
                if (!string.IsNullOrEmpty(description))
                {
                    name += " = " + description;
                }
            }
            _sb.AppendLine(name);
        }