internal static ConfigCenter DoLoadConfig(StreamReader fs) { ConfigCenter config = new ConfigCenter(); Dictionary <string, IConfigIO> handleDictionary = GetConfigIOInstanceList(config); IConfigIO instance = null; while (!fs.EndOfStream) { string lineStr = fs.ReadLine().Trim(); if (lineStr.Length > 0 && !lineStr.StartsWith("#")) { if (handleDictionary.ContainsKey(lineStr)) { instance = handleDictionary[lineStr]; } else { instance?.ReadConfig(lineStr); } } } foreach (string key in handleDictionary.Keys) { handleDictionary[key].WriteLog(); } return(config); }
protected void Application_Start() { ConfigCenter.Init("Account"); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); }
public void OnImportFile() { string filePath = ToolFunction.OpenFilePath("*.txt", "打开文件", ".txt"); ConfigCenter.Instance().AddHistoryFile(filePath); GetComponent <MovieCatalogueScript>().AddListItembByFileName(filePath); }
static void RequireInitProxy() { MessageDialog.Information("阿门", "欢迎使用订票助手.NET。为了保证您能更快速更顺利地运行助手,现在需要咨询下阁下的网络设置。\n\n在这之后,您可以随时通过选项来修改设置。"); var nc = NetworkConfiguration.Current; if (MessageDialog.Question("您是否可以直接访问12306?如果可以,那么将会设置成直接访问,速度最快,同时能享有服务器测速加速功能。\n\n一般家庭宽带用户均为『可以』,单位一般也『可以』,但是如果您的公司需要使用代理才能访问外网,请点击『否』。", true)) { nc.ProxyType = 0; } else if (MessageDialog.Question("您是否有确定的代理服务器地址以访问12306,或您的代理服务器需要用户名和密码才可以访问?如果属于以上情况,请点击『是』。", true)) { nc.ProxyType = 3; MessageDialog.Information("提示", "请继续在选项对话框中完成设置。"); using (var od = new ConfigCenter()) { od.SelectedConfig = od.FindConfigUI <NetworkConfig>().First(); od.ShowDialog(); } } else if (MessageDialog.Question("您的IE是否使用了PAC脚本?如果是的话,助手将无法为您的代理进行缓存,可能访问效果最慢。", true)) { nc.ProxyType = 2; } else { nc.ProxyType = 1; } MessageDialog.Information("提示", "设置完毕,感谢您的耐心。亲,祝你回家顺利 :-)"); }
private void MailStatus_Click(object sender, EventArgs e) { using (var f = new ConfigCenter()) { f.SelectConfigUI <MailConfig>(); f.ShowDialog(AppContext.HostForm); } }
public static ConfigCenter Instance() { if (ConfigCenterInstance == null) { ConfigCenterInstance = new ConfigCenter(); } return(ConfigCenterInstance); }
static void Main(string[] args) { ConfigCenter configCenter = new ConfigCenter(); string doorUrl = configCenter.WebSite.Door; Console.WriteLine(doorUrl); Console.ReadLine(); }
public static ConfigCenter LoadFromFile() { ConfigCenter config = new ConfigCenter(); using (StreamReader fs = new StreamReader(AppCenter.Instance.ConfigFile)) { config = DoLoadConfig(fs); } return(config); }
public static Dictionary <string, IConfigIO> GetConfigIOInstanceList(ConfigCenter config) { Dictionary <string, IConfigIO> retDic = new Dictionary <string, IConfigIO>(); Type[] configIOList = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttribute <ConfigIOAttr>() != null).ToArray(); foreach (Type type in configIOList) { retDic.Add(type.GetCustomAttribute <ConfigIOAttr>().Name, Activator.CreateInstance(type, new object[] { config }) as IConfigIO); } return(retDic); }
internal static ConfigCenter DoLoadMacAddress(ConfigCenter configCenter, StreamReader fs) { configCenter.MacAddressMap.Clear(); while (!fs.EndOfStream) { string lineStr = fs.ReadLine().Trim(); string[] oneData = lineStr.Split(' ').Where(t => !string.IsNullOrWhiteSpace(t)).ToArray(); if (oneData.Length == 2) { configCenter.MacAddressMap.Add(oneData[0], oneData[1]); } } return(configCenter); }
public static void SaveMacAddress(ConfigCenter configCenter) { if (isSaveMac) { return; } isSaveMac = true; using (StreamWriter fs = new StreamWriter(AppCenter.Instance.MacMapFile, false)) { Dictionary <string, string> macMap = configCenter.MacAddressMap; foreach (string mac in macMap.Keys) { fs.WriteLine($"{mac} {macMap[mac]}"); } } isSaveMac = false; }
public static ConfigCenter LoadFromFile() { ConfigCenter config = new ConfigCenter(); using (StreamReader fs = new StreamReader(AppCenter.Instance.ConfigFile)) { config = DoLoadConfig(fs); } if (File.Exists(AppCenter.Instance.MacMapFile)) { using (StreamReader fs = new StreamReader(AppCenter.Instance.MacMapFile)) { config = DoLoadMacAddress(config, fs); } } return(config); }
public Common(ConfigCenter config) { this.config = config; var methods = GetType().GetMethods().Where(t => t.GetCustomAttribute <ConfigMethodAttr>() != null); foreach (MethodInfo method in methods) { string configName = method.GetCustomAttribute <ConfigMethodAttr>().Name.ToUpper(); if (MethodDic.ContainsKey(configName)) { MethodDic[configName] = method; } else { MethodDic.Add(configName, method); } } }
void EngineAvailabilityTest_Load(object sender, EventArgs e) { using (lv.CreateBatchOperationDispatcher()) { lv.Items.AddRange(ServiceManager.Instance.ResourceProviders.Select(s => CreateItem(s, s.Info, s)) .Concat(ServiceManager.Instance.DownloadServiceProviders.Select(s => CreateItem(s, s.Info, s))) .ToArray() ); } btnSetProxy.Click += (s, x) => { var dlg = new ConfigCenter(); dlg.SelectConfigUI <NetworkOption>(); dlg.ShowDialog(this); }; btnRecheck.Click += (x, y) => RunTest(); RunTest(); }
public void BtnYes() { var filepath = m_DeleteObj.GetComponent <ClickMovieListItem>().GetFilePath(); ConfigCenter.Instance().DeleteFileByPath(filepath); var temphead = FileReader.GetHeadFromFile(filepath); var portraitpath = ToolFunction.GetDefaultPortraitPathByName(temphead.strPortrait, ".jpg"); if (File.Exists(portraitpath)) { File.Delete(portraitpath); } if (File.Exists(filepath)) { File.Delete(filepath); } Destroy(m_DeleteObj); Destroy(gameObject); }
public static ConfigCenter LoadFromString(string data) { ConfigCenter config = new ConfigCenter(); if (string.IsNullOrEmpty(data)) { throw new Exception("LoadFromString参数为为空"); } using (MemoryStream ms = new MemoryStream()) { StreamWriter sw = new StreamWriter(ms); sw.Write(data); sw.Flush(); StreamReader sr = new StreamReader(ms); sr.BaseStream.Position = 0; config = DoLoadConfig(sr); ms.Close(); } return(config); }
void MainForm_Shown(object sender, EventArgs e) { //代理提示 if (!AppContext.Instance.Options.ProxyWarningShown) { if (Question("您需要变更网络设置吗?")) { var dlg = new ConfigCenter() { StartPosition = FormStartPosition.CenterParent }; dlg.SelectConfigUI <NetworkOption>(); dlg.ShowDialog(this); } AppContext.Instance.Options.ProxyWarningShown = true; } if (!string.IsNullOrEmpty(Program.NewFeatureVersion) && AppContext.Instance.Options.NewFeatureVersion != Program.NewFeatureVersion) { new NewFeature().ShowDialog(this); } }
public void Btn_Save() { if (string.IsNullOrEmpty(m_InputDoctorName.text) || string.IsNullOrEmpty(m_InputFilePath.text)) { m_InputDoctorName.placeholder.GetComponent <Text>().color = Color.red; m_InputFilePath.placeholder.GetComponent <Text>().color = Color.red; } else { //根据输入的文件名和选择的头像,将文件存储到默认存储文件夹,将头像图片复制到默认头像存储文件夹 m_FilePath = ToolFunction.GetMovieSaveFilePath(m_InputFilePath.text, ".txt"); var tempPortrait = ToolFunction.GenerateStringID(); ToolFunction.ImageSaveLocal(m_PortraitImage.mainTexture, ToolFunction.GetDefaultPortraitPathByName(tempPortrait, ".jpg")); int tempTimeCount = m_RecordManager.GetFrameCount(); int tempStartTime = (int)(tempTimeCount * m_fLeftSliderValue); int tempEndTime = (int)(tempTimeCount * m_fRightSliderValue); MovieHeadData tempData = new MovieHeadData( "MOVIE_DATA", m_InputDoctorName.text, tempPortrait, System.DateTime.Now.ToString("MM/dd/yyyy H:mm:ss"), tempEndTime - tempStartTime, 0, ConfigCenter.Instance().GetFPS() ); m_RecordManager.SaveDataToFile( tempData, m_FilePath, tempStartTime, tempEndTime ); m_SavePanel.SetActive(false); m_InfoSaved.SetActive(true); } }
public void TestConfig_LoadFile() { ConfigCenter config = ConfigUtils.LoadFromFile(); Assert.AreNotEqual(config.PortMapList.Count, 0); }
void InitUI() { var targetImg = new[] { Properties.Resources.clock_16, Properties.Resources.stock_right, Properties.Resources.tick_16, Properties.Resources.delete_16, Properties.Resources.refresh, Properties.Resources.Block }; il.Images.AddRange(targetImg.Select(Utility.Get24PxImageFrom16PxImg).ToArray()); RefreshMarkMenu(); AppContext.Instance.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu(); tsMarkRes.DropDownOpening += tsMarkRes_DropDownOpening; mMarkOption.Click += (s, e) => { using (var dlg = new ConfigCenter()) { dlg.SelectedConfig = dlg.FindConfigUI <MarkOption>().First(); dlg.ShowDialog(); } }; mMarkNone.Click += SetMarkHandler; stProgressCurrent.Maximum = ServiceManager.Instance.DownloadServiceProviders.Count(); stProgressCurrent.Visible = false; stDownloadProgressTotal.Text = "0/0"; stStatus.Text = "当前没有任务等待下载"; stStatus.Image = Properties.Resources.tick_16; //任务操作 tsRemoveAll.Click += (s, e) => RemoveTasks(_ => true); tsRemoveFail.Click += (s, e) => RemoveTasks(_ => _.Status == QueueStatus.Failed); tsRemoveSucc.Click += (s, e) => RemoveTasks(_ => _.Status == QueueStatus.Succeed || _.Status == QueueStatus.Skipped); tsCopyMagnet.Click += (s, e) => { var items = queue.SelectedItems.Cast <DownloadQueueItem>().Select(x => x.ResourceItem).ToArray(); AppContext.Instance.ResourceOperation.CopyMagnetLink(items); }; queue.MouseDoubleClick += (s, e) => { var item = queue.SelectedItems.Cast <DownloadQueueItem>().FirstOrDefault(); if (item == null) { return; } if (item.Status == QueueStatus.Succeed) { //尝试打开 try { Process.Start(item.DownloadedFilePath); } catch (Exception) { } } else if (item.Status == QueueStatus.Failed) { lock (_downloadQueue) { item.Status = QueueStatus.Wait; _downloadQueue.Enqueue(item.ResourceItem); } } }; }
public PortMapItem(ConfigCenter config) { this.config = config; }
private void Start() { ListMovieByDirectory(ConfigCenter.Instance().GetDefaultDirPath()); ListMovieByFileNames(ConfigCenter.Instance().GetHistoryFilePathList()); }
// Use this for initialization void Awake() { ConfigCenter.Instance().ConfigDataInit(DataPath.strConfigFilePath); Application.targetFrameRate = ConfigCenter.Instance().GetFPS(); }
protected void Application_End(object sender, EventArgs e) { ConfigCenter.Stop(); }
public void LoadFromFile_Test() { ConfigCenter config = ConfigUtils.LoadFromFile(); Assert.AreNotEqual(config.AllowPortList.Count, 0); }
void InitMark() { ctxMarkType.Opening += (s, e) => { if (lv.FocusedItem == null) { e.Cancel = true; return; } var items = lv.SelectedFullItems; var rawItems = lv.SelectedItems; mDownloadTorrent.Visible = items.Any(x => x.BasicInfo.ResourceType == ResourceType.BitTorrent); mOpenDownloadPage.Visible = items.Any(x => x.BasicInfo.ResourceType == ResourceType.NetDisk); mCopyDownloadLink.Visible = items.Any(x => !x.BasicInfo.HasSubResources); //items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K); tsMultiResNotLoad.Visible = rawItems.Any(x => x.Resource.HasSubResources && x.Resource.SubResources == null); var itemView = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail(); mViewContent.Enabled = itemView?.ResourceType == ResourceType.BitTorrent; mViewDetail.Enabled = !string.IsNullOrEmpty(itemView?.Provider?.GetDetailUrl(itemView)); //resources mMarkDone.Enabled = mMarkUndone.Enabled = mMarkColor.Enabled = items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K || x.BasicInfo.ResourceType == ResourceType.BitTorrent); }; mViewDetail.Click += (s, e) => { var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail(); if (resource != null) { AppContext.Instance.ResourceOperation.ViewDetail(resource.Provider, resource); } }; mCopyDownloadLink.Click += (s, e) => AppContext.Instance.ResourceOperation.CopyDownloadLink(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray()); mMarkDone.Click += (s, e) => AppContext.Instance.ResourceOperation.MarkDone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray()); mMarkUndone.Click += (s, e) => AppContext.Instance.ResourceOperation.MarkUndone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray()); tsMultiResNotLoad.Click += (s, e) => { foreach (var item in lv.SelectedItems.Where(x => x.Resource.HasSubResources && x.Resource.SubResources == null)) { item.IsExpanded = true; } }; mViewContent.Click += (s, e) => { var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail(); if (resource != null) { AppContext.Instance.ResourceOperation.ViewTorrentContents(resource.Provider, resource); } }; mDownloadTorrent.Click += (s, e) => { var items = lv.SelectedFullItems; AppContext.Instance.ResourceOperation.AccquireDownloadTorrent(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray()); }; mOpenDownloadPage.Click += (s, e) => { var items = lv.SelectedFullItems; AppContext.Instance.ResourceOperation.OpenDownloadPage(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray()); }; lv.MouseDoubleClick += (s, e) => { var item = lv.FocusedItem; if (item == null) { return; } if (item.ChildItems.Count > 0) { item.IsExpanded = !item.IsExpanded; } else { ctxMarkType.Show(lv.PointToScreen(e.Location)); } }; lv.ItemExpand += (s, e) => { var item = e.Item as ResourceListViewItem; if (item.Resource.HasSubResources && item.Resource.SubResources == null) { Task.Factory.StartNew(() => item.Resource.Provider.LoadSubResources(item.Resource)); } }; AppContext.Instance.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu(); RefreshMarkMenu(); mMarkColor.DropDownOpening += mMarkColor_DropDownOpening; mMarkOption.Click += (s, e) => { using (var dlg = new ConfigCenter()) { dlg.SelectedConfig = dlg.FindConfigUI <MarkOption>().First(); dlg.ShowDialog(); } }; mMarkNone.Click += SetMarkHandler; }