public void Deserialize(TCPParameter tp, StructuredText node) { base.Deserialize(tp, node); tp.Destination = node.Get("destination", ""); Debug.Assert(tp.Destination != null); tp.Port = ParseUtil.ParseInt(node.Get("port"), _defaultPort); }
public object Deserialize(StructuredText storage) { RenderProfile prof = new RenderProfile(); prof.FontName = storage.Get("font-name", "Courier New"); prof.CJKFontName = storage.Get("cjk-font-name", storage.Get("japanese-font-name", storage.Get("chinese-font-name", "Courier New"))); prof.FontSize = ParseUtil.ParseFloat(storage.Get("font-size"), 10.0f); prof.LineSpacing = ParseUtil.ParseInt(storage.Get("line-spacing"), 0); prof.UseClearType = ParseUtil.ParseBool(storage.Get("clear-type"), false); prof.EnableBoldStyle = ParseUtil.ParseBool(storage.Get("enable-bold-style"), true); prof.ForceBoldStyle = ParseUtil.ParseBool(storage.Get("force-bold-style"), false); prof.ForeColor = ParseUtil.ParseColor(storage.Get("text-color"), Color.FromKnownColor(KnownColor.WindowText)); prof.BackColor = ParseUtil.ParseColor(storage.Get("back-color"), Color.FromKnownColor(KnownColor.Window)); prof.ImageStyle = ParseUtil.ParseEnum <ImageStyle>(storage.Get("back-style"), ImageStyle.Center); prof.BackgroundImageFileName = storage.Get("back-image", ""); prof.ESColorSet = new EscapesequenceColorSet(); string escolor = storage.Get("escape-sequence-color"); if (escolor != null) { prof.ESColorSet.Load(escolor); } prof.DarkenEsColorForBackground = ParseUtil.ParseBool(storage.Get("darken-escolor-for-background"), true); return(prof); }
/// <summary> /// 解析CameraShake事件字符串 /// "camera_shake 2 0 1.5,0.3 4 0.2" /// </summary> static public void ParseShakeEvent(string evt, out CameraShake.ShakeType shakeType, out CameraShake.NoiseType noiseType, out Vector3 moveExt, out float speed, out float duration) { // 参数使用空白分割 var args = evt.Split(' '); try { // 参数0是指令参数,通常为camera_shake shakeType = (CameraShake.ShakeType)ParseUtil.ParseInt(args [1]); noiseType = (CameraShake.NoiseType)ParseUtil.ParseInt(args [2]); moveExt = ParseUtil.ParseVector2(args [3]); speed = ParseUtil.ParseFloat(args [4]); duration = ParseUtil.ParseFloat(args [5]); } catch (System.Exception ex) { shakeType = CameraShake.ShakeType.Constant; noiseType = CameraShake.NoiseType.Perlin; moveExt = default(Vector3); speed = 0f; duration = 0f; Debug.LogError($"解析CameraShake事件字符串失败:{evt}"); } }
public object Deserialize(StructuredText node) { SerialTerminalParam tp = new SerialTerminalParam(); tp.Port = ParseUtil.ParseInt(node.Get("Port"), 1); tp.SetTerminalName(node.Get("TerminalType", "vt100")); tp.AutoExecMacroPath = node.Get("autoexec-macro", null); return(tp); }
private static int TryParseInt(string[] values, int index) { if (values.Length <= index) { return(0); } else { return(ParseUtil.ParseInt(values[index], 0)); } }
protected override Cell CreateEntity() { BaseEntity container = _upperElement.CurrentEntity; ProductRule prodRule = container.ProductRule; _entity = new Cell(prodRule, container, new Location(_data.GetAttribute("location"))); parseSource(_data.GetAttribute("source")); _entity.DataIndex = ParseUtil.ParseInt(_data.GetAttribute("index"), 0); _entity.ValueAppend = ParseUtil.ParseBoolean(_data.GetAttribute("valueAppend"), false); _entity.Value = ParseUtil.IfNullOrEmpty(_data.GetAttribute("value")); _entity.FillType = ParseUtil.ParseEnum <FillType>(_data.GetAttribute("fill"), FillType.Origin); return(_entity); }
private void OnOK(object sender, EventArgs e) { try { IIntPreferenceItem intitem = _item.AsInt(); IStringPreferenceItem stritem = _item.AsString(); if (intitem != null) { intitem.Value = ParseUtil.ParseInt(_valueBox.Text, intitem.InitialValue); } else { stritem.Value = _valueBox.Text; } } catch (Exception ex) { GUtil.Warning(this, ex.Message); this.DialogResult = DialogResult.None; } }
public object Deserialize(StructuredText node) { SerialTerminalSettings ts = SerialPortUtil.CreateDefaultSerialTerminalSettings(1); //TODO Deserializeの別バージョンを作ってimportさせるべきだろう。もしくはService側の実装から変える。要素側には空引数コンストラクタを強制すればいいか StructuredText basenode = node.FindChild(typeof(TerminalSettings).FullName); if (basenode != null) { ts.BaseImport((ITerminalSettings)SerialPortPlugin.Instance.SerializeService.Deserialize(basenode)); } ts.BaudRate = ParseUtil.ParseInt(node.Get("baud-rate"), 9600); ts.ByteSize = (byte)ParseUtil.ParseInt(node.Get("byte-size"), 8); ts.Parity = ParseUtil.ParseEnum <Parity>(node.Get("parity"), Parity.NOPARITY); ts.StopBits = ParseUtil.ParseEnum <StopBits>(node.Get("stop-bits"), StopBits.ONESTOPBIT); ts.FlowControl = ParseUtil.ParseEnum <FlowControl>(node.Get("flow-control"), FlowControl.None); ts.TransmitDelayPerChar = ParseUtil.ParseInt(node.Get("delay-per-char"), 0); ts.TransmitDelayPerLine = ParseUtil.ParseInt(node.Get("delay-per-line"), 0); return(ts); }
protected override Field CreateEntity() { Table table = _tableElement.Entity; ProductRule prod = table.ProductRule; _entity = new Field(table, _data.GetAttribute("name")); _entity.ColIndex = ParseUtil.ParseColumnIndex(_data.GetAttribute("colIndex"), -1); _entity.Type = ParseUtil.ParseEnum <FieldType>(_data.GetAttribute("type"), FieldType.Unknown); _entity.Format = _data.GetAttribute("format"); _entity.CommentColumn = _data.GetAttribute("annnotationField"); _entity.RefColumn = _data.GetAttribute("refField"); _entity.LinkType = _data.GetAttribute("linkType"); string tmpStr = _data.GetAttribute("dropDownListSource"); if (!string.IsNullOrEmpty(tmpStr)) { Source tmpSource = prod.GetSource(tmpStr); /** * dropDownListSource数据源要么引用预定义的DataList,要么指定了DataTable.Field;否则将被忽略 */ if (tmpSource != null && tmpSource is ListSource) { _entity.DropDownListSource = tmpSource as ListSource; } else if (tmpSource == null && tmpStr.Contains('.')) { tmpSource = new ListSource(tmpStr.Split('.')[0], tmpStr.Split('.')[1]); _entity.DropDownListSource = tmpSource as ListSource; prod.RegistSource(tmpSource); } } _entity.Spannable = ParseUtil.ParseBoolean(_data.GetAttribute("spannable"), false); _entity.ColSpan = ParseUtil.ParseInt(_data.GetAttribute("colspan"), 1); _entity.SumField = ParseUtil.ParseBoolean(_data.GetAttribute("sumfield"), false); _entity.EmptyFill = _data.GetAttribute("emptyFill"); return(_entity); }
public DecalFont(ConfigNode node, IEnumerable <TMP_FontAsset> fontAssets) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (fontAssets == null) { throw new ArgumentNullException(nameof(fontAssets)); } var name = ParseUtil.ParseString(node, "name"); _fontAsset = fontAssets.First(o => o.name == name); if (FontAsset == null) { throw new FormatException($"Could not find font asset named {name}"); } _title = ParseUtil.ParseString(node, "title", true, name); _fontStyle = (FontStyles)ParseUtil.ParseInt(node, "style", true); _fontStyleMask = (FontStyles)ParseUtil.ParseInt(node, "styleMask", true); }
//旧バージョンフォーマットの読み込み private static ShortcutFileContent ParseOldFormat(XmlElement root) { if (root.GetAttribute("type") != "tcp") { throw new FormatException("Unknown File Format"); } //accountの有無でTelnet/SSHを切り替え ITerminalParameter param; ISSHLoginParameter ssh = null; ITCPParameter tcp = null; string account = root.GetAttribute("account"); if (account.Length > 0) { ssh = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultSSHParameter(); ssh.Account = account; tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter)); } else { tcp = TerminalSessionsPlugin.Instance.ProtocolService.CreateDefaultTelnetParameter(); } param = (ITerminalParameter)tcp.GetAdapter(typeof(ITerminalParameter)); ITerminalSettings settings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings("", null); settings.BeginUpdate(); //アトリビュート舐めて設定 foreach (XmlAttribute attr in root.Attributes) { switch (attr.Name) { case "auth": if (ssh != null) { ssh.AuthenticationType = ParseUtil.ParseEnum <AuthenticationType>(attr.Value, AuthenticationType.Password); } break; case "keyfile": if (ssh != null) { ssh.IdentityFileName = attr.Value; } break; case "encoding": settings.Encoding = (EncodingType)EnumDescAttribute.For(typeof(EncodingType)).FromDescription(attr.Value, EncodingType.ISO8859_1); break; case "terminal-type": settings.TerminalType = ParseUtil.ParseEnum <TerminalType>(attr.Value, TerminalType.XTerm); param.SetTerminalName(attr.Value); break; case "localecho": settings.LocalEcho = ParseUtil.ParseBool(attr.Value, false); break; case "caption": settings.Caption = attr.Value; break; case "transmit-nl": settings.TransmitNL = ParseUtil.ParseEnum <NewLine>(attr.Value, NewLine.CR); break; case "host": tcp.Destination = attr.Value; break; case "port": tcp.Port = ParseUtil.ParseInt(attr.Value, ssh != null? 22 : 23); break; case "method": if (ssh != null) { ssh.Method = attr.Value == "SSH1"? SSHProtocol.SSH1 : SSHProtocol.SSH2; } break; } } //ts.LineFeedRule = ParseUtil.ParseEnum<LineFeedRule>(node.Get("linefeedrule"), LineFeedRule.Normal); settings.EndUpdate(); return(new ShortcutFileContent(settings, param)); }
protected override Region CreateEntity() { RegionTable table = _regionTableElement.Entity; ProductRule prodRule = table.ProductRule; string tmpStr = _data.GetAttribute("type"); if (string.IsNullOrEmpty(tmpStr)) { return(null); } _entity = "corner".Equals(tmpStr.ToLower()) ? (Region) new CornerRegion(table) : "rowheader".Equals(tmpStr.ToLower()) ? new RowHeaderRegion(table) : "columnheader".Equals(tmpStr.ToLower()) ? (Region) new ColumnHeaderRegion(table) : new BodyRegion(table); tmpStr = _data.GetAttribute("source"); if (!string.IsNullOrEmpty(tmpStr)) { string[] values = tmpStr.Split('.'); if (values.Length > 1) { _entity.Field = values[1]; } _entity.Source = prodRule.RegistSource(values[0]); } _entity.EmptyFill = _data.GetAttribute("emptyFill"); if (_entity is BodyRegion) { //暂无逻辑 } else if (_entity is HeaderRegion) { HeaderRegion header = _entity as HeaderRegion; header.Source = parseTreeSource(tmpStr, _data.GetAttribute("innerMapping"), prodRule) ?? header.Source; tmpStr = _data.GetAttribute("headerBodyMapping"); header.HeaderBodyRelation = parseRelation(header.Source, tmpStr, prodRule); //tmpStr = _data.GetAttribute("treeSource"); //header.TreeSource = parseTreeSource(tmpStr, _data.GetAttribute("treeInnerMapping"), prodRule); ////header.IdField = element.GetAttribute("IdField"); ////header.ParentField = element.GetAttribute("parentField"); //tmpStr = _data.GetAttribute("headerTreeMapping"); //header.HeaderTreeRelation = parseRelation(header.Source, tmpStr, prodRule); //if (header.HeaderTreeRelation != null) //{ // header.HeaderTreeRelation.ReferecedSource = header.TreeSource; header.MaxLevel = ParseUtil.ParseInt(_data.GetAttribute("maxLevel"), -1); header.ColSpannable = ParseUtil.ParseBoolean(_data.GetAttribute("colSpannable")); header.RowSpannable = ParseUtil.ParseBoolean(_data.GetAttribute("rowSpannable")); header.IsBasedOn = ParseUtil.ParseBoolean(_data.GetAttribute("basedSource")); //} } else if (_entity is CornerRegion) { tmpStr = _data.GetAttribute("spanRule"); if (!string.IsNullOrEmpty(tmpStr)) { CornerSpanRule spanRule = CornerSpanRule.None; if (!Enum.TryParse(tmpStr, true, out spanRule)) { spanRule = "row".Equals(tmpStr.ToLower()) ? CornerSpanRule.BaseOnRowHeader : "column".Equals(tmpStr.ToLower()) ? CornerSpanRule.BaseOnColumnHeader : "one".Equals(tmpStr.ToLower()) ? CornerSpanRule.AllInOne : CornerSpanRule.None; } (_entity as CornerRegion).SpanRule = spanRule; } } return(_entity); }
protected override Table CreateEntity() { BaseEntity container = _upperElement.CurrentEntity; ProductRule prodRule = container.ProductRule; Location tmpLocation = new Location(_data.GetAttribute("location")); _entity = new Table(prodRule, container, tmpLocation); string tmpStr = _data.GetAttribute("source"); if (!string.IsNullOrEmpty(tmpStr)) { _entity.SourceName = tmpStr; //只要不是动态解析的数据源,Source不能为空 if ((container is Sheet && !(container as Sheet).IsDynamic) || !DynamicSource.NeedDynamicParse(tmpStr)) { //_entity.Source = prodRule.RegistSource(tmpStr); prodRule.RegistSource(tmpStr); } } _entity.RowNumIndex = ParseUtil.ParseColumnIndex(_data.GetAttribute("rowNumIndex"), -1); _entity.CopyFill = ParseUtil.ParseBoolean(_data.GetAttribute("copyFill"), true); _entity.SumLocation = ParseUtil.ParseEnum <LocationPolicy>(_data.GetAttribute("sumLocation"), LocationPolicy.Undefined); _entity.SumOffset = ParseUtil.ParseInt(_data.GetAttribute("sumOffset"), _entity.SumLocation == LocationPolicy.Undefined || _entity.SumLocation == LocationPolicy.Absolute ? -1 : 0); _entity.AutoFitHeight = ParseUtil.ParseBoolean(_data.GetAttribute("autoFitHeight"), false); int groupLevel = ParseUtil.ParseInt(_data.GetAttribute("groupLevel"), 0); if (groupLevel > 0) { tmpStr = _data.GetAttribute("groupNumShow"); if (!string.IsNullOrEmpty(tmpStr)) { bool[] shows = new bool[groupLevel]; string[] bools = tmpStr.Split(','); for (int i = 0; i < bools.Length && i < shows.Length; i++) { if (bool.Parse(bools[i])) { shows[i] = true; } } _entity.SetGroup(shows); } } _entity.AdjustSumOffset(); #region Field重复出现的处理 List <Field> fieldlist = new List <Field>(); tmpStr = _data.GetAttribute("fields"); if (!string.IsNullOrEmpty(tmpStr)) { string[] fieldArray = tmpStr.Split(','); foreach (var fieldname in fieldArray) { fieldlist.Add(new Field(_entity, fieldname)); } } _entity.AddFields(fieldlist); //子结点 parseField(_upperElement.ProductRuleElement.QuerySubNodes("Field", _data)); #endregion Field重复出现的处理 // 行号处理 parseRowNum(_upperElement.ProductRuleElement.QuerySubNodes("RowNum", _data)); //区域计算:计算行号、字段的列位置,以及Table填充列范围 _entity.CalculateArea(); //汇总列:在确定字段位置之后处理 tmpStr = _data.GetAttribute("sumColumns"); if (!string.IsNullOrEmpty(tmpStr)) { string[] columns = tmpStr.Split(','); _entity.AddSumColumns(columns); } return(_entity); }