/// <summary> /// 等価比較 /// </summary> /// <param name="obj">オブジェクト</param> /// <returns>比較結果</returns> public override bool Equals(object obj) { ColRow target = obj as ColRow; if (target == null) { return(false); } return(_col == target.Col && _row == target.Row); }
// Retrieve the metadata attribute associated with a given cell, // or null if no such attribute was previously associated. public object GetMetadata(int row, int col, string attribute) { object ret = null; ColRow key = new ColRow(row, col); if (ColRowToMetadata.ContainsKey(key)) { var metadata = ColRowToMetadata[key]; if (metadata.ContainsKey(attribute)) { ret = metadata[attribute]; } } return(ret); }
// Associate a metadata attribute with a given maze cell public void SetMetadata(int row, int col, string attribute, object data) { ColRow key = new ColRow(row, col); Dictionary <string, object> metadata = null; if (!ColRowToMetadata.ContainsKey(key)) { metadata = new Dictionary <string, object>(); ColRowToMetadata[key] = metadata; } metadata = ColRowToMetadata[key]; if (metadata.ContainsKey(attribute)) { metadata[attribute] = data; } else { metadata.Add(attribute, data); } }
public abstract int Get(string line, string[] values, int lineindex, ColRow[] pos);
public abstract int Get(TextReader reader, string[] values, ColRow[] pos);
public override int Get(string line, string[] values, int lineindex, ColRow[] pos) { int count = 0; for (int k = 0; k < values.Length; k++) { values[k] = null; if (pos != null) { pos[k].line = lineindex; pos[k].col = 0; } } int index = 0; if (line.Length > 0 && line[0] == CommentChar) return -1; while (index < line.Length) { if (pos != null && count < pos.Length) { pos[count].line = lineindex; pos[count].col = index; } values[count] = line.Substring(index, Math.Min(m_length[count], line.Length - index)); index += m_length[count++]; } return count; }
public override int Get(string line, string[] values, int lineindex, ColRow[] pos) { int count = 0; for (int k = 0; k < values.Length; k++) { values[k] = null; if (pos != null) { pos[k].col = 0; pos[k].line = lineindex; } } int index = 0; if (line.Length > 0 && line[0] == CommentChar) return -1; while (index < line.Length) { if (pos != null && count < pos.Length) { pos[count].line = lineindex; pos[count].col = index; } if (line[index] == QuoteChar) { index++; StringBuilder sb = new StringBuilder(); while (true) { int k = line.IndexOf(QuoteChar, index); if (k == -1) throw new ESQLException(Properties.Resources.UnexpectedTextFileEOL, lineindex + 1, index + 1); else { int next_ch; if (k < line.Length -1) { next_ch = line[k + 1]; if (next_ch == QuoteChar) { sb.Append(line.Substring(index, k - index + 1)); index = k + 2; if (index > line.Length - 1) break; } else { sb.Append(line.Substring(index, k - index)); index = k + 1; break; } } else { sb.Append(line.Substring(index)); index = k + 1; break; } } } if (index < line.Length) if (line[index] == Delimiter) index++; else throw new ESQLException(Properties.Resources.InvalidTextFileFormat, lineindex + 1, index + 1); if (count < values.Length) values[count++] = sb.ToString(); } else { int k = line.IndexOf(Delimiter, index); if (k > -1) { if (count < values.Length) values[count++] = line.Substring(index, k - index); index = k + 1; } else { if (count < values.Length) values[count++] = line.Substring(index); break; } } } return count; }
public bool Start() { string host = service.GetConfigValue("ComrmsHost").ConfigValue; string path = "/query/comrms"; string method = "GET"; string appcode = service.GetConfigValue("ComrmsAppCode").ConfigValue; string querys = "symbols=" + service.GetConfigValue("ComrmsQuerys").ConfigValue; string bodys = ""; string url = host + path; HttpWebRequest httpRequest = null; HttpWebResponse httpResponse = null; if (0 < querys.Length) { url = url + "?" + querys; } if (host.Contains("https://")) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); } else { httpRequest = (HttpWebRequest)WebRequest.Create(url); } httpRequest.Method = method; httpRequest.Headers.Add("Authorization", "APPCODE " + appcode); if (0 < bodys.Length) { byte[] data = Encoding.UTF8.GetBytes(bodys); using (Stream stream = httpRequest.GetRequestStream()) { stream.Write(data, 0, data.Length); } } try { httpResponse = (HttpWebResponse)httpRequest.GetResponse(); } catch (WebException ex) { httpResponse = (HttpWebResponse)ex.Response; } Stream st = httpResponse.GetResponseStream(); StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8")); string contract = reader.ReadToEnd(); Comrms comrms = contract.ToObject <Comrms>(); if (comrms.Code == 0) { foreach (Obj obj in comrms.Obj) { ColRow cRow = new ColRow("Contract", "FS", obj.FS, false); if (cRow.R_HasField) { cRow["Price"] = obj.P; cRow["NV"] = obj.NV; cRow["Time"] = new DateTime(1970, 1, 1, 0, 0, 0).AddHours(8).AddSeconds(obj.Tick); cRow["ZF"] = obj.ZF; cRow.Update(); } else { cRow["F_Id"] = Guid.NewGuid().ToString(); cRow["ContractName"] = obj.N; cRow["ContractCode"] = obj.S; cRow["Price"] = obj.P; cRow["NV"] = obj.NV; cRow["M"] = obj.M; cRow["S"] = obj.S; cRow["C"] = obj.C; cRow["Time"] = new DateTime(1970, 1, 1, 0, 0, 0).AddHours(8).AddSeconds(obj.Tick); cRow["ZF"] = obj.ZF; cRow.Insert(); } } } return(true); }