コード例 #1
0
        //Patches a method name for the exceptions (IndicesStats needs better unique names for all the url endpoints)
        //or to get rid of double verbs in an method name i,e ClusterGetSettingsGet > ClusterGetSettings
        public static void PatchMethod(CsharpMethod method)
        {
            if (method.FullName.StartsWith("IndicesStats") && method.Path.Contains("{index}"))
            {
                method.FullName = method.FullName.Replace("IndicesStats", "IndexStats");
            }
            //IndicesPutAliasPutAsync
            if (method.FullName.StartsWith("IndicesPutAlias") && method.Path.Contains("{index}"))
            {
                method.FullName = method.FullName.Replace("IndicesPutAlias", "IndexPutAlias");
            }

            if (method.FullName.StartsWith("IndicesStats") || method.FullName.StartsWith("IndexStats"))
            {
                if (method.Path.Contains("/indexing/"))
                {
                    method.FullName = method.FullName.Replace("Stats", "IndexingStats");
                }
                if (method.Path.Contains("/search/"))
                {
                    method.FullName = method.FullName.Replace("Stats", "SearchStats");
                }
                if (method.Path.Contains("/fielddata/"))
                {
                    method.FullName = method.FullName.Replace("Stats", "FieldDataStats");
                }
            }
            //remove duplicate occurance of the HTTP method name
            var m = method.HttpMethod.ToPascalCase();

            method.FullName =
                Regex.Replace(method.FullName, m, (a) => a.Index != method.FullName.IndexOf(m) ? "" : m);
        }
コード例 #2
0
        //Patches a method name for the exceptions (IndicesStats needs better unique names for all the url endpoints)
        //or to get rid of double verbs in an method name i,e ClusterGetSettingsGet > ClusterGetSettings
        public static void PatchMethod(CsharpMethod method)
        {
            if (method.FullName.StartsWith("IndicesStats") && method.Path.Contains("{index}"))
                method.FullName = method.FullName.Replace("IndicesStats", "IndexStats");
            //IndicesPutAliasPutAsync
            if (method.FullName.StartsWith("IndicesPutAlias") && method.Path.Contains("{index}"))
                method.FullName = method.FullName.Replace("IndicesPutAlias", "IndexPutAlias");

            if (method.FullName.StartsWith("IndicesStats") || method.FullName.StartsWith("IndexStats"))
            {
                if (method.Path.Contains("/indexing/"))
                    method.FullName = method.FullName.Replace("Stats", "IndexingStats");
                if (method.Path.Contains("/search/"))
                    method.FullName = method.FullName.Replace("Stats", "SearchStats");
                if (method.Path.Contains("/fielddata/"))
                    method.FullName = method.FullName.Replace("Stats", "FieldDataStats");
            }

            //remove duplicate occurance of the HTTP method name
            var m = method.HttpMethod.ToPascalCase();
            method.FullName =
                Regex.Replace(method.FullName, m, (a) => a.Index != method.FullName.IndexOf(m) ? "" : m);

            string manualOverride;
            var key = method.QueryStringParamName.Replace("QueryString", "");
            if (MethodNameOverrides.TryGetValue(key, out manualOverride))
                method.QueryStringParamName = manualOverride + "QueryString";

            method.DescriptorType = method.QueryStringParamName.Replace("QueryString","Descriptor");

            string generic;
            if (KnownDescriptors.TryGetValue(method.DescriptorType, out generic))
                method.DescriptorTypeGeneric = generic;

            try
            {
                var typeName = "RawClientGenerator.Overrides.Descriptors." + method.DescriptorType + "Overrides";
                var type = _assembly.GetType(typeName);
                if (type == null)
                    return;
                var overrides = Activator.CreateInstance(type) as IDescriptorOverrides;
                if (overrides == null)
                    return;
                method.Url.Params = method.Url.Params.Where(p => !overrides.SkipQueryStringParams.Contains(p.Key))
                    .ToDictionary(k => k.Key, v => v.Value);
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch (Exception e)
            {
            }
        }
コード例 #3
0
ファイル: ApiGenerator.cs プロジェクト: nickcanz/NEST
        //Patches a method name for the exceptions (IndicesStats needs better unique names for all the url endpoints)
        //or to get rid of double verbs in an method name i,e ClusterGetSettingsGet > ClusterGetSettings
        public static void PatchMethod(CsharpMethod method)
        {
            if (method.FullName.StartsWith("IndicesStats") && method.Path.Contains("{index}"))
                method.FullName = method.FullName.Replace("IndicesStats", "IndexStats");
            //IndicesPutAliasPutAsync
            if (method.FullName.StartsWith("IndicesPutAlias") && method.Path.Contains("{index}"))
                method.FullName = method.FullName.Replace("IndicesPutAlias", "IndexPutAlias");

            if (method.FullName.StartsWith("IndicesStats") || method.FullName.StartsWith("IndexStats"))
            {
                if (method.Path.Contains("/indexing/"))
                    method.FullName = method.FullName.Replace("Stats", "IndexingStats");
                if (method.Path.Contains("/search/"))
                    method.FullName = method.FullName.Replace("Stats", "SearchStats");
                if (method.Path.Contains("/fielddata/"))
                    method.FullName = method.FullName.Replace("Stats", "FieldDataStats");
            }
            //remove duplicate occurance of the HTTP method name
            var m = method.HttpMethod.ToPascalCase();
            method.FullName =
                Regex.Replace(method.FullName, m, (a) => a.Index != method.FullName.IndexOf(m) ? "" : m);
        }