coding style

This commit is contained in:
Markus Stoll 2014-10-21 14:40:04 +02:00 committed by Hylke Bons
parent c26dc8318f
commit 778490580f
3 changed files with 26 additions and 26 deletions

View file

@ -62,16 +62,16 @@ namespace SparkleShare {
this.watcher.Changed += OnFilesChanged; this.watcher.Changed += OnFilesChanged;
} }
private void OnFilesChanged(List<string> changedFilesInBasedir) private void OnFilesChanged(List<string> changed_files_in_basedir)
{ {
Dictionary<SparkleRepoBase, List<string>> changeDict = new Dictionary<SparkleRepoBase, List<string>> (); Dictionary<SparkleRepoBase, List<string>> change_dict = new Dictionary<SparkleRepoBase, List<string>> ();
foreach (string file in changedFilesInBasedir) { foreach (string file in changed_files_in_basedir) {
string repo_name; string repo_name;
int pathSepIndex = file.IndexOf (Path.DirectorySeparatorChar); int path_sep_index = file.IndexOf (Path.DirectorySeparatorChar);
if (pathSepIndex >= 0) if (path_sep_index >= 0)
repo_name = file.Substring (0, pathSepIndex); repo_name = file.Substring (0, path_sep_index);
else else
repo_name = file; repo_name = file;
@ -83,18 +83,18 @@ namespace SparkleShare {
List<string> changes; List<string> changes;
if (changeDict.ContainsKey (repo)) if (change_dict.ContainsKey (repo))
changes = changeDict [repo]; changes = change_dict [repo];
else { else {
changes = new List<string> (); changes = new List<string> ();
changeDict.Add (repo, changes); change_dict.Add (repo, changes);
} }
changes.Add (Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, file)); changes.Add (Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, file));
} }
foreach (SparkleRepoBase repo in changeDict.Keys) { foreach (SparkleRepoBase repo in change_dict.Keys) {
foreach (string file in changeDict[repo]) { foreach (string file in change_dict[repo]) {
FileActivityTask task = MacActivityTask ( FileActivityTask task = MacActivityTask (
repo, repo,
new FileSystemEventArgs(WatcherChangeTypes.Changed, file, "unknown") new FileSystemEventArgs(WatcherChangeTypes.Changed, file, "unknown")

View file

@ -151,19 +151,19 @@ namespace SparkleShare {
var handler = Changed; var handler = Changed;
if (handler != null) { if (handler != null) {
List<string> filteredPaths = new List<string> (); List<string> filtered_paths = new List<string> ();
foreach (var path in paths) { foreach (var path in paths) {
if (path.Length > BasePath.Length) { if (path.Length > BasePath.Length) {
var t = path.Substring (BasePath.Length); var t = path.Substring (BasePath.Length);
t = t.Trim ("/".ToCharArray ()); t = t.Trim ("/".ToCharArray ());
if (!string.IsNullOrWhiteSpace (t)) if (!string.IsNullOrWhiteSpace (t))
filteredPaths.Add(t); filtered_paths.Add(t);
} }
} }
if(filteredPaths.Count > 0) if(filtered_paths.Count > 0)
handler (filteredPaths); handler (filtered_paths);
} }
GC.KeepAlive (this); GC.KeepAlive (this);

View file

@ -30,32 +30,32 @@ namespace SparkleShare {
public SparkleRepoBase [] Repositories { public SparkleRepoBase [] Repositories {
get { get {
lock (this.repo_lock) lock (this.repo_lock)
return this.sortedRepositories.GetRange (0, this.sortedRepositories.Count).ToArray (); return this.sorted_repositories.GetRange (0, this.sorted_repositories.Count).ToArray ();
} }
} }
private void AddRepository(SparkleRepoBase repo) private void AddRepository(SparkleRepoBase repo)
{ {
lock (this.repo_lock) { lock (this.repo_lock) {
sortedRepositories.Add (repo); sorted_repositories.Add (repo);
repositoryDict.Add (repo.Name, repo); repository_dict.Add (repo.Name, repo);
sortedRepositories.Sort ((x, y) => string.Compare (x.Name, y.Name)); sorted_repositories.Sort ((x, y) => string.Compare (x.Name, y.Name));
} }
} }
private void RemoveRepository(SparkleRepoBase repo) private void RemoveRepository(SparkleRepoBase repo)
{ {
lock (this.repo_lock) { lock (this.repo_lock) {
sortedRepositories.Remove (repo); sorted_repositories.Remove (repo);
repositoryDict.Remove (repo.Name); repository_dict.Remove (repo.Name);
} }
} }
public SparkleRepoBase GetRepositoryByName(string name) public SparkleRepoBase GetRepositoryByName(string name)
{ {
lock (this.repo_lock) { lock (this.repo_lock) {
if(repositoryDict.ContainsKey(name)) if(repository_dict.ContainsKey(name))
return repositoryDict [name]; return repository_dict [name];
return null; return null;
} }
@ -181,8 +181,8 @@ namespace SparkleShare {
private FileSystemWatcher watcher; private FileSystemWatcher watcher;
private Object repo_lock = new Object (); private Object repo_lock = new Object ();
private Object check_repos_lock = new Object (); private Object check_repos_lock = new Object ();
private List<SparkleRepoBase> sortedRepositories = new List<SparkleRepoBase> (); private List<SparkleRepoBase> sorted_repositories = new List<SparkleRepoBase> ();
private Dictionary<string, SparkleRepoBase> repositoryDict = new Dictionary<string, SparkleRepoBase> (); private Dictionary<string, SparkleRepoBase> repository_dict = new Dictionary<string, SparkleRepoBase> ();
private bool lost_folders_path = false; private bool lost_folders_path = false;
@ -498,7 +498,7 @@ namespace SparkleShare {
private void RemoveRepository (string folder_path) private void RemoveRepository (string folder_path)
{ {
foreach (SparkleRepoBase repo in this.sortedRepositories) { foreach (SparkleRepoBase repo in this.sorted_repositories) {
if (repo.LocalPath.Equals (folder_path)) { if (repo.LocalPath.Equals (folder_path)) {
RemoveRepository (repo); RemoveRepository (repo);
repo.Dispose (); repo.Dispose ();