protected SynologyRequest(SynologyApi api) { Api = api; //Fixed possible loop for LoadInfo if (ApiName == "SYNO.API.Info") { CgiPath = "query.cgi"; } else { //Request and Method returns null if the API or the Method is not found. var data = Api.Connection.Request("SYNO.API.Info")?.Method <Dictionary <string, IApiInfo> >("query", ApiName); //Request and Method returns null if the API or the Method is not found. //If the Info API has returned a value and contains the current API Info, this update the associated cgi. if (data != null && data.Data.ContainsKey(ApiName)) { CgiPath = data.Data[ApiName].Path; } else { throw new Exception("The API cannot be found on this Synology. Check if RequestAttribute exists on the relative SynologyRequest subclass or the SYNO.API.Info result."); } } Api.Connection.Logger.LogDebug($"Created request {ApiName} to path {CgiPath}"); }
protected SynologyRequest(SynologyApi parentApi, string cgiPath, string api) { Api = parentApi; CgiPath = cgiPath; ApiName = $"SYNO.{api}"; LoadInfo(); }
protected SynologyRequest(SynologyApi api) { Api = api; var ty = GetType(); var res = new List <string>(); while (ty != null) { var ta = ty.GetCustomAttribute(typeof(RequestAttribute)) as RequestAttribute; if (ta != null) { res.Insert(0, ta.Name); } ty = ty.BaseType; } ApiName = string.Join(".", res); //Fixed possible loop for LoadInfo if (ApiName == "SYNO.API.Info") { CgiPath = "query.cgi"; } else { //Request and Method returns null if the API or the Method is not found. var data = Api.Connection.Request("SYNO.API.Info")?.Method <Dictionary <string, ApiInfo> >("query", ApiName); //Request and Method returns null if the API or the Method is not found. //If the Info API has returned a value and contains the current API Info, this update the associated cgi. if (data != null && data.Data.ContainsKey(ApiName)) { CgiPath = data.Data[ApiName].Path; } else { throw new Exception("The API cannot be found on this Synology. Check if RequestAttribute exists on the relative SynologyRequest subclass or the SYNO.API.Info result."); } } Api.Connection.Logger.Debug($"Created request {ApiName} to path {CgiPath}"); }