/// <summary> /// 默认站点配置 /// </summary> /// <returns></returns> public static TinyConfiguration LoadDefaultConfiguration() { TinyConfiguration _tinyConfiguration = new TinyConfiguration(); _tinyConfiguration = new TinyConfiguration(); _tinyConfiguration.AuthExpireSeconds = 28800; _tinyConfiguration.IsSitePublic = true; _tinyConfiguration.NavigationLinks = new string[][] { new string[] { "/", "HOME" }, new string[] { "https://estermont.wordpress.com/", "DOWNLOAD" }, new string[] { "https://github.com/yahch", "GITHUB" } }; _tinyConfiguration.PageSize = 5; _tinyConfiguration.Password = PBKDF2.Encrypt("admin"); _tinyConfiguration.Port = 6600; _tinyConfiguration.SiteBuildDate = new DateTime(2018, 3, 15); _tinyConfiguration.SiteName = "TiNY"; _tinyConfiguration.Username = "******"; _tinyConfiguration.Encryption = false; _tinyConfiguration.LoginRetryTimeSpanSeconds = 30; _tinyConfiguration.DataDirectory = Root; return(_tinyConfiguration); }
/// <summary> /// 更新配置文件 /// </summary> /// <param name="config"></param> /// <returns></returns> public static bool UpdateConfig(TinyConfiguration config) { try { Configuration = config; var fs = File.OpenWrite(ConfigFileName); var xs = SERIALIZER.SerializorToStream(config); xs.CopyTo(fs); xs.Close(); fs.Close(); return(true); } catch (Exception) { return(false); } }
/// <summary> /// 加载外部配置,如果没有,加载默认配置 /// </summary> private static void LoadConfiguration() { if (string.IsNullOrEmpty(ConfigFileName)) { throw new ArgumentException("配置文件路径不存在!"); } // 判断是否有配置文件,如果有就读取 if (File.Exists(ConfigFileName)) { using (var fs = File.OpenRead(ConfigFileName)) { Configuration = SERIALIZER.DeserializorFromStream <TinyConfiguration>(fs); } } else { UpdateConfig(LoadDefaultConfiguration()); } }
public TinyfxPageRender(TinyConfiguration configuration) { _tinyConfiguration = configuration; _pressService = new PressService(); }