예제 #1
0
        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="config"></param>
        public static void SaveConfig(OAuthWeiboConfig config)
        {
            string        sDirectory = Himall.Core.Helper.IOHelper.urlToVirtual(WorkDirectory) + "/Weibo.config";
            XmlSerializer xml        = new XmlSerializer(typeof(OAuthWeiboConfig));
            MemoryStream  Stream     = new MemoryStream();

            xml.Serialize(Stream, config);

            byte[]       b       = Stream.ToArray();
            MemoryStream stream2 = new MemoryStream(b);

            Himall.Core.HimallIO.CreateFile(sDirectory, stream2, Core.FileCreateType.Create);
        }
예제 #2
0
        public static void SaveConfig(OAuthWeiboConfig config)
        {
            FileStream fileStream = new FileStream(string.Concat(WeiboCore.WorkDirectory, "\\Weibo.config"), FileMode.Create);

            try
            {
                (new XmlSerializer(typeof(OAuthWeiboConfig))).Serialize(fileStream, config);
            }
            finally
            {
                if (fileStream != null)
                {
                    ((IDisposable)fileStream).Dispose();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 获取配置
        /// </summary>
        /// <returns></returns>
        public static OAuthWeiboConfig GetConfig()
        {
            OAuthWeiboConfig config = new OAuthWeiboConfig();

            string sDirectory = Himall.Core.Helper.IOHelper.urlToVirtual(WorkDirectory) + "/Weibo.config";

            if (HimallIO.ExistFile(sDirectory))
            {
                XmlSerializer xs  = new XmlSerializer(typeof(OAuthWeiboConfig));
                byte[]        b   = Himall.Core.HimallIO.GetFileContent(sDirectory);
                string        str = System.Text.Encoding.Default.GetString(b);
                MemoryStream  fs  = new MemoryStream(b);
                config = (OAuthWeiboConfig)xs.Deserialize(fs);
            }
            else
            {
                SaveConfig(config);
            }

            return(config);
        }