Esempio n. 1
0
        private TmfParser(string tmfFile)
        {
            _reader = File.OpenText(tmfFile);
            _reader.ReadLine(); //PDB:  e:\lcsrgs.obj.amd64chk\rgs\dev\...\microsoft.rtc.rgs.clients.pdb
            _reader.ReadLine(); //PDB:  Last Updated :2012-5-4:12:51:1:778 (UTC) [ManagedWPP]

            string line = _reader.ReadLine();

            Match m = _header.Match(line);

            if (!m.Success)
            {
                throw new Exception("failed to match the header line in file " + tmfFile);
            }
            // the expected format is like
            // f73bbb29-e2f0-93e7-ee22-e396f8fe1570 RgsClientsLib // SRC=matchmakinglocator.cs MJ= MN=

            _providerId    = m.Groups[1].Value;
            _componentName = m.Groups[2].Value;
            _srcfile       = m.Groups[3].Value
                             .Replace('-', '_')
                             .Replace('.', '_');

            _sb = new StringBuilder(
                @"// 
//    This code was generated by EtwEventTypeGen.exe 
//

using System;

");
            _sb.Append("namespace Microsoft.Etw.");
            _sb.Append(_provider.CreateValidIdentifier(_componentName));
            _sb.Append('.');
            _sb.AppendLine(_srcfile.Replace('.', '_'));
            _sb.AppendLine("{");

            while (true)
            {
                if (!ReadEvent())
                {
                    break;
                }
            }
            _sb.AppendLine("    }");
            _sb.AppendLine("}");

            _code = _sb.ToString();
        }
Esempio n. 2
0
 public static string GenerateValidIdentifier(string token)
 {
     using (var code = new CSharpCodeProvider())
     {
         return(code.CreateValidIdentifier(token));
     }
 }
Esempio n. 3
0
        public static string ValidClassName(string name)
        {
            name = StripNonAlphanumDot(name);
            CSharpCodeProvider codeProvider = new CSharpCodeProvider();

            return(codeProvider.CreateValidIdentifier(name));
        }
        private static string GetValidIdentifier(string name)
        {
            string newName = name.Replace("-", "_");

            newName = provider.CreateValidIdentifier(newName);
            return(newName);
        }
Esempio n. 5
0
        /*
         * =========================================================================
         *  Functions
         * =========================================================================
         */

        /// <summary>
        /// Creates a valid class name for csharp
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static string normalizeClassName(string filename)
        {
            CSharpCodeProvider codeProvider = new CSharpCodeProvider();

            filename = codeProvider.CreateValidIdentifier(filename);

            return(filename);
        }
Esempio n. 6
0
        static void CacheBinaryReaderMethods()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();
            // get BinaryReader extension methods from the executing assembly
            var extensionMethods = (from type in types
                                    where type.IsSealed && !type.IsGenericType && !type.IsNested
                                    from method in type.GetMethods(BindingFlags.Static
                                                                   | BindingFlags.Public | BindingFlags.NonPublic)
                                    where method.IsDefined(typeof(ExtensionAttribute), false)
                                    where method.GetParameters()[0].ParameterType == typeof(BinaryReader)
                                    select new { method = method, type = method.ReturnType }).ToList();

            // trim this down further to one of each return type
            extensionMethods = (from method in extensionMethods
                                group method by method.type into g
                                select g.First()).ToList();

            using (var provider = new CSharpCodeProvider())
            {
                var test = provider.CreateValidIdentifier(typeof(int).ToString());
                var binaryReaderMethods = (from method in typeof(BinaryReader).GetMethods()
                                           where method.ReturnType != typeof(void)
                                           select new { method = method, type = method.ReturnType }).ToList().Where(x =>
                {
                    var typeString = provider.CreateValidIdentifier((x.type).ToString());
                    typeString     = typeString.Split('.').Last();
                    return(x.method.Name.ToLower().Contains(typeString.ToLower()));
                }).ToList();


                binaryReaderMethods = (from method in binaryReaderMethods
                                       group method by method.type into g
                                       select g.First()).ToList();

                var totalMethods = binaryReaderMethods.Union(extensionMethods);
                Methods = new Dictionary <Type, string>(totalMethods.Count());
                foreach (var item in totalMethods)
                {
                    Methods[item.type] = item.method.Name;
                }
            }
        }
