public List<string> get(string name) { Setting setting = keyTest(name); List<string> result = source.read(setting); if (result.Count == 0) { result = new List<string>(); if (!String.IsNullOrEmpty(setting.DefaultValue)) { result.Add(setting.DefaultValue); } } return result; }
protected List<FileInfo> folderTraveller(string look_here) { List<FileInfo> return_me = new List<FileInfo>(); if (worker.CancellationPending) return return_me; try { foreach (FileInfo add_me in new DirectoryInfo(look_here).GetFiles()) { return_me.Add(add_me); } foreach (DirectoryInfo now_here in new DirectoryInfo(look_here).GetDirectories()) { return_me.AddRange(folderTraveller(now_here.FullName)); } } catch (UnauthorizedAccessException e) { outputLine(e.Message); } catch (DirectoryNotFoundException e) { outputLine(e.Message); } return return_me; }
void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { MonitorFile file; while (!worker.CancellationPending) { NotifyPropertyChanged("Active"); NotifyPropertyChanged("Status"); if (QueueCount == 0) { // No new files? Take a nap. try { Thread.Sleep(100); } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } continue; } lock (FileQueue) { file = FileQueue.Dequeue(); } if (!file.Path.Game.IsMonitored) continue; FileInfo fi = new FileInfo(Path.Combine(file.root, file.path)); GameID game = file.Path.Game.id; switch (file.change_type) { case System.IO.WatcherChangeTypes.Changed: case System.IO.WatcherChangeTypes.Created: case System.IO.WatcherChangeTypes.Renamed: if (!fi.Exists) continue; List<DetectedFile> these_files = file.Path.Game.GetSavesMatching(file.full_path); if (these_files.Count == 0) continue; foreach (DetectedFile this_file in these_files) { _status = game.Name + " updating " + Path.Combine(this_file.Path, this_file.Name); NotifyPropertyChanged("Status"); if (this_file.full_dir_path == null) continue; Archive archive = Archives.GetArchive( game, this_file); try { if (archive == null) { if (this_file.owner == null) archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file)); else archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file)); Archives.Add(archive); } //monitorNotifier.ShowBalloonTip(10, "Safety Will Robinson", "Trying to archive " + file.path, ToolTipIcon.Info); MessageHandler.suppress_messages = true; List<DetectedFile> temp_list = new List<DetectedFile>(); temp_list.Add(this_file); archive.backup(temp_list, false, true); } catch { //monitorNotifier.ShowBalloonTip(10,"Danger Will Robinson","Error while trying to archive " + file.path,ToolTipIcon.Error); // If something goes wrong during backup, it's probable the file copy. // Reinsert the file to the end of the queue, then move on to the next one. if (!FileQueue.Contains(file)) { FileQueue.Enqueue(file); } } finally { MessageHandler.suppress_messages = false; } } break; } if (worker.CancellationPending) e.Cancel = true; _status = null; } NotifyPropertyChanged("Status"); NotifyPropertyChanged("Active"); }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create); // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie var cookieOptions = new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }; app.UseCookieAuthentication(cookieOptions); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); // Enables the application to remember the second login verification factor such as phone or email. // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. // This is similar to the RememberMe option when you log in. app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); // Uncomment the following lines to enable logging in with third party login providers //app.UseMicrosoftAccountAuthentication( // clientId: "", // clientSecret: ""); //app.UseTwitterAuthentication( // consumerKey: "", // consumerSecret: ""); //app.UseFacebookAuthentication( // appId: "", // appSecret: ""); //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() //{ // ClientId = "", // ClientSecret = "" //}); //Enable Mixed Authentication //As we are using LogonUserIdentity, its required to run in PipelineStage.PostAuthenticate //Register this after any middleware that uses stage marker PipelineStage.Authenticate //See http://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline // Enable mixed auth app.UseMixedAuth(new MixedAuthOptions() { Provider = new MixedAuthProvider() { OnImportClaims = identity => { List<Claim> claims = new List<Claim>(); using (var principalContext = new PrincipalContext(ContextType.Domain | ContextType.Machine)) { using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, identity.Name)) { if (userPrincipal != null) { claims.Add(new Claim(ClaimTypes.Email, userPrincipal.EmailAddress ?? string.Empty)); claims.Add(new Claim(ClaimTypes.Surname, userPrincipal.Surname ?? string.Empty)); claims.Add(new Claim(ClaimTypes.GivenName, userPrincipal.GivenName ?? string.Empty)); } } } return claims; } } }, cookieOptions); }
private void button3_Click(object sender, EventArgs e) { pictureBox1.Cursor = Cursors.Default; flowLayoutPanel1.Visible = true; flowLayoutPanel1.Controls.Clear(); flowLayoutPanel1.Controls.Add(button6); button6.Visible = true; List<PictureBox> pbList = new List<PictureBox>(); int i = 0; ResourceManager rm = Properties.Resources.ResourceManager; ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true); if (rs != null) { var images = from entry in rs.Cast<DictionaryEntry>() where entry.Value is Image select entry.Value; foreach (Image img in images) { pbList.Add(new PictureBox() { Image = img, Width = button6.Width, Height = flowLayoutPanel1.Width/2, SizeMode = PictureBoxSizeMode.StretchImage }); flowLayoutPanel1.Controls.Add(pbList[i]); pbList[i].Click += delegate(object o, EventArgs ee) { pbList.ForEach(b => b.BorderStyle = BorderStyle.None); ((PictureBox)o).BorderStyle = BorderStyle.FixedSingle; pictureBox1.Image = ((PictureBox)o).Image; }; i++; } } }