Rev | Line | |
---|
[1658] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace HeuristicLab.Persistence.GUI {
|
---|
| 7 |
|
---|
| 8 | internal static class TypeExtensions {
|
---|
| 9 |
|
---|
| 10 | public static string SimpleFullName(this Type type) {
|
---|
| 11 | StringBuilder sb = new StringBuilder();
|
---|
| 12 | SimpleFullName(type, sb);
|
---|
| 13 | return sb.ToString();
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | private static void SimpleFullName(Type type, StringBuilder sb) {
|
---|
| 17 | if (type.IsGenericType) {
|
---|
| 18 | sb.Append(type.Name, 0, type.Name.LastIndexOf('`'));
|
---|
| 19 | sb.Append("<");
|
---|
| 20 | foreach (Type t in type.GetGenericArguments()) {
|
---|
| 21 | SimpleFullName(t, sb);
|
---|
| 22 | sb.Append(", ");
|
---|
| 23 | }
|
---|
| 24 | sb.Remove(sb.Length - 2, 2);
|
---|
| 25 | sb.Append(">");
|
---|
| 26 | } else {
|
---|
| 27 | sb.Append(type.Name);
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.