public object Deserialize(StructuredText node)
        {
            TerminalSettings ts = new TerminalSettings();

            ts.BeginUpdate();

            ts.Encoding     = ParseEncodingType(node.Get("encoding", ""), EncodingType.ISO8859_1);
            ts.TerminalType = ParseUtil.ParseEnum <TerminalType>(node.Get("terminal-type"), TerminalType.XTerm);
            ts.LocalEcho    = ParseUtil.ParseBool(node.Get("localecho"), false);
            ts.LineFeedRule = ParseUtil.ParseEnum <LineFeedRule>(node.Get("linefeedrule"), LineFeedRule.Normal);
            ts.TransmitNL   = ParseUtil.ParseEnum <NewLine>(node.Get("transmit-nl"), NewLine.CR);
            ts.EnabledCharTriggerIntelliSense = ParseUtil.ParseBool(node.Get("char-trigger-intellisense"), false);
            string shellscheme = node.Get("shellscheme", ShellSchemeCollection.DEFAULT_SCHEME_NAME);

            if (shellscheme.Length > 0)
            {
                ts.SetShellSchemeName(shellscheme);
            }
            ts.Caption = node.Get("caption", "");
#if !UNITTEST
            //現在テストではRenderProfileは対象外
            StructuredText rp = node.FindChild(typeof(RenderProfile).FullName);
            if (rp != null)
            {
                ts.RenderProfile = _serializeService.Deserialize(rp) as RenderProfile;
            }
#endif
            ts.EndUpdate();
            return(ts);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public void Deserialize(SSHLoginParameter tp, StructuredText node)
 {
     base.Deserialize(tp, node);
     tp.Method             = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
     tp.AuthenticationType = ParseUtil.ParseEnum <AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
     tp.Account            = node.Get("account", "");
     tp.IdentityFileName   = node.Get("identityFileName", "");
     if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword)
     {
         string pw = node.Get("passphrase", null);
         if (pw != null)
         {
             tp.PasswordOrPassphrase = pw;
             tp.LetUserInputPassword = false;
         }
         else
         {
             pw = node.Get("password", null);
             if (pw != null)
             {
                 pw = new SimpleStringEncrypt().DecryptString(pw);
                 if (pw != null)
                 {
                     tp.PasswordOrPassphrase = pw;
                     tp.LetUserInputPassword = false;
                 }
             }
         }
     }
 }
        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);
        }
        public void Deserialize(SSHLoginParameter tp, StructuredText node)
        {
            base.Deserialize(tp, node);
            tp.Method             = "SSH1".Equals(node.Get("method")) ? SSHProtocol.SSH1 : SSHProtocol.SSH2;
            tp.AuthenticationType = ParseUtil.ParseEnum <AuthenticationType>(node.Get("authentication", ""), AuthenticationType.Password);
            tp.Account            = node.Get("account", "");
            tp.IdentityFileName   = node.Get("identityFileName", "");
            if (ProtocolsPlugin.Instance.ProtocolOptions.ReadSerializedPassword)
            {
                string pw = node.Get("passphrase", null);
                if (pw != null)
                {
                    tp.PasswordOrPassphrase = pw;
                    tp.LetUserInputPassword = false;
                }
                else
                {
                    pw = node.Get("password", null);
                    if (pw != null)
                    {
                        pw = new SimpleStringEncrypt().DecryptString(pw);
                        if (pw != null)
                        {
                            tp.PasswordOrPassphrase = pw;
                            tp.LetUserInputPassword = false;
                        }
                    }
                }
            }

            tp.EnableAgentForwarding = GetBoolValue(node, "enableAgentForwarding", false);

            tp.EnableX11Forwarding = GetBoolValue(node, "enableX11Forwarding", false);

            StructuredText x11Node = node.FindChild("x11Forwarding");

            if (x11Node != null)
            {
                int display = GetIntValue(x11Node, "display", 0);
                X11ForwardingParams x11params = new X11ForwardingParams(display);
                x11params.Screen                    = GetIntValue(x11Node, "screen", 0);
                x11params.NeedAuth                  = GetBoolValue(x11Node, "needAuth", false);
                x11params.XauthorityFile            = x11Node.Get("xauthorityFile", null);
                x11params.UseCygwinUnixDomainSocket = GetBoolValue(x11Node, "useCygwinUnixDomainSocket", false);
                x11params.X11UnixFolder             = x11Node.Get("x11UnixFolder", null);
                tp.X11Forwarding                    = x11params;
            }
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
        //旧バージョンフォーマットの読み込み
        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 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);
        }