예제 #1
0
        private object Deserialize(Type targetType, XmlRpcObjectBase item, PropertyInfo[] properties)
        {
            if (item is XmlRpcStruct strct)
            {
                return(DeserializeStruct(targetType, strct, properties));
            }

            // todo: implement any other types that may be supported like serialize as strings, integers, doubles, etc
            throw new NotImplementedException();

            return(default(object));
        }
예제 #2
0
        private async Task <XmlRpcObject> ApiRequest(string method, params KeyValuePair <string, object>[] arguments)
        {
            Interlocked.Increment(ref totalRequests);
            Interlocked.Increment(ref totalRequestsToday);
            Interlocked.Increment(ref totalRequestsInTimeBlock);

            if (requestBlockTimeLimit == DateTime.MinValue)
            {
                requestBlockTimeLimit = DateTime.Now;
            }

            var url         = isVip ? VipApiUrl : ApiUrl;
            var requestData = BuildRequestData(method, arguments);
            var request     = CreatePostAsync(url, requestData);

            try
            {
                using (var response = await request.GetResponseAsync())
                {
                    if (response.Headers.HasKeys())
                    {
                        var headerKeys = response.Headers.AllKeys;
                        if (headerKeys.Contains("Content-Location"))
                        {
                            isVip = isVip || response.Headers.Get("Content-Location")?.ToLower() ==
                                    "https://vip-api.opensubtitles.org.local/xml-rpc";
                        }

                        if (headerKeys.Contains("Download-Quota"))
                        {
                            if (int.TryParse(response.Headers.Get("Download-Quota"), out var quota))
                            {
                                Volatile.Write(ref downloadQuota, quota);
                            }
                        }
                    }

                    return(XmlRpcObjectBase.Parse(await GetResponseStringAsync(response)));
                }
            }
            catch (Exception exc)
            {
                // for now...
                return(null);
            }
        }
예제 #3
0
 public XmlRpcMember(XmlRpcString name, XmlRpcObjectBase value)
 {
     Name  = name;
     Value = value;
 }
예제 #4
0
 public void Add(XmlRpcObjectBase child)
 {
     children.Add(child);
 }
예제 #5
0
 internal void Add(XmlRpcObjectBase child)
 {
     children.Add(child);
 }