/// <summary> /// 构造方法 /// </summary> public SettingJson(IJson json) { this.m_Json = json; this.m_PlayerPrefs = new JsonData(); Load(); }
/// <summary> /// Get the result of the request in the form of IJson. /// </summary> /// <param name="url">Request url</param> /// <param name="paramsDic">Parameter dictionary</param> /// <param name="addVerification">Add verification sign for parameters</param> /// <returns>IJson result</returns> public static IJson GetJsonResult(string url, Dictionary <string, string> paramsDic, bool addVerification) { string result = GetTextResult(url, paramsDic, addVerification); IJson json = JsonParser.Parse(result); return(json); }
public ServiceBusQueue( string connectionString, IJson json) { this.connectionString = connectionString; this.json = json; }
public RedisCache( ConnectionMultiplexer client, IJson json) { this.client = client; this.json = json; }
/// <summary> /// Initialize a new login. /// </summary> /// <returns>Successful</returns> public bool Init() { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://passport.bilibili.com/qrcode/getLoginUrl"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string result = reader.ReadToEnd(); reader.Close(); response.Close(); dataStream.Close(); IJson getLoginUrl = JsonParser.Parse(result); LoginUrlRecieved?.Invoke(this, getLoginUrl.GetValue("data").GetValue("url").ToString()); Bitmap qrBitmap = RenderQrCode(getLoginUrl.GetValue("data").GetValue("url").ToString()); QRImageLoaded?.Invoke(this, qrBitmap); oauthKey = getLoginUrl.GetValue("data").GetValue("oauthKey").ToString(); return(true); } catch (WebException ex) { ConnectionFailed?.Invoke(this, ex); return(false); } }
/// <summary> /// Get infos of a video/season. /// </summary> /// <param name="id">Aid/Season-id</param> /// <param name="isSeason">IsSeason</param> /// <returns>Video info</returns> public static VideoInfo GetInfo(uint id, bool isSeason) { if (!isSeason) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("aid", id.ToString()); try { IJson json = BiliApi.GetJsonResult("https://api.bilibili.com/x/web-interface/view", dic, false); return(new VideoInfo(json.GetValue("data"), isSeason)); } catch (System.Net.WebException) { return(null); } } else { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("season_id", id.ToString()); try { IJson json = BiliApi.GetJsonResult("https://bangumi.bilibili.com/view/web_api/season", dic, false); if (json.GetValue("code").ToLong() == 0) { return(new VideoInfo(json.GetValue("result"), isSeason)); } return(null); } catch (System.Net.WebException) { return(null); } } }
public DictaatFactory(ConfigVariables configVariables, Core.IDirectory directory, Core.IFile file, Core.IJson json) { _directory = directory; _pathHelper = new PathHelper(configVariables); _menuFactory = new MenuFactory(configVariables, file); _json = json; }
public JsonImportPersonRepo(IConfig config, IJson json) { Guard.NotNull(() => config, config); Guard.NotNull(() => json, json); _config = config; _json = json; }
public SubmitController(HostProxyService hostProxyService, BatchService batchService, IJson json, ILogger <SubmitController> logger) { _hostProxyService = hostProxyService; _batchService = batchService; _json = json; _logger = logger; }
/// <summary> /// Validate <paramref name="instance" /> against <paramref /// name="schema" />, returning a list of validation errors. /// </summary> /// /// <remarks> /// <para> /// This method implements JSON Type Definition validation. The precise /// set of validation errors returned are those prescribed by the JSON /// Type Definition specification. The order of the validation errors is /// not meaningful. /// </para> /// /// <para> /// If <paramref name="schema" /> is not a correct schema (that is, its /// <see cref="Schema.Verify" /> raises an exception), then the behavior /// of this method is undefined. /// </para> /// </remarks> /// /// <param name="schema">The schema to validate against.</param> /// /// <param name="instance">The instance ("input") to validate.</param> /// /// <returns> /// <para> /// A list of validation errors, indicating parts of <paramref /// name="instance" /> that <paramref name="schema" /> rejected. This /// list will be empty if there are no validation errors. /// </para> /// /// <para> /// If <see cref="MaxErrors" /> is nonzero, then no more than <see /// cref="MaxErrors" /> errors are returned. Otherwise, all errors are /// returned. /// </para> /// </returns> /// /// <exception cref="MaxDepthExceededException"> /// If <see cref="MaxDepth" /> is nonzero, and validation runs into a /// chain of <c>ref</c>s deeper than the value of <see cref="MaxDepth" /// />. /// </exception> public IList <ValidationError> Validate(Schema schema, IJson instance) { ValidationState state = new ValidationState { Root = schema, InstanceTokens = new List <string>(), SchemaTokens = new List <List <string> >() { new List <string>() }, Errors = new List <ValidationError>(), MaxErrors = MaxErrors, }; try { validate(state, schema, instance); } catch (MaxErrorsReachedException) { // This is a dummy error. We should swallow this, and just // returned the abridged set of errors. } return(state.Errors); }
public AzureResourceGroupClient( HttpClient client, IHttp http, IJson json, IOptions <AzureOptions> azureOptions, ILogger <AzureResourceGroupClient> log) : base(client, http, json, log) { _azureOptions = azureOptions.Value; }
public string GetLatestDownloadUrl() { while (true) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/xuan525/Bili-dl/releases/latest"); request.Accept = "application/vnd.github.v3+json"; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string result = reader.ReadToEnd(); reader.Close(); response.Close(); dataStream.Close(); IJson json = JsonParser.Parse(result); string url = json.GetValue("assets").GetValue(0).GetValue("browser_download_url").ToString(); return(url); } catch (WebException) { Thread.Sleep(5000); } } }
public bool IsLatestVersion() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/xuan525/Bili-dl/releases/latest"); request.Accept = "application/vnd.github.v3+json"; request.UserAgent = "Bili-dl"; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string result = reader.ReadToEnd(); reader.Close(); response.Close(); dataStream.Close(); IJson json = JsonParser.Parse(result); string latestTag = json.GetValue("tag_name").ToString(); return(Application.Current.FindResource("Version").ToString() == latestTag); } catch { return(true); } }
public SeasonSuggest(IJson item) { Position = (uint)(item.GetValue("position").ToLong()); if (item.Contains("title")) { Title = item.GetValue("title").ToString(); } else { Title = null; } Keyword = item.GetValue("keyword").ToString(); Cover = Regex.Unescape("https:" + item.GetValue("Cover").ToString()); Uri = Regex.Unescape(item.GetValue("uri").ToString()); Ptime = item.GetValue("ptime").ToLong(); SeasonTypeName = item.GetValue("season_type_name").ToString(); Area = item.GetValue("area").ToString(); if (item.Contains("label")) { Label = item.GetValue("label").ToString(); } else { Label = null; } }
public Http( IHttpClientFactory factory, IJson json) { this.factory = factory; this.json = json; }
public PredictService(IOption option, ILogger <PredictService> logger, IJson json) { _option = option; _logger = logger; _json = json; _limit = new SemaphoreSlim(_option.MaxRequests); }
public bool IsLatestVersion() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/xuan525/OriginReportTools/releases/latest"); request.Accept = "application/vnd.github.v3+json"; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"; try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string result = reader.ReadToEnd(); reader.Close(); response.Close(); dataStream.Close(); IJson json = JsonParser.Parse(result); string latestTag = json.GetValue("tag_name").ToString(); return(Application.Current.FindResource("Version").ToString() == latestTag); } catch { return(true); } }
protected AzureClient(HttpClient client, IHttp http, IJson json, ILogger log) { Client = client; Http = http; Json = json; Log = log; }
public TerrainManager( IJson json ) { _json = json; _terrain = new Dictionary <int, Terrain>(); }
/// <summary> /// 输出Json文本到客户端 /// </summary> /// <param name="Response"></param> /// <param name="json"></param> public static void WriteJson(this HttpResponseBase Response, IJson json) { Response.ContentType = "application/json"; Response.ClearContent(); Response.BinaryWrite(Encoding.UTF8.GetBytes(json.ToString())); Response.Flush(); }
public static T ReadAndDeserialize <T>(this string file, IJson json) { file.VerifyNotEmpty(nameof(file)); json.VerifyNotNull(nameof(json)); return(json.Deserialize <T>(File.ReadAllText(file))); }
public void LoadAsync() { if (cancellationTokenSource != null) { cancellationTokenSource.Cancel(); } ContentViewer.ScrollToHome(); ContentPanel.Children.Clear(); cancellationTokenSource = new CancellationTokenSource(); CancellationToken cancellationToken = cancellationTokenSource.Token; LoadingPrompt.Visibility = Visibility.Visible; PagesBox.Visibility = Visibility.Hidden; Task task = new Task(() => { IJson userinfo = BiliApi.GetJsonResult("https://api.bilibili.com/x/web-interface/nav", null, false); if (cancellationToken.IsCancellationRequested) { return; } if (userinfo.GetValue("code").ToLong() == 0) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("mid", userinfo.GetValue("data").GetValue("mid").ToLong().ToString()); IJson json = BiliApi.GetJsonResult("https://api.bilibili.com/x/space/fav/nav", dic, false); if (cancellationToken.IsCancellationRequested) { return; } if (json.GetValue("code").ToLong() == 0) { Dispatcher.Invoke(new Action(() => { foreach (IJson folder in json.GetValue("data").GetValue("archive")) { FavItem favItem; if (folder.GetValue("Cover").Contains(0)) { favItem = new FavItem(folder.GetValue("name").ToString(), folder.GetValue("cover").GetValue(0).GetValue("pic").ToString(), folder.GetValue("cur_count").ToLong(), folder.GetValue("media_id").ToLong(), true); } else { favItem = new FavItem(folder.GetValue("name").ToString(), null, folder.GetValue("cur_count").ToLong(), folder.GetValue("media_id").ToLong(), true); } favItem.PreviewMouseLeftButtonDown += FavItem_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(favItem); } })); } } Dispatcher.Invoke(new Action(() => { LoadingPrompt.Visibility = Visibility.Hidden; })); }); task.Start(); }
private bool Analysis() { StatusUpdate?.Invoke(ProgressPercentage, 0, Status.Analyzing); Segments = new List <Segment>(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("avid", Aid.ToString()); dic.Add("cid", Cid.ToString()); dic.Add("qn", Qn.ToString()); try { IJson json = BiliApi.GetJsonResult("https://api.bilibili.com/x/player/playurl", dic, false); if (json.GetValue("code").ToLong() == 0) { if (json.GetValue("data").GetValue("quality").ToLong() == Qn) { foreach (IJson v in json.GetValue("data").GetValue("durl")) { Segment segment = new Segment(Aid, Regex.Unescape(v.GetValue("url").ToString()), SegmentType.Mixed, v.GetValue("size").ToLong(), Threads); segment.Finished += Segment_Finished; Segments.Add(segment); } } else { return(false); } } else { json = BiliApi.GetJsonResult("http://api.bilibili.com/pgc/player/web/playurl", dic, false); if (json.GetValue("code").ToLong() == 0) { if (json.GetValue("result").GetValue("quality").ToLong() == Qn) { foreach (IJson v in json.GetValue("result").GetValue("durl")) { Segment segment = new Segment(Aid, Regex.Unescape(v.GetValue("url").ToString()), SegmentType.Mixed, v.GetValue("size").ToLong(), Threads); segment.Finished += Segment_Finished; Segments.Add(segment); } } else { return(false); } } else { return(false); } } return(true); } catch (WebException) { return(false); } }
public ImportActivity(IOption option, IRecordContainer <AgentRecord> agentContainer, IRecordContainer <TargetRecord> targetContainer, IJson json, ILogger <ImportActivity> logger) { _option = option; _agentContainer = agentContainer; _targetContainer = targetContainer; _json = json; _logger = logger; }
public ImportActivity(IOption option, IRecordContainer <LinkRecord> linkContainer, IRecordContainer <MetadataRecord> metadataContainer, IJson json, ILogger <ImportActivity> logger) { _option = option; _linkContainer = linkContainer; _metadataContainer = metadataContainer; _json = json; _logger = logger; }
public static void Main() { object obj = new onefield(); IJson j = IlCreator.CreateSerializer(obj.GetType()); String t = j.ToJson(obj); Console.Write(t); }
public SubmitController(ILogger <SubmitController> logger, IPredictService predict, IExecutionContext executionContext, IJson json, IOption option) { _logger = logger; _predict = predict; _executionContext = executionContext; _json = json; _option = option; }
/// <summary> /// 设定记录器实例接口 /// </summary> /// <param name="handler">记录器</param> public void SetJson(IJson handler) { if (handler == this) { throw new InvalidOperationException("Own instance can not give itself"); } this.handler = handler; }
public static string ToJson(IJson source, Type type) { StringBuilder sb = new StringBuilder("{"); int l = type.GetProperties().Length; for (int i = 0; i < l; i++) { PropertyInfo info = type.GetProperties()[i]; sb.AppendFormat(@"""{0}"":", info.Name); //sb.AppendFormat("{0}:", info.Name); object value = info.GetValue(source, null); switch (info.PropertyType.Name) { case "Int64": case "Boolean": case "Int32": sb.Append((null != value ? value.ToString().ToLower() : string.Empty)); break; case "String[]": string[] s1 = value as string[]; sb.Append("["); for (int j = 0; j < s1.Length; j++) { sb.AppendFormat("\"{0}\"", JavaScriptEncode(s1[j])); if (j < s1.Length - 1) { sb.Append(","); } } sb.Append("]"); break; case "Int32[]": int[] i1 = value as int[]; sb.Append("["); for (int j = 0; j < i1.Length; j++) { sb.Append(i1[j]); if (j < i1.Length - 1) { sb.Append(","); } } sb.Append("]"); break; default: sb.AppendFormat("\"{0}\"", EnCode(null == value ? string.Empty : value.ToString())); break; } if (i < l - 1) { sb.Append(","); } } sb.Append("}"); return(sb.ToString()); }
/// <summary> /// Create REST client and use provided HttpClient /// </summary> /// <param name="client"></param> public RestClient(HttpClient client, ILogger <RestClient> logger, IJson?json = null) { client.VerifyNotNull(nameof(client)); logger.VerifyNotNull(nameof(logger)); _client = client; _logger = logger; _json = json ?? Json.Default; }
/// <summary> /// This method provides a way to send a message via JSON and receive /// a JSON response with the result. /// </summary> /// <param name="json">The JSON command.</param> /// <param name="timeout">Timeout in milliseconds. If timeout is 0 then no timeout is used.</param> /// <returns>The JSON command response.</returns> internal string ExecuteJson(IJson json, int timeout) { if (_runningAsynchronously) throw new Exception("Can't run synchronously when already running asynchronously!"); if (_msgQueue.Count > 0) { #if DEBUG if (Log.IsErrorEnabled) Log.Error("Message queue not empty! Discarding unread queue items."); #endif while (_msgQueue.Count > 0) { string item = _msgQueue.Dequeue(); #if DEBUG if (Log.IsWarnEnabled) Log.Warn("Discarding following message:\n" + item); #endif } } // Going to wait on result. _completed.Reset(); // Send the JSON command. SendJsonCommand(json); // Wait on result, with optional timeout. if (timeout == 0) _completed.WaitOne(); else _completed.WaitOne(timeout); // Return the single message response. return _msgQueue.Dequeue(); }
/// <summary> /// Send a JSON message to the command. First 2 bytes is size of message. /// </summary> /// <remarks> /// This is used by both asynchronous and no result commands. /// </remarks> /// <param name="json">The JSON string to send.</param> internal void SendJsonCommand(IJson json) { #if DEBUG if (Log.IsDebugEnabled) Log.Debug("Send: " + json.ToJson()); #endif Stream output = _process.StandardInput.BaseStream; byte[] msg = JsonMsgUtil.WrapJsonOutput(json); output.Write(msg, 0, msg.Length); output.Flush(); }
/// <summary> /// Send a JSON message to the command. First 2 bytes is size of message. /// </summary> /// <param name="json">The JSON string to send.</param> internal void SendJsonForAsynchronousResults(IJson json) { #if DEBUG if (Log.IsDebugEnabled) Log.Debug("Send: " + json); #endif _runningAsynchronously = true; Stream output = _process.StandardInput.BaseStream; byte[] msg = JsonMsgUtil.WrapJsonOutput(json); output.Write(msg, 0, msg.Length); output.Flush(); }
/// <summary> /// 输出Jsonp文本到客户端 /// </summary> /// <param name="Response"></param> /// <param name="callBack">客户端的js回调方法</param> /// <param name="json">json参数</param> public static void WriteJsonp(this HttpResponseBase Response, string callBack, IJson json) { Response.ContentType = "application/x-javascript"; Response.ClearContent(); Response.BinaryWrite(Encoding.UTF8.GetBytes(string.Format("{0}({1});", callBack, json.ToString()))); Response.Flush(); }
internal static byte[] WrapJsonOutput(IJson json) { return WrapJsonOutput(json.ToJson()); }
/// <summary> /// This method provides a way to send a message via JSON and receive /// a JSON response with the result. /// </summary> /// <remarks> /// Uses default timeout setting. /// </remarks> /// <param name="json">The JSON command.</param> /// <returns>The JSON command response.</returns> internal string ExecuteJson(IJson json) { return ExecuteJson(json, DefaultTimeout); }