示例#1
0
        private static string PolicyDirectTypeName(Type type) => type.Name; // deliberately taking the short, easier for a resharper unit to add than subtract.

        public static string GetTypeLiteral(Type type) =>
        PolicyDirectTypeName(type).Let(
            rawName =>
            type.IsGenericType
                        ? rawName.Substring(0, rawName.IndexOf('`')) + Braced("<", ">")(MergedStrings(Intersperse(",", type.GetGenericArguments().Select(GetTypeLiteral))))
                        : new Dictionary <string, string>
        {
            { "String", "string" }
        }.Let(d =>
              d.GetValueIfPresent(rawName).Match(x => x, () => rawName)));
示例#2
0
 public static string Quoted(string str) => Braced("\"", "\"")(str.Replace("\"", "\\\""));