Exemplo n.º 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;
        }
Exemplo n.º 2
0
 /// <summary>
 /// register api object
 /// </summary>
 /// <param name="apiObject">api object</param>
 public static void RegisterApiObject(ApiObject apiObject)
 {
     if (apiObject == null || apiObject.Name.IsNullOrEmpty() || apiObject.Servers.IsNullOrEmpty() || apiObject.Endpoints.IsNullOrEmpty())
     {
         return;
     }
     ApiObjects[apiObject.Name] = apiObject;
     foreach (var endpoint in apiObject.Endpoints)
     {
         string formatKey = GetApiObjectAndEndpointFormatKey(apiObject.Name, endpoint.Name);
         EndpointCollection[formatKey] = endpoint;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// register api server
 /// </summary>
 /// <param name="apiObjectName">api object name</param>
 /// <param name="server">api server</param>
 public static void RegisterServer(string apiObjectName, ApiServer server)
 {
     if (apiObjectName.IsNullOrEmpty() || server == null)
     {
         return;
     }
     if (!ApiObjects.TryGetValue(apiObjectName, out var nowApiGroup) || nowApiGroup == null)
     {
         ApiObjects[apiObjectName] = new ApiObject()
         {
             Name      = apiObjectName,
             Endpoints = new List <ApiEndpoint>(),
             Servers   = new List <ApiServer>()
             {
                 server
             }
         };
     }
     else
     {
         nowApiGroup.Servers.Add(server);
     }
 }