コード例 #1
0
        /// <inheritdoc />
        protected override void ProcessRecord()
        {
            var holder = new WikiClientStateHolder();

            holder.SetCookies(WikiClient.CookieContainer);
            if (StateFile == null)
            {
                WriteObject(Utility.SaveJson(holder));
            }
            else
            {
                Utility.SaveJsonTo(StateFile, holder);
            }
        }
コード例 #2
0
        /// <inheritdoc />
        protected override void ProcessRecord()
        {
            var client = new WikiClient
            {
                ClientUserAgent = "PSWikiClient/0.1 (https://github.com/CXuesong/PSWikiClient)",
                Timeout         = TimeSpan.FromMinutes(1),
            };
            WikiClientStateHolder state = null;

            if (StateContent != null)
            {
                state = Utility.LoadJson <WikiClientStateHolder>(StateContent);
            }
            else if (StateFile != null)
            {
                state = Utility.LoadJsonFrom <WikiClientStateHolder>(StateFile);
            }
            if (state != null)
            {
                client.CookieContainer = state.TryGetCookies();
            }
            WriteObject(client);
        }