Example #1
0
        /// <summary>
        /// register api endpoint
        /// </summary>
        /// <param name="apiObjectName">api object name</param>
        /// <param name="endpoint">api endpoint</param>
        public static void RegisterEndpoint(string apiObjectName, ApiEndpoint endpoint)
        {
            if (apiObjectName.IsNullOrEmpty() || endpoint == null)
            {
                return;
            }
            if (!ApiObjects.TryGetValue(apiObjectName, out var nowApiGroup) || nowApiGroup == null)
            {
                ApiObjects[apiObjectName] = new ApiObject()
                {
                    Name      = apiObjectName,
                    Endpoints = new List <ApiEndpoint>()
                    {
                        endpoint
                    },
                    Servers = new List <ApiServer>()
                };
            }
            else
            {
                nowApiGroup.Endpoints.Add(endpoint);
            }
            string formatKey = GetApiObjectAndEndpointFormatKey(apiObjectName, endpoint.Name);

            EndpointCollection[formatKey] = endpoint;
        }
Example #2
0
 /// <summary>
 /// get endpoint path
 /// </summary>
 /// <param name="endpoint">api endpoint</param>
 /// <returns></returns>
 public string GetEndpointPath(ApiEndpoint endpoint)
 {
     if (endpoint == null)
     {
         return(string.Empty);
     }
     return(GetEndpointPath(endpoint.Path));
 }