[longomatch] Add an optimization when retrieving by name
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add an optimization when retrieving by name
- Date: Fri, 17 Apr 2015 16:27:17 +0000 (UTC)
commit 84e574d01b51030f4a6bd661d4c9602322faaa9a
Author: Jorge Zapata <jorgeluis zapata gmail com>
Date: Wed Apr 15 14:00:00 2015 +0200
Add an optimization when retrieving by name
In case we only look for templates by name, on the filestorage
try to find a file with that filename.
LongoMatch.Services/FileStorage.cs | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.Services/FileStorage.cs b/LongoMatch.Services/FileStorage.cs
index cbeb77a..357a976 100644
--- a/LongoMatch.Services/FileStorage.cs
+++ b/LongoMatch.Services/FileStorage.cs
@@ -171,6 +171,18 @@ namespace LongoMatch.Services.Services
if (dict == null)
return RetrieveAll<T> ();
+ // In case the only keyword is name try to find the files by name
+ if (dict.ContainsKey ("Name") && dict.Keys.Count == 1) {
+ string path = Path.Combine (typePath, dict["Name"] + GetExtension
(typeof(T)));
+
+ if (File.Exists (path)) {
+ T t = Serializer.LoadSafe<T> (path);
+ Log.Information ("Retrieving by filename " + path);
+ l.Add (t);
+ return l;
+ }
+ }
+
// Get the name of the class and look for a folder on the
// basePath with the same name
foreach (string path in Directory.GetFiles (typePath, "*" + extension)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]