| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Text; |
| | | 7 | | using System.Xml.Serialization; |
| | | 8 | | using CoreWCF.Runtime; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Xml.Serialization |
| | | 11 | | { |
| | | 12 | | internal class CodeIdentifierEx |
| | | 13 | | { |
| | 0 | 14 | | internal static Func<string, string> GetCSharpName { get; private set; } = GetCSharpNameStub; |
| | 0 | 15 | | internal static Func<Type, string> GetCSharpNameByType { get; private set; } = GetCSharpNameByTypeStub; |
| | | 16 | | |
| | | 17 | | private static string GetCSharpNameStub(string name) |
| | | 18 | | { |
| | 0 | 19 | | var getCSharpNameMethod = typeof(CodeIdentifier).GetMethod("GetCSharpName", new Type[] { typeof(string) }); |
| | | 20 | | Fx.Assert(getCSharpNameMethod != null, "Missing method CodeIdentifier.GetCSharpName(string)"); |
| | 0 | 21 | | GetCSharpName = (Func<string, string>)getCSharpNameMethod.CreateDelegate(typeof(Func<string, string>)); |
| | 0 | 22 | | return GetCSharpName(name); |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | private static string GetCSharpNameByTypeStub(Type type) |
| | | 26 | | { |
| | 0 | 27 | | var getCSharpNameMethod = typeof(CodeIdentifier).GetMethod("GetCSharpName", new Type[] { typeof(Type) }); |
| | | 28 | | Fx.Assert(getCSharpNameMethod != null, "Missing method CodeIdentifier.GetCSharpName(Type)"); |
| | 0 | 29 | | GetCSharpNameByType = (Func<Type, string>)getCSharpNameMethod.CreateDelegate(typeof(Func<Type, string>)); |
| | 0 | 30 | | return GetCSharpNameByType(type); |
| | | 31 | | } |
| | | 32 | | } |
| | | 33 | | } |