Esempio n. 7
0
 protected static string ValidateFieldName(string fieldName)
 {
     using (var provider = new CSharpCodeProvider())
     {
         if (!provider.IsValidIdentifier(fieldName))
         {
             var huh = provider.CreateValidIdentifier(fieldName);
             fieldName = string.Format("invalidName_{0}", fieldName);
         }
     }
     return(fieldName);
 }
Esempio n. 8
0
        public static string CreateIdentifier(string s)
        {
            char[] chars = s.ToCharArray();
            for (int i = 0; i < chars.Length; i++)
            {
                if (!char.IsLetterOrDigit(chars[i]))
                {
                    chars[i] = '_';
                }
            }

            return(_provider.CreateValidIdentifier(new string(chars)));
        }
Esempio n. 9
0
        public void GeneratedCodeNamespaceProviderKeywords()
        {
            string expected;

            string []       unmatchables;
            CodeCompileUnit ccu;

            foreach (string input in keywords)
            {
                ccu = StronglyTypedResourceBuilder.Create(testResources,
                                                          "TestClass",
                                                          input,
                                                          "TestResourcesNameSpace",
                                                          provider,
                                                          true,
                                                          out unmatchables);

                expected = provider.CreateValidIdentifier(input);

                Assert.AreEqual(expected, ccu.Namespaces [0].Name);
            }
        }
Esempio n. 10
0
 public MoonfishTagDefinition(string displayName, IEnumerable <MoonfishTagField> fieldList)
     : this()
 {
     DisplayName = displayName;
     using (var cSharpCode = new CSharpCodeProvider())
     {
         var token = displayName;
         token = new string(token.ToCharArray().Where(char.IsLetterOrDigit).ToArray());
         token = cSharpCode.CreateValidIdentifier(token);
         Name  = token;
     }
     Fields = new List <MoonfishTagField>(fieldList);
 }
        public void VerifyResourceNameProviderKeywords()
        {
            // not complete list, doesnt really need to be
            string expected, output;

            foreach (string input in keywords)
            {
                output = StronglyTypedResourceBuilder.VerifyResourceName(input, provider);

                expected = provider.CreateValidIdentifier(input);

                Assert.AreEqual(expected, output);
            }
        }
Esempio n. 12
0
        private static List <MethodInfo> FindAllMethods <T>()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();
            // get BinaryReader extension methods from the executing assembly
            var extensionMethods = (from type in types
                                    where type.IsSealed && !type.IsGenericType && !type.IsNested
                                    from method in type.GetMethods(BindingFlags.Static
                                                                   | BindingFlags.Public | BindingFlags.NonPublic)
                                    where method.IsDefined(typeof(ExtensionAttribute), false)
                                    where method.GetParameters()[0].ParameterType == typeof(T)
                                    select method).ToList();

            // trim this down further to one of each return type
            extensionMethods = (from method in extensionMethods
                                group method by method.ReturnType
                                into g
                                select g.First()).ToList();

            var provider = new CSharpCodeProvider();

            var methods = (from method in typeof(T).GetMethods()
                           where method.ReturnType != typeof(void)
                           select method).Where(x =>
            {
                var typeString = provider.CreateValidIdentifier((x.ReturnType).ToString());
                typeString     = typeString.Split('.').Last();
                return(x.Name.ToLower().Contains(typeString.ToLower()));
            }).ToList();

            methods = (from method in methods
                       group method by method.ReturnType
                       into g
                       select g.First()).ToList();
            var totalMethods = methods.Union(extensionMethods).ToList();

            provider.Dispose();
            return(totalMethods);
        }
