Exemplo n.º 1
0
 public object Deserialize(StructuredText node)
 {
     //TODO エラーハンドリング弱い
     if (node.ChildCount != 2)
     {
         return(null);
     }
     return(new MRUItem(
                (ITerminalParameter)_serializeService.Deserialize(node.GetChildOrNull(0)),
                (ITerminalSettings)_serializeService.Deserialize(node.GetChildOrNull(1))));
 }
Exemplo n.º 2
0
        public IEnumerable <Denomination> Get()
        {
            var result = _serializeService.Deserialize <Denomination[]>(FILE_NAME);

            _items = result.Handle(r => r.ToList(), () => _defaultItems.ToList());
            return(_items);
        }
Exemplo n.º 3
0
        private void DoContext(IContextComm contextComm, Stream streamMessage)
        {
            // get the request stream
            using (MemoryStream ms = new MemoryStream())
            {
                streamMessage.CopyTo(ms);
                ms.Seek(0, SeekOrigin.Begin);
                StreamReader sr = new StreamReader(ms);
                while (!sr.EndOfStream)
                {
                    var req = sr.ReadLine();
                    Debug.Print("receive " + req);
                }

                ms.Seek(0, SeekOrigin.Begin);

                SerialObject so = fSerializeService.Deserialize(ms);
                // send an ack
                contextComm.Acknowledge();

                // find hosted actor directory
                // forward msg to hostedactordirectory
                Become(new Behavior <SerialObject>(t => { return(true); }, ProcessMessage));
                SendMessage(so);
            }
        }
        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);
        }
Exemplo n.º 5
0
        private static ShortcutFileContent ParseV4(XmlElement root)
        {
            XmlElement first  = null;
            XmlElement second = null;

            //ちょっといいかげんだが、最初のElement、2個目のElementを。
            foreach (XmlNode node in root.ChildNodes)
            {
                XmlElement e = node as XmlElement;
                if (e != null)
                {
                    if (first == null)
                    {
                        first = e;
                    }
                    else if (second == null)
                    {
                        second = e;
                        break;
                    }
                }
            }

            if (second == null)
            {
                throw new FormatException("Unknown XML Format");
            }
            StructuredText setting_text   = new XmlStructuredTextReader(first).Read();
            StructuredText parameter_text = new XmlStructuredTextReader(second).Read();

            ISerializeService ss      = TerminalSessionsPlugin.Instance.SerializeService;
            ITerminalSettings setting = ss.Deserialize(setting_text) as ITerminalSettings;

            if (setting == null)
            {
                throw new FormatException("TerminalSettings could not be loaded");
            }
            ITerminalParameter param = ss.Deserialize(parameter_text) as ITerminalParameter;

            if (param == null)
            {
                throw new FormatException("TerminalParameter could not be loaded");
            }

            return(new ShortcutFileContent(setting, param));
        }
Exemplo n.º 6
0
        public async Task <J> Get(T request)
        {
            var url  = this.createRequestService.GetUrl(request);
            var data = await this.clientService.GetData(url);

            var result = serializeService.Deserialize(data);

            return(result);
        }
 public T GetObject <T>(string fileName)
 {
     try
     {
         string text = File.ReadAllText(fileName);
         return(serializeService.Deserialize <T>(text));
     }
     catch (Exception ex)
     {
         throw Errors.GetObjectError(ex, fileName, typeof(T));
     }
 }