public MOEX.ASTS.Client.Client Connect(StringDictionary parameters, Scales scales) { if (this.disposed) { throw new ObjectDisposedException(base.GetType().Name); } string twoLetterISOLanguageName = null; StringBuilder builder = new StringBuilder(); foreach (DictionaryEntry entry in parameters) { if (string.Equals("LANGUAGE", entry.Key.ToString(), StringComparison.InvariantCultureIgnoreCase)) { twoLetterISOLanguageName = NameToLang[entry.Value.ToString().ToUpper()]; } StringBuilder introduced13 = builder.Append(entry.Key).Append("="); introduced13.Append(entry.Value).AppendLine(); } if (twoLetterISOLanguageName == null) { twoLetterISOLanguageName = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; } StringBuilder report = new StringBuilder(0x400); int code = this.MTEConnect(builder.ToString(), report); if (code < 0) { throw new ClientException(code, report.ToString()); } string language = DetectLanguage(report.ToString()); if (!language.Equals(twoLetterISOLanguageName)) { char ch = twoLetterISOLanguageName.ToUpper()[0]; if (this.MTEExecTrans(code, "CHANGE_LANGUAGE", ch.ToString(), report) == 0) { language = twoLetterISOLanguageName; } } MOEX.ASTS.Client.Client item = new MOEX.ASTS.Client.Client(this, code, language, scales); lock (this.clients) { this.clients.Add(item); } return(item); }
internal string Encode(IDictionary <string, object> values, Scales scales) { StringBuilder builder = new StringBuilder(this.input.Size); if ((values == null) || (values.Count == 0)) { return(builder.Append(' ', this.input.Size).ToString()); } int scale = 0; if (this.Params.HasSecCode) { object obj2 = null; if (values.TryGetValue(this.Params.fldSecCode.Name, out obj2)) { object obj3 = null; if (this.Params.HasSecBoard) { values.TryGetValue(this.Params.fldSecBoard.Name, out obj3); } if (obj3 == null) { scales.Find(obj2.ToString(), out scale); } else { scales.Find(obj3.ToString(), obj2.ToString(), out scale); } } } int num2 = 0; for (int i = 0; i < this.Params.varBlockCount; i++) { Meta.Field field = this.Params[i + this.Params.varBlockFirst]; if ((field.flags & 8) != 0) { if (num2 == 0) { num2 = 1; } object obj4 = null; if ((values.TryGetValue(field.Name, out obj4) && (obj4 != null)) && obj4.GetType().IsArray) { Array array = obj4 as Array; num2 = Math.Max(num2, array.Length); } } } int num4 = (this.Params.varBlockFirst + this.Params.varBlockCount) - 1; int num5 = 0; int varBlockFirst = 0; while (varBlockFirst < this.Params.Count) { Meta.Field field2 = this.Params[varBlockFirst]; object obj5 = null; if (values.TryGetValue(field2.Name, out obj5)) { if (obj5 == null) { builder.Append(' ', field2.Size); } else { System.Type type = obj5.GetType(); if (((field2.flags & 8) != 0) && type.IsArray) { Array array2 = obj5 as Array; if (num5 < array2.Length) { field2.Encode(builder, array2.GetValue(new int[] { num5 }), scale); } else { builder.Append(' ', field2.Size); } } else { field2.Encode(builder, obj5, scale); } } } else if (string.IsNullOrEmpty(field2.Defaults)) { builder.Append(' ', field2.Size); } else { builder.Append(field2.Defaults); } if (varBlockFirst == num4) { if (++num5 < num2) { varBlockFirst = this.Params.varBlockFirst; } else { varBlockFirst++; } } else { varBlockFirst++; } } return(builder.ToString()); }