Esempio n. 13
0
        public void BaseNameKeywords()
        {
            // provider.CreateValidIdentifier used to return valid identifier
            string expected;

            string []       unmatchables;
            CodeCompileUnit ccu;

            foreach (string input in keywords)
            {
                ccu = StronglyTypedResourceBuilder.Create(testResources,
                                                          input,
                                                          "TestNamespace",
                                                          "TestResourcesNameSpace",
                                                          provider,
                                                          true,
                                                          out unmatchables);

                expected = provider.CreateValidIdentifier(input);

                Assert.AreEqual(expected, ccu.Namespaces [0].Types [0].Name);
            }
        }
 public static string SafeName(string name)
 {
     try
     {
         if (name == null)
         {
             return(string.Empty);
         }
         if (Guid.TryParse(name, out var outputGuid) || (name.Length > 38 && Guid.TryParse(name.Substring(0, 38), out var outputGuid2)))
         {
             name = name.ToUpper()
                    .Replace("-", "_")
                    .Replace("{", string.Empty)
                    .Replace("}", string.Empty);
             return("_" + name);
         }
         name = name.Replace(" ", "_");
         name = name.Replace("~", string.Empty);
         name = name.Replace("`", string.Empty);
         name = name.Replace("!", string.Empty);
         name = name.Replace("@", string.Empty);
         name = name.Replace("#", string.Empty);
         name = name.Replace("$", string.Empty);
         name = name.Replace("%", string.Empty);
         name = name.Replace("^", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("|", string.Empty);
         name = name.Replace("*", string.Empty);
         name = name.Replace("(", string.Empty);
         name = name.Replace(")", string.Empty);
         name = name.Replace("-", "_");
         name = name.Replace("{", string.Empty);
         name = name.Replace("}", string.Empty);
         name = name.Replace("[", string.Empty);
         name = name.Replace("]", string.Empty);
         name = name.Replace("\"", string.Empty);
         name = name.Replace("'", string.Empty);
         name = name.Replace(":", string.Empty);
         name = name.Replace(";", string.Empty);
         name = name.Replace("<", string.Empty);
         name = name.Replace(",", string.Empty);
         name = name.Replace(">", string.Empty);
         name = name.Replace(".", string.Empty);
         name = name.Replace("?", string.Empty);
         name = name.Replace("/", string.Empty);
         name = name.Replace("+", string.Empty);
         name = name.Replace("=", string.Empty);
         name = name.Replace("–", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("%", string.Empty);
         name = name.Replace("\t", string.Empty);
         name = name.Replace("___", "_");
         name = name.Replace("__", "_");
         var firstchar = name[0];
         if (firstchar >= '0' && firstchar <= '9')
         {
             name = "_" + name;
         }
         var cs = new CSharpCodeProvider();
         name = cs.CreateValidIdentifier(name);
         return(name);
     }
     catch
     {
         return("_");
     }
 }
Esempio n. 15
0
 public static string SafeName(string name)
 {
     try
     {
         if (name == null)
         {
             return(string.Empty);
         }
         if (Guid.TryParse(name, out var outputGuid) || (name.Length > 38 && Guid.TryParse(name.Substring(0, 38), out var outputGuid2)))
         {
             name = name.ToUpper()
                    .Replace("-", "_")
                    .Replace("{", string.Empty)
                    .Replace("}", string.Empty);
             return("_" + name);
         }
         name = name.Replace(" ", "_");
         name = name.Replace("~", string.Empty);
         name = name.Replace("`", string.Empty);
         name = name.Replace("!", string.Empty);
         name = name.Replace("@", string.Empty);
         name = name.Replace("#", string.Empty);
         name = name.Replace("$", string.Empty);
         name = name.Replace("%", string.Empty);
         name = name.Replace("^", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("|", string.Empty);
         name = name.Replace("*", string.Empty);
         name = name.Replace("(", string.Empty);
         name = name.Replace(")", string.Empty);
         name = name.Replace("-", "_");
         name = name.Replace("{", string.Empty);
         name = name.Replace("}", string.Empty);
         name = name.Replace("[", string.Empty);
         name = name.Replace("]", string.Empty);
         name = name.Replace("\"", string.Empty);
         name = name.Replace("'", string.Empty);
         name = name.Replace("’", string.Empty);
         name = name.Replace(":", string.Empty);
         name = name.Replace(";", string.Empty);
         name = name.Replace("<", string.Empty);
         name = name.Replace(",", string.Empty);
         name = name.Replace(">", string.Empty);
         name = name.Replace(".", string.Empty);
         name = name.Replace("?", string.Empty);
         name = name.Replace("/", string.Empty);
         name = name.Replace("+", string.Empty);
         name = name.Replace("=", string.Empty);
         name = name.Replace("–", string.Empty);
         name = name.Replace("&", string.Empty);
         name = name.Replace("%", string.Empty);
         name = name.Replace("\t", string.Empty);
         name = name.Replace("___", "_");
         name = name.Replace("__", "_");
         var firstchar = name[0];
         if (firstchar >= '0' && firstchar <= '9')
         {
             name = "_" + name;
         }
         name = string.Concat(name.Normalize(NormalizationForm.FormD).Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark)).Normalize(NormalizationForm.FormC);
         var cs = new CSharpCodeProvider();
         name = cs.CreateValidIdentifier(name);
         return(name);
     }
     catch
     {
         return("_");
     }
 }
Esempio n. 16
0
        private ListFilter <T> Compile()
        {
            var            uniqueCode = GetUniqueCode();
            ListFilter <T> resultFilter;

            if (!FiltersCache.TryGetValue(uniqueCode, out resultFilter))
            {
                var includeAssemblies = new HashSet <string>();

                var provider = new CSharpCodeProvider(new Dictionary <string, string>()
                {
                    { "CompilerVersion", "v3.5" }
                });

                var name = "Filter";
                if (FilterBy != null)
                {
                    name += "_" + Regex.Replace(FilterBy, @"\W", "");
                }
                if (SortFields != null)
                {
                    name += "_Sort_" + Regex.Replace(SortFields.Aggregate((y, x) => y), @"\W", "");
                }
                var typeName = provider.CreateValidIdentifier(name);


                var targetTypeName = typeof(T).FullName.Replace('+', '.');
                var code           = new StringBuilder();
                code.AppendLine("using System;");
                code.AppendLine("using System.Collections;");
                code.AppendLine("using System.Collections.Generic;");
                code.AppendLine("using System.Linq;");
                code.AppendLine("using ASC.Api.Collections;");
                code.AppendLine("using System.Globalization;");

                code.AppendFormat("public class {1} : ListFilter<{0}> {{\r\n", targetTypeName, typeName);
                code.AppendFormat(
                    "    public override IEnumerable<{0}> FilterList(IEnumerable<{0}> items, bool sortDescending, FilterOperation operation, string[] filterValues){{\r\n",
                    targetTypeName);
                //Do a needed operations

                //TODO: Do a null checks!
                if (ShouldFilter())
                {
                    try
                    {
                        var filters      = FilterBy.Split(',');
                        var filterChecks = new List <string>();
                        foreach (var filter in filters)
                        {
                            var propInfo = GetPropertyInfo(filter).Where(x => x != null).ToList();
                            foreach (var propertyInfo in propInfo)
                            {
                                includeAssemblies.Add(propertyInfo.PropertyType.Assembly.Location);
                            }

                            var byProperty = GetPropertyPath(propInfo);

                            var nullCheck = GetNullCheck("item", propInfo);


                            filterChecks.Add(string.Format("({1}Satisfy(operation, filterValues, item.{0}{2}))",
                                                           byProperty,
                                                           string.IsNullOrEmpty(nullCheck) ? "" : (nullCheck + " && "),
                                                           GetPropertyToString(propInfo.Last())));
                        }
                        code.AppendFormat(
                            "items = items.Where(item =>{0});\r\n", string.Join(" || ", filterChecks.ToArray()));
                    }
                    catch (Exception)
                    {
                    }
                }
                if (ShouldSort())
                {
                    var propInfo = SortFields.Select(x => GetPropertyInfo(x)).Where(x => x != null).ToList();
                    //Add where
                    if (propInfo.Any())
                    {
                        foreach (var info in propInfo)
                        {
                            foreach (var propertyInfo in info)
                            {
                                includeAssemblies.Add(propertyInfo.PropertyType.Assembly.Location);
                            }

                            var nullCheck = GetNullCheck("item", info);
                            if (!string.IsNullOrEmpty(nullCheck))
                            {
                                code.AppendFormat("items=items.Where(item=>{0});", nullCheck);
                                code.AppendLine();
                            }
                        }

                        var byProperties = propInfo.Select(x => GetPropertyPath(x)).ToList();
                        code.AppendLine("items = sortDescending");
                        code.AppendFormat("?items.OrderByDescending(item => item.{0})", byProperties.First());
                        foreach (var byProperty in byProperties.Skip(1))
                        {
                            code.AppendFormat(".ThenByDescending(item => item.{0})", byProperty);
                        }

                        code.AppendFormat(": items.OrderBy(item => item.{0})", byProperties.First());
                        foreach (var byProperty in byProperties.Skip(1))
                        {
                            code.AppendFormat(".ThenBy(item => item.{0})", byProperty);
                        }
                        code.AppendLine(";");
                    }
                }

                code.AppendFormat("return items;\r\n");
                code.AppendLine("} }");

                var assemblyName = "filter" + Guid.NewGuid().ToString("N");
                var cp           = new CompilerParameters
                {
                    GenerateExecutable      = false,
                    OutputAssembly          = assemblyName,
                    GenerateInMemory        = true,
                    TreatWarningsAsErrors   = false,
                    CompilerOptions         = "/optimize /t:library",
                    IncludeDebugInformation = false,
                };

                cp.ReferencedAssemblies.Add("mscorlib.dll");
                cp.ReferencedAssemblies.Add("system.dll");
                cp.ReferencedAssemblies.Add("System.Core.dll");
                cp.ReferencedAssemblies.Add(GetType().Assembly.Location);
                cp.ReferencedAssemblies.Add(typeof(T).Assembly.Location);
                foreach (var includeAssembly in includeAssemblies)
                {
                    cp.ReferencedAssemblies.Add(includeAssembly);
                }

                var cr = provider.CompileAssemblyFromSource(cp, code.ToString());
                if (!cr.Errors.HasErrors)
                {
                    var assembly      = cr.CompiledAssembly;
                    var evaluatorType = assembly.GetType(typeName);
                    var evaluator     = Activator.CreateInstance(evaluatorType);
                    resultFilter = evaluator as ListFilter <T>;
                }
                //Add anyway!!!
                FiltersCache.Add(uniqueCode, resultFilter);
            }
            return(resultFilter);
        }
Esempio n. 17
0
 public static string Direct(this string name)
 {
     return(Code.CreateValidIdentifier(name));
 }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 21 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

            var swaggerParser = new SwaggerParser();


            #line default
            #line hidden
            this.Write("using System;\r\nusing System.Collections.Generic;\r\nusing System.Net.Http;\r\nusing S" +
                       "ystem.Threading.Tasks;\r\nusing System.Linq;\r\nusing Newtonsoft.Json;\r\nusing Swagge" +
                       "r2WebApiClient.Infrastructure;\r\nusing Swagger2WebApiClient.Models;\r\nusing ");

            #line 32 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Config.Namespace));

            #line default
            #line hidden
            this.Write(".Models;\r\nusing ");

            #line 33 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Config.Namespace));

            #line default
            #line hidden
            this.Write(".Api;\r\nusing Refit;\r\n#region Models\r\nnamespace ");

            #line 36 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Config.Namespace));

            #line default
            #line hidden
            this.Write(".Models\r\n{\r\n");

            #line 38 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

            var classDefinitions = ProxyDefinition.ClassDefinitions;
            foreach (var classDef in classDefinitions)
            {
                List <EnumDefinition> modelEnums = new List <EnumDefinition>();


            #line default
            #line hidden
                this.Write("\t/// <summary>\r\n\t/// \r\n\t/// </summary>\r\n\tpublic class ");

            #line 47 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(classDef.Name));

            #line default
            #line hidden
                this.Write("  ");

            #line 47 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(string.IsNullOrEmpty(classDef.Inherits) ? string.Empty : string.Format(": {0}", classDef.Inherits)));

            #line default
            #line hidden
                this.Write("\r\n\t{\r\n\t\t");

            #line 49 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

                foreach (var prop in classDef.Properties)
                {
            #line default
            #line hidden
                    this.Write("\r\n\t\tpublic ");

            #line 53 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.TypeName));

            #line default
            #line hidden
                    this.Write(" ");

            #line 53 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(prop.Name));

            #line default
            #line hidden
                    this.Write(" { get; set; }\r\n\t\t");

            #line 54 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

                    if (prop.EnumValues != null)
                    {
                        modelEnums.Add(new EnumDefinition()
                        {
                            Name   = prop.TypeName,
                            Values = prop.EnumValues
                        });
                    }


            #line default
            #line hidden
                    this.Write("\t\t");

            #line 64 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n\t\t");

            #line 66 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                foreach (var modelEnum in modelEnums)
                {
                    var csharpCodeProvider = new CSharpCodeProvider();


            #line default
            #line hidden
                    this.Write("\t\tpublic enum ");

            #line 70 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(csharpCodeProvider.CreateValidIdentifier(modelEnum.Name)));

            #line default
            #line hidden
                    this.Write("\r\n\t\t{\r\n\t\t\t");

            #line 72 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    foreach (var value in modelEnum.Values.Distinct())
                    {
            #line default
            #line hidden
                        this.Write("\t\t\t");

            #line 73 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(swaggerParser.FixTypeName(value)));

            #line default
            #line hidden
                        this.Write(",\r\n\t\t\t");

            #line 74 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("\t\t}\r\n\t\t");

            #line 76 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("    }\r\n");

            #line 78 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            }


            #line default
            #line hidden
            this.Write("\r\n}\r\n\r\n#endregion\r\n\r\n#region ApiClient\r\nnamespace ");

            #line 87 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(Config.Namespace));

            #line default
            #line hidden
            this.Write(".Api{\r\n\r\n");

            #line 89 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

            var proxies = ProxyDefinition.Operations.Select(i => i.ProxyName).Distinct();
            foreach (var proxy in proxies)
            {
            #line default
            #line hidden
                this.Write("\t/// <summary>\r\n\t/// Web Api Client For ");

            #line 95 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(swaggerParser.FixTypeName(proxy)));

            #line default
            #line hidden
                this.Write("\r\n\t/// </summary>\r\n\tpublic interface I");

            #line 97 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(swaggerParser.FixTypeName(proxy)));

            #line default
            #line hidden
                this.Write("WebApi\r\n\t{\r\n\t");

            #line 99 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"

                List <EnumDefinition> proxyParamEnums = new List <EnumDefinition>();
                foreach (var operationDef in ProxyDefinition.Operations.Where(i => i.ProxyName.Equals(proxy)))
                {
                    string returnType = string.IsNullOrEmpty(operationDef.ReturnType) ? "Task" : string.Format("Task<{0}>", operationDef.ReturnType);
                    var    enums      = operationDef.Parameters.Where(i => i.Type.EnumValues != null);
                    if (enums != null)
                    {
                        foreach (var enumParam in enums)
                        {
                            enumParam.Type.TypeName = operationDef.OperationId + enumParam.Type.Name;
                            proxyParamEnums.Add(new EnumDefinition()
                            {
                                Name   = enumParam.Type.TypeName,
                                Values = enumParam.Type.EnumValues
                            });
                        }
                    }
                    operationDef.Parameters = operationDef.Parameters.OrderByDescending(i => i.IsRequired).ToList();
                    string parameters = string.Join(", ", operationDef.Parameters.Select(
                                                        x => (x.IsRequired == false) ? string.Format("{0}{1} {2} = {3}", swaggerParser.GetParameterType(x), swaggerParser.GetDefaultType(x), x.Type.GetCleanName(), swaggerParser.GetDefaultValue(x))
                                                                                 :  string.Format("{0}{1} {2}", swaggerParser.GetParameterType(x), swaggerParser.GetDefaultType(x), x.Type.GetCleanName())));
                    var methodShow = string.Empty;
                    switch (operationDef.Method.ToUpperInvariant())
                    {
                    case "GET":
                        methodShow = "Get";
                        break;

                    case "POST":
                        methodShow = "Post";
                        break;

                    case "DELETE":
                        methodShow = "Delete";
                        break;

                    case "PUT":
                        methodShow = "Put";
                        break;

                    default:
                        break;
                    }



            #line default
            #line hidden
                    this.Write("\t/// <summary>\r\n    /// ");

            #line 142 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operationDef.Description ?? ""));

            #line default
            #line hidden
                    this.Write("\r\n    /// </summary>\r\n\t");

            #line 144 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    foreach (var p in operationDef.Parameters)
                    {
            #line default
            #line hidden
                        this.Write("    /// <param name=\"");

            #line 145 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(p.Type.GetCleanName()));

            #line default
            #line hidden
                        this.Write("\">");

            #line 145 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(p.Description ?? ""));

            #line default
            #line hidden
                        this.Write("</param>\r\n\t");

            #line 146 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    }

            #line default
            #line hidden
                    this.Write("    /// <returns></returns>\r\n\t[");

            #line 148 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(methodShow));

            #line default
            #line hidden
                    this.Write("(\"");

            #line 148 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operationDef.Path));

            #line default
            #line hidden
                    this.Write("\")]\r\n\t");

            #line 149 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(returnType));

            #line default
            #line hidden
                    this.Write("  ");

            #line 149 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(operationDef.OperationId));

            #line default
            #line hidden
                    this.Write("Async(");

            #line 149 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(parameters));

            #line default
            #line hidden
                    this.Write(");\r\n\r\n\t");

            #line 151 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("}\r\n");

            #line 153 "E:\MyWorkSpace\SpringCloudDemo\Swagger2WebApiClient\Templates\ApiClientTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n}\r\n#endregion\r\n\r\n");
            return(this.GenerationEnvironment.ToString());
        }