diff --git a/BaseTemplate.sln b/BaseTemplate.sln
index 3275b69..217dd04 100644
--- a/BaseTemplate.sln
+++ b/BaseTemplate.sln
@@ -7,11 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseTemplate.Android", "Bas
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseTemplate.iOS", "BaseTemplate\BaseTemplate.iOS\BaseTemplate.iOS.csproj", "{F1E21F2E-4A53-4DDA-A198-1B778CAD73C8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseTemplate", "BaseTemplate\BaseTemplate\BaseTemplate.csproj", "{C632F893-3A9D-419A-B680-3CF5940D6921}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaseTemplate", "BaseTemplate\BaseTemplate\BaseTemplate.csproj", "{C632F893-3A9D-419A-B680-3CF5940D6921}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateFoundation", "TemplateFoundation\TemplateFoundation.csproj", "{902D1E2F-17A1-40E9-9B68-99C6D1D5DE6B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemplateFoundationUnitTest", "TemplateFoundationUnitTest\TemplateFoundationUnitTest.csproj", "{0FBF1B04-403E-4330-892D-2A6E547F4B3A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateFoundationUnitTest", "TemplateFoundationUnitTest\TemplateFoundationUnitTest.csproj", "{0FBF1B04-403E-4330-892D-2A6E547F4B3A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreServices", "CoreServices\CoreServices.csproj", "{F7937D67-C44C-4305-B645-C0C4F67F8B88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -101,6 +103,18 @@ Global
{0FBF1B04-403E-4330-892D-2A6E547F4B3A}.Release|iPhone.Build.0 = Release|Any CPU
{0FBF1B04-403E-4330-892D-2A6E547F4B3A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{0FBF1B04-403E-4330-892D-2A6E547F4B3A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|iPhone.Build.0 = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/BaseTemplate/BaseTemplate.Android/BaseTemplate.Android.csproj b/BaseTemplate/BaseTemplate.Android/BaseTemplate.Android.csproj
index 8220a2e..a0bad56 100644
--- a/BaseTemplate/BaseTemplate.Android/BaseTemplate.Android.csproj
+++ b/BaseTemplate/BaseTemplate.Android/BaseTemplate.Android.csproj
@@ -84,9 +84,6 @@
2.3.0.759
-
- 1.1.3
-
@@ -121,6 +118,10 @@
+
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}
+ CoreServices
+
{C632F893-3A9D-419A-B680-3CF5940D6921}
BaseTemplate
diff --git a/BaseTemplate/BaseTemplate.Android/MainActivity.cs b/BaseTemplate/BaseTemplate.Android/MainActivity.cs
index c58aa5e..8bbda0d 100644
--- a/BaseTemplate/BaseTemplate.Android/MainActivity.cs
+++ b/BaseTemplate/BaseTemplate.Android/MainActivity.cs
@@ -5,8 +5,8 @@
using Android.OS;
using System;
using System.Threading.Tasks;
-using BaseTemplate.Constants;
using System.Diagnostics;
+using CoreServices.Constants;
namespace BaseTemplate.Droid
{
diff --git a/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/NotifierImplementation.cs b/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/NotifierImplementation.cs
index c870d7b..9ede06d 100644
--- a/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/NotifierImplementation.cs
+++ b/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/NotifierImplementation.cs
@@ -7,7 +7,7 @@
using Android.OS;
using Android.Support.V4.App;
using BaseTemplate.Droid.Services.LocalNotificationService;
-using BaseTemplate.Services.LocalNotificationService;
+using CoreServices.LocalNotificationsServices;
using Xamarin.Forms;
using AndroidApp = Android.App.Application;
using TaskStackBuilder = Android.Support.V4.App.TaskStackBuilder;
diff --git a/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/ScheduledAlarmHandler.cs b/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/ScheduledAlarmHandler.cs
index 3dd3a07..b33cb4d 100644
--- a/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/ScheduledAlarmHandler.cs
+++ b/BaseTemplate/BaseTemplate.Android/Services/LocalNotificationService/ScheduledAlarmHandler.cs
@@ -1,7 +1,7 @@
using System.IO;
using System.Xml.Serialization;
using Android.Content;
-using BaseTemplate.Services.LocalNotificationService;
+using CoreServices.LocalNotificationsServices;
using Xamarin.Forms;
namespace BaseTemplate.Droid.Services.LocalNotificationService
diff --git a/BaseTemplate/BaseTemplate.iOS/AppDelegate.cs b/BaseTemplate/BaseTemplate.iOS/AppDelegate.cs
index 868f8d5..279d988 100644
--- a/BaseTemplate/BaseTemplate.iOS/AppDelegate.cs
+++ b/BaseTemplate/BaseTemplate.iOS/AppDelegate.cs
@@ -1,11 +1,8 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
-
-using BaseTemplate.Constants;
-
+using CoreServices.Constants;
using Foundation;
-
using UIKit;
namespace BaseTemplate.iOS
diff --git a/BaseTemplate/BaseTemplate.iOS/BaseTemplate.iOS.csproj b/BaseTemplate/BaseTemplate.iOS/BaseTemplate.iOS.csproj
index 45abf6d..6028715 100644
--- a/BaseTemplate/BaseTemplate.iOS/BaseTemplate.iOS.csproj
+++ b/BaseTemplate/BaseTemplate.iOS/BaseTemplate.iOS.csproj
@@ -154,12 +154,13 @@
2.3.0.759
-
- 1.1.3
-
+
+ {F7937D67-C44C-4305-B645-C0C4F67F8B88}
+ CoreServices
+
{C632F893-3A9D-419A-B680-3CF5940D6921}
BaseTemplate
diff --git a/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/INotifierImplementation.cs b/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/INotifierImplementation.cs
index 77fac3a..1857332 100644
--- a/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/INotifierImplementation.cs
+++ b/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/INotifierImplementation.cs
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics;
using BaseTemplate.iOS.Services.LocalNotificationService;
-using BaseTemplate.Services.LocalNotificationService;
+using CoreServices.LocalNotificationsServices;
using Foundation;
using UserNotifications;
using Xamarin.Forms;
diff --git a/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/IosNotificationReceiver.cs b/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/IosNotificationReceiver.cs
index d70e090..4218c34 100644
--- a/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/IosNotificationReceiver.cs
+++ b/BaseTemplate/BaseTemplate.iOS/Services/LocalNotificationService/IosNotificationReceiver.cs
@@ -1,5 +1,5 @@
using System;
-using BaseTemplate.Services.LocalNotificationService;
+using CoreServices.LocalNotificationsServices;
using UserNotifications;
using Xamarin.Forms;
diff --git a/BaseTemplate/BaseTemplate/App.xaml.cs b/BaseTemplate/BaseTemplate/App.xaml.cs
index 566dd57..6f5701d 100644
--- a/BaseTemplate/BaseTemplate/App.xaml.cs
+++ b/BaseTemplate/BaseTemplate/App.xaml.cs
@@ -1,56 +1,56 @@
-using System.Globalization;
+using BaseTemplate.ViewModels;
+using CoreServices.DataServices.LocalDatabaseService;
+using CoreServices.FileService;
+using CoreServices.TranslationService;
+using System.Globalization;
using System.Threading;
-using BaseTemplate.Resources;
-using BaseTemplate.Services.FileSystemService;
-using BaseTemplate.Services.LocalDatabaseService;
-using BaseTemplate.ViewModels;
using TemplateFoundation.IOCFoundation;
using TemplateFoundation.Navigation.NavigationContainers;
using Xamarin.Forms;
namespace BaseTemplate
{
- public partial class App : Application
- {
- public App()
- {
- InitializeComponent();
+ public partial class App : Application
+ {
+ public App()
+ {
+ InitializeComponent();
- SetupDependencyInjection();
- CreateDataBaseTables();
- SetDefaultLanguage();
- SetStartPage();
- }
+ SetupDependencyInjection();
+ CreateDataBaseTables();
+ SetDefaultLanguage();
+ SetStartPage();
+ }
- private void SetupDependencyInjection()
- {
- Ioc.Container.Register().AsSingleton();
- Ioc.Container.Register().AsSingleton();
- }
- ///
- /// Create your database tables that you need
- ///
- private void CreateDataBaseTables()
- {
- // Ioc.Container.Resolve().CreateDatabaseTables(Send List of tabels);
- }
- ///
- /// Set your default language for the entire app
- /// Just change culture info ar,en,fr,es
- ///
- private void SetDefaultLanguage()
- {
- Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
+ private void SetupDependencyInjection()
+ {
+ Ioc.Container.Register().AsSingleton();
+ Ioc.Container.Register().AsSingleton();
+ }
+ ///
+ /// Create your database tables that you need
+ ///
+ private void CreateDataBaseTables()
+ {
+ // Ioc.Container.Resolve().CreateDatabaseTables(Send List of tabels);
+ }
+ ///
+ /// Set your default language for the entire app
+ /// Just change culture info ar,en,fr,es
+ ///
+ private void SetDefaultLanguage()
+ {
+ Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
- AppResources.Culture = new CultureInfo("en");
- }
+ AppResources.Culture = new CultureInfo("en");
+ }
- private void SetStartPage()
- {
- var masterDetailNav = new MasterDetailNavigationContainer();
- masterDetailNav.Init("Fawakeh");
- masterDetailNav.AddPage();
- MainPage = masterDetailNav;
- }
- }
+ private void SetStartPage()
+ {
+ MasterDetailNavigationContainer masterDetailNav = new MasterDetailNavigationContainer();
+ masterDetailNav.Init("Fawakeh");
+ masterDetailNav.AddPage();
+ MainPage = masterDetailNav;
+ }
+ }
}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/BaseTemplate.csproj b/BaseTemplate/BaseTemplate/BaseTemplate.csproj
index 2c8a690..897ab99 100644
--- a/BaseTemplate/BaseTemplate/BaseTemplate.csproj
+++ b/BaseTemplate/BaseTemplate/BaseTemplate.csproj
@@ -29,10 +29,8 @@
-
-
@@ -40,14 +38,5 @@
MainPage.xaml
-
- AppResources.resx
-
-
-
-
- ResXFileCodeGenerator
- AppResources.Designer.cs
-
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Constants/AppConstants.cs b/BaseTemplate/BaseTemplate/Constants/AppConstants.cs
deleted file mode 100644
index f557c0e..0000000
--- a/BaseTemplate/BaseTemplate/Constants/AppConstants.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-namespace BaseTemplate.Constants
-{
- public static class AppConstants
- {
- #region Constants
- public const string ErrorFileName = "Fatal.log";
-
- public const string DatabaseFileName = "localDatabase.db3";
- #endregion
- }
-}
diff --git a/BaseTemplate/BaseTemplate/Resources/AppResources.Designer.cs b/BaseTemplate/BaseTemplate/Resources/AppResources.Designer.cs
deleted file mode 100644
index 23b4258..0000000
--- a/BaseTemplate/BaseTemplate/Resources/AppResources.Designer.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace BaseTemplate.Resources {
- using System;
- using System.Reflection;
-
-
- [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class AppResources {
-
- private static System.Resources.ResourceManager resourceMan;
-
- private static System.Globalization.CultureInfo resourceCulture;
-
- [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal AppResources() {
- }
-
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static System.Resources.ResourceManager ResourceManager {
- get {
- if (object.Equals(null, resourceMan)) {
- System.Resources.ResourceManager temp = new System.Resources.ResourceManager("BaseTemplate.Resources.AppResources", typeof(AppResources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/BaseTemplate/BaseTemplate/Services/FileSystemService/FileSystemService.cs b/BaseTemplate/BaseTemplate/Services/FileSystemService/FileSystemService.cs
deleted file mode 100644
index c193c60..0000000
--- a/BaseTemplate/BaseTemplate/Services/FileSystemService/FileSystemService.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.IO;
-using System.Threading.Tasks;
-using Xamarin.Essentials;
-
-namespace BaseTemplate.Services.FileSystemService
-{
- public class FileSystemService : IFileSystemService
- {
- public string GetFilePath(string filename)
- {
- return Path.Combine(FileSystem.AppDataDirectory, filename);
- }
-
- public async Task OpenFileStream(string filename)
- {
- return await FileSystem.OpenAppPackageFileAsync(filename);
- }
- }
-}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Services/FileSystemService/IFileSystemService.cs b/BaseTemplate/BaseTemplate/Services/FileSystemService/IFileSystemService.cs
deleted file mode 100644
index 9dfc830..0000000
--- a/BaseTemplate/BaseTemplate/Services/FileSystemService/IFileSystemService.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.IO;
-using System.Threading.Tasks;
-
-namespace BaseTemplate.Services.FileSystemService
-{
- public interface IFileSystemService
- {
- string GetFilePath(string filename);
- Task OpenFileStream(string filename);
- }
-}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/ILocalDatabaseService.cs b/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/ILocalDatabaseService.cs
deleted file mode 100644
index 052aa94..0000000
--- a/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/ILocalDatabaseService.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Threading.Tasks;
-using SQLite;
-
-namespace BaseTemplate.Services.LocalDatabaseService
-{
- public interface ILocalDatabaseService
- {
- Task CreateDatabaseTables(List tables);
- Task CreateDatabaseTables(List tables, CreateFlags tableCreateFlags);
- Task> GetAll() where T : class, new();
- Task Insert(object item);
- Task InsertAll(List items) where T : new();
- Task Update(object item);
- Task UpdateAll(List items) where T : new();
- Task Delete(object obj);
- Task DeleteAll() where T : new();
- Task DropTableAsync() where T : new();
- Task> QueryString(string sql) where T : class, new();
- Task> GetTableInfo(string tableName);
- Task> GetAll(Expression> query) where T : new();
- Task GetOne(Expression> query) where T : class, new();
- Task InsertOrReplaceAll(List items) where T : new();
- Task InsertOrReplaceOne(object item) where T : new();
- Task DeleteAll(List items) where T : new();
- Task ExecuteAsync(string sqlQuery);
- }
-}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/LocalDatabaseService.cs b/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/LocalDatabaseService.cs
deleted file mode 100644
index d65fee9..0000000
--- a/BaseTemplate/BaseTemplate/Services/LocalDatabaseService/LocalDatabaseService.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Threading.Tasks;
-using BaseTemplate.Constants;
-using SQLite;
-using Xamarin.Essentials;
-
-namespace BaseTemplate.Services.LocalDatabaseService
-{
- public class LocalDatabaseService : ILocalDatabaseService
- {
- #region Flags
-
- public const SQLiteOpenFlags Flags =
- // open the database in read/write mode
- SQLiteOpenFlags.ReadWrite |
- // create the database if it doesn't exist
- SQLiteOpenFlags.Create |
- // enable multi-threaded database access
- SQLiteOpenFlags.SharedCache |
- // Encrypts The Database File
- SQLiteOpenFlags.ProtectionComplete;
-
- #endregion
-
- #region Statics
-
- public static string DatabasePath => Path.Combine(FileSystem.AppDataDirectory, AppConstants.DatabaseFileName);
-
- private static readonly Lazy LazyInitializer =
- new Lazy(() => new SQLiteAsyncConnection(DatabasePath, Flags));
-
- private static SQLiteAsyncConnection SqlCon => LazyInitializer.Value;
-
- public static bool DbInitialized;
-
- #endregion
-
- #region Methods
-
- public async Task CreateDatabaseTables(List tables)
- {
- foreach (Type item in tables)
- try
- {
- if (SqlCon.TableMappings.Any(m => m.MappedType.Name == item.Name)) continue;
- await SqlCon.CreateTableAsync(item).ConfigureAwait(false);
- DbInitialized = true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- public async Task CreateDatabaseTables(List tables, CreateFlags tableCreateFlags)
- {
- foreach (Type item in tables)
- try
- {
- if (SqlCon.TableMappings.Any(m => m.MappedType.Name == item.Name)) continue;
- await SqlCon.CreateTableAsync(item, tableCreateFlags).ConfigureAwait(false);
- DbInitialized = true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- public async Task> GetTableInfo(string tableName)
- {
- return await SqlCon.GetTableInfoAsync(tableName);
- }
-
-
- public async Task GetOne(Expression> query) where T : class, new()
- {
- try
- {
- return await SqlCon.Table().Where(query).FirstOrDefaultAsync();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- public async Task> GetAll(Expression> query) where T : new()
- {
- try
- {
- return await SqlCon.Table().Where(query).ToListAsync();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
- public async Task> GetAll() where T : class, new()
- {
- return await SqlCon.Table().ToListAsync().ConfigureAwait(false);
- }
-
- public async Task Insert(object item)
- {
- try
- {
- return await SqlCon.InsertAsync(item).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
- public async Task InsertAll(List items) where T : new()
- {
- return await SqlCon.InsertAllAsync(items).ConfigureAwait(false);
- }
-
-
- public async Task InsertOrReplaceOne(object item) where T : new()
- {
- return await SqlCon.InsertOrReplaceAsync(item).ConfigureAwait(false);
- }
-
-
- public async Task InsertOrReplaceAll(List items) where T : new()
- {
- foreach (T item in items) await SqlCon.InsertOrReplaceAsync(item).ConfigureAwait(false);
- }
-
-
- public async Task Update(object item)
- {
- return await SqlCon.UpdateAsync(item).ConfigureAwait(false);
- }
-
-
- public async Task UpdateAll(List items) where T : new()
- {
- return await SqlCon.UpdateAllAsync(items).ConfigureAwait(false);
- }
-
-
- public async Task Delete(object item)
- {
- return await SqlCon.DeleteAsync(item).ConfigureAwait(false);
- }
-
-
- public async Task DeleteAll() where T : new()
- {
- return await SqlCon.DeleteAllAsync().ConfigureAwait(false);
- }
-
-
- public async Task DeleteAll(List items) where T : new()
- {
- foreach (T item in items) await SqlCon.DeleteAsync(item).ConfigureAwait(false);
- }
-
-
- public async Task> QueryString(string sql) where T : class, new()
- {
- return await SqlCon.QueryAsync(sql);
- }
-
-
- public async Task DropTableAsync() where T : new()
- {
- return await SqlCon.DropTableAsync();
- }
-
-
- public async Task ExecuteAsync(string sqlQuery)
- {
- try
- {
- return await SqlCon.ExecuteAsync(sqlQuery);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Services/LocalNotificationService/ILocalNotificationService.cs b/BaseTemplate/BaseTemplate/Services/LocalNotificationService/ILocalNotificationService.cs
deleted file mode 100644
index a567f19..0000000
--- a/BaseTemplate/BaseTemplate/Services/LocalNotificationService/ILocalNotificationService.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-
-namespace BaseTemplate.Services.LocalNotificationService
-{
- public interface ILocalNotificationService
- {
- ///
- /// The Executed Behaviour when the app receives a notification
- ///
- event EventHandler NotificationReceived;
-
- ///
- /// Executes the platform Specific service initiation code
- ///
- void Initialize();
-
- ///
- /// Show a local notification now
- ///
- /// Title of the notification
- /// Body or description of the notification
- /// Id of the notification
- void Notify(string title, string body, int id = 0);
-
- ///
- /// Show a local notification at a certain date and time
- ///
- /// Title of the notification
- /// Body or description of the notification
- /// The date and time the notification should be fired
- /// Id of the notification
- void Notify(string title, string body, DateTime notificationDateTime, int id = 0);
-
- ///
- /// Cancel a local notification
- ///
- /// Id of the notification to cancel
- void Cancel(int id);
-
- ///
- /// Channels the parameters to the "NotificationReceived" event when a notification is fired
- ///
- void ReceiveNotification(string title, string message);
- }
-}
\ No newline at end of file
diff --git a/BaseTemplate/BaseTemplate/Services/LocalNotificationService/NotificationEventArgs.cs b/BaseTemplate/BaseTemplate/Services/LocalNotificationService/NotificationEventArgs.cs
deleted file mode 100644
index 0428ea0..0000000
--- a/BaseTemplate/BaseTemplate/Services/LocalNotificationService/NotificationEventArgs.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-
-namespace BaseTemplate.Services.LocalNotificationService
-{
- public class NotificationEventArgs : EventArgs
- {
- public string Title { get; set; }
- public string Message { get; set; }
- }
-}
\ No newline at end of file
diff --git a/CoreServices/Constants/AppConstants.cs b/CoreServices/Constants/AppConstants.cs
new file mode 100644
index 0000000..6e86d9c
--- /dev/null
+++ b/CoreServices/Constants/AppConstants.cs
@@ -0,0 +1,13 @@
+namespace CoreServices.Constants
+{
+ public static class AppConstants
+ {
+ #region Constants
+
+ public const string ErrorFileName = "Fatal.log";
+
+ public const string DatabaseFileName = "localDatabase.db3";
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/CoreServices.csproj b/CoreServices/CoreServices.csproj
new file mode 100644
index 0000000..a084833
--- /dev/null
+++ b/CoreServices/CoreServices.csproj
@@ -0,0 +1,32 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+ AppResources.resx
+ True
+ True
+
+
+
+
+
+ AppResources.Designer.cs
+ PublicResXFileCodeGenerator
+
+
+
+
+
+
+
+
diff --git a/CoreServices/DataServices/LocalDatabaseService/ILocalDatabaseService.cs b/CoreServices/DataServices/LocalDatabaseService/ILocalDatabaseService.cs
new file mode 100644
index 0000000..ac4699b
--- /dev/null
+++ b/CoreServices/DataServices/LocalDatabaseService/ILocalDatabaseService.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
+using SQLite;
+
+namespace CoreServices.DataServices.LocalDatabaseService
+{
+ public interface ILocalDatabaseService
+ {
+ Task CreateDatabaseTables(List tables);
+ Task CreateDatabaseTables(List tables, CreateFlags tableCreateFlags);
+ Task> GetAll() where T : class, new();
+ Task Insert(object item);
+ Task InsertAll(List items) where T : new();
+ Task Update(object item);
+ Task UpdateAll(List items) where T : new();
+ Task Delete(object obj);
+ Task DeleteAll() where T : new();
+ Task DropTableAsync() where T : new();
+ Task> QueryString(string sql) where T : class, new();
+ Task> GetTableInfo(string tableName);
+ Task> GetAll(Expression> query) where T : new();
+ Task GetOne(Expression> query) where T : class, new();
+ Task InsertOrReplaceAll(List items) where T : new();
+ Task InsertOrReplaceOne(object item) where T : new();
+ Task DeleteAll(List items) where T : new();
+ Task ExecuteAsync(string sqlQuery);
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/DataServices/LocalDatabaseService/LocalDatabaseService.cs b/CoreServices/DataServices/LocalDatabaseService/LocalDatabaseService.cs
new file mode 100644
index 0000000..9f900b7
--- /dev/null
+++ b/CoreServices/DataServices/LocalDatabaseService/LocalDatabaseService.cs
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
+using CoreServices.Constants;
+using SQLite;
+using Xamarin.Essentials;
+
+namespace CoreServices.DataServices.LocalDatabaseService
+{
+ public class LocalDatabaseService : ILocalDatabaseService
+ {
+ #region Flags
+
+ public const SQLiteOpenFlags Flags =
+ // open the database in read/write mode
+ SQLiteOpenFlags.ReadWrite |
+ // create the database if it doesn't exist
+ SQLiteOpenFlags.Create |
+ // enable multi-threaded database access
+ SQLiteOpenFlags.SharedCache |
+ // Encrypts The Database File
+ SQLiteOpenFlags.ProtectionComplete;
+
+ #endregion
+
+ #region Statics
+
+ public static string DatabasePath => Path.Combine(FileSystem.AppDataDirectory, AppConstants.DatabaseFileName);
+
+ private static readonly Lazy LazyInitializer =
+ new Lazy(() => new SQLiteAsyncConnection(DatabasePath, Flags));
+
+ private static SQLiteAsyncConnection SqlCon => LazyInitializer.Value;
+
+ public static bool DbInitialized;
+
+ #endregion
+
+ #region Methods
+
+ public async Task CreateDatabaseTables(List tables)
+ {
+ foreach (Type item in tables)
+ try
+ {
+ if (SqlCon.TableMappings.Any(m => m.MappedType.Name == item.Name)) continue;
+
+ await SqlCon.CreateTableAsync(item).ConfigureAwait(false);
+ DbInitialized = true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ public async Task CreateDatabaseTables(List tables, CreateFlags tableCreateFlags)
+ {
+ foreach (Type item in tables)
+ try
+ {
+ if (SqlCon.TableMappings.Any(m => m.MappedType.Name == item.Name)) continue;
+
+ await SqlCon.CreateTableAsync(item, tableCreateFlags).ConfigureAwait(false);
+ DbInitialized = true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ public async Task> GetTableInfo(string tableName)
+ {
+ return await SqlCon.GetTableInfoAsync(tableName);
+ }
+
+
+ public async Task GetOne(Expression> query) where T : class, new()
+ {
+ try
+ {
+ return await SqlCon.Table().Where(query).FirstOrDefaultAsync();
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ public async Task> GetAll(Expression> query) where T : new()
+ {
+ try
+ {
+ return await SqlCon.Table().Where(query).ToListAsync();
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+
+ public async Task> GetAll() where T : class, new()
+ {
+ return await SqlCon.Table().ToListAsync().ConfigureAwait(false);
+ }
+
+ public async Task Insert(object item)
+ {
+ try
+ {
+ return await SqlCon.InsertAsync(item).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+
+ public async Task InsertAll(List items) where T : new()
+ {
+ return await SqlCon.InsertAllAsync(items).ConfigureAwait(false);
+ }
+
+
+ public async Task InsertOrReplaceOne(object item) where T : new()
+ {
+ return await SqlCon.InsertOrReplaceAsync(item).ConfigureAwait(false);
+ }
+
+
+ public async Task InsertOrReplaceAll(List items) where T : new()
+ {
+ foreach (T item in items) await SqlCon.InsertOrReplaceAsync(item).ConfigureAwait(false);
+ }
+
+
+ public async Task Update(object item)
+ {
+ return await SqlCon.UpdateAsync(item).ConfigureAwait(false);
+ }
+
+
+ public async Task UpdateAll(List items) where T : new()
+ {
+ return await SqlCon.UpdateAllAsync(items).ConfigureAwait(false);
+ }
+
+
+ public async Task Delete(object item)
+ {
+ return await SqlCon.DeleteAsync(item).ConfigureAwait(false);
+ }
+
+
+ public async Task DeleteAll() where T : new()
+ {
+ return await SqlCon.DeleteAllAsync().ConfigureAwait(false);
+ }
+
+
+ public async Task DeleteAll(List items) where T : new()
+ {
+ foreach (T item in items) await SqlCon.DeleteAsync(item).ConfigureAwait(false);
+ }
+
+
+ public async Task> QueryString(string sql) where T : class, new()
+ {
+ return await SqlCon.QueryAsync(sql);
+ }
+
+
+ public async Task DropTableAsync() where T : new()
+ {
+ return await SqlCon.DropTableAsync();
+ }
+
+
+ public async Task ExecuteAsync(string sqlQuery)
+ {
+ try
+ {
+ return await SqlCon.ExecuteAsync(sqlQuery);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/FileService/FileSystemService.cs b/CoreServices/FileService/FileSystemService.cs
new file mode 100644
index 0000000..54852de
--- /dev/null
+++ b/CoreServices/FileService/FileSystemService.cs
@@ -0,0 +1,19 @@
+using System.IO;
+using System.Threading.Tasks;
+using Xamarin.Essentials;
+
+namespace CoreServices.FileService
+{
+ public class FileSystemService : IFileSystemService
+ {
+ public string GetFilePath(string filename)
+ {
+ return Path.Combine(FileSystem.AppDataDirectory, filename);
+ }
+
+ public async Task OpenFileStream(string filename)
+ {
+ return await FileSystem.OpenAppPackageFileAsync(filename);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/FileService/IFileSystemService.cs b/CoreServices/FileService/IFileSystemService.cs
new file mode 100644
index 0000000..7281146
--- /dev/null
+++ b/CoreServices/FileService/IFileSystemService.cs
@@ -0,0 +1,11 @@
+using System.IO;
+using System.Threading.Tasks;
+
+namespace CoreServices.FileService
+{
+ public interface IFileSystemService
+ {
+ string GetFilePath(string filename);
+ Task OpenFileStream(string filename);
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/LocalNotificationsServices/ILocalNotificationService.cs b/CoreServices/LocalNotificationsServices/ILocalNotificationService.cs
new file mode 100644
index 0000000..fa3bc85
--- /dev/null
+++ b/CoreServices/LocalNotificationsServices/ILocalNotificationService.cs
@@ -0,0 +1,45 @@
+using System;
+
+namespace CoreServices.LocalNotificationsServices
+{
+ public interface ILocalNotificationService
+ {
+ ///
+ /// The Executed Behaviour when the app receives a notification
+ ///
+ event EventHandler NotificationReceived;
+
+ ///
+ /// Executes the platform Specific service initiation code
+ ///
+ void Initialize();
+
+ ///
+ /// Show a local notification now
+ ///
+ /// Title of the notification
+ /// Body or description of the notification
+ /// Id of the notification
+ void Notify(string title, string body, int id = 0);
+
+ ///
+ /// Show a local notification at a certain date and time
+ ///
+ /// Title of the notification
+ /// Body or description of the notification
+ /// The date and time the notification should be fired
+ /// Id of the notification
+ void Notify(string title, string body, DateTime notificationDateTime, int id = 0);
+
+ ///
+ /// Cancel a local notification
+ ///
+ /// Id of the notification to cancel
+ void Cancel(int id);
+
+ ///
+ /// Channels the parameters to the "NotificationReceived" event when a notification is fired
+ ///
+ void ReceiveNotification(string title, string message);
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/LocalNotificationsServices/NotificationEventArgs.cs b/CoreServices/LocalNotificationsServices/NotificationEventArgs.cs
new file mode 100644
index 0000000..f696dcd
--- /dev/null
+++ b/CoreServices/LocalNotificationsServices/NotificationEventArgs.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace CoreServices.LocalNotificationsServices
+{
+ public class NotificationEventArgs : EventArgs
+ {
+ public string Title { get; set; }
+ public string Message { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/SearchServices/LCSSearch/SearchService.cs b/CoreServices/SearchServices/LCSSearch/SearchService.cs
new file mode 100644
index 0000000..53c27c1
--- /dev/null
+++ b/CoreServices/SearchServices/LCSSearch/SearchService.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using CoreServices.ServiceModels;
+
+namespace CoreServices.SearchServices.LCSSearch
+{
+ public static class SearchService
+ {
+ public static int Lcs(string firstString, string secondString)
+ {
+ int string1Length = firstString.Length;
+ int string2Length = secondString.Length;
+ var table = new int[string1Length + 1, string2Length + 1];
+ for (int i = 0; i <= string1Length; i++)
+ for (int j = 0; j <= string2Length; j++)
+ if (i == 0 || j == 0)
+ table[i, j] = 0;
+ else if (firstString[i - 1] == secondString[j - 1])
+ table[i, j] = table[i - 1, j - 1] + 1;
+ else
+ table[i, j] = Math.Max(table[i - 1, j], table[i, j - 1]);
+
+ return table[string1Length, string2Length];
+ }
+
+ ///
+ /// Returns objects in the collection where its target property is identical or similar to the query string
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable SearchInCollection(IEnumerable collection, string targetProperty,
+ string query)
+ {
+ var searchList = collection.Select(x => new KeyVal(x, 0)).ToList();
+ foreach (var pair in searchList)
+ {
+ string stringValue = (string) typeof(T).GetProperty(targetProperty)?.GetValue(pair.Key, null);
+ pair.Value = Lcs(stringValue, query);
+ }
+
+ return searchList.Where(x => x.Value > 0).OrderByDescending(x => x.Value).Select(x => x.Key);
+ }
+
+ ///
+ /// Returns objects in the collection where its target property is identical or similar to the query string
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IEnumerable SearchInCollection(IEnumerable collection,
+ Func targetPropertyFunc,
+ string query)
+ {
+ var searchList = collection.Select(x => new KeyVal(x, 0)).ToList();
+ foreach (var pair in searchList)
+ {
+ string stringValue =
+ (string) typeof(T).GetProperty(targetPropertyFunc(pair.Key))?.GetValue(pair.Key, null);
+ pair.Value = Lcs(stringValue, query);
+ }
+
+ return searchList.Where(x => x.Value > 0).OrderByDescending(x => x.Value).Select(x => x.Key);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ServiceModels/KeyValPair.cs b/CoreServices/ServiceModels/KeyValPair.cs
new file mode 100644
index 0000000..6dc1d06
--- /dev/null
+++ b/CoreServices/ServiceModels/KeyValPair.cs
@@ -0,0 +1,18 @@
+namespace CoreServices.ServiceModels
+{
+ public class KeyVal
+ {
+ public TKey Key { get; set; }
+ public TVal Value { get; set; }
+
+ public KeyVal()
+ {
+ }
+
+ public KeyVal(TKey key, TVal val)
+ {
+ Key = key;
+ Value = val;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/TranslationService/AppResources.Designer.cs b/CoreServices/TranslationService/AppResources.Designer.cs
new file mode 100644
index 0000000..9393360
--- /dev/null
+++ b/CoreServices/TranslationService/AppResources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace CoreServices.TranslationService {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ public class AppResources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal AppResources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CoreServices.TranslationService.AppResources", typeof(AppResources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ public static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/BaseTemplate/BaseTemplate/Resources/AppResources.resx b/CoreServices/TranslationService/AppResources.resx
similarity index 100%
rename from BaseTemplate/BaseTemplate/Resources/AppResources.resx
rename to CoreServices/TranslationService/AppResources.resx
diff --git a/CoreServices/ValidationService/Implementations/ValidatableObject.cs b/CoreServices/ValidationService/Implementations/ValidatableObject.cs
new file mode 100644
index 0000000..10c589b
--- /dev/null
+++ b/CoreServices/ValidationService/Implementations/ValidatableObject.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Implementations
+{
+ public class ValidatableObject : IValidatable
+ {
+ public string ErrorMsg { get; set; }
+
+ public T Value
+ {
+ get => _value;
+ set
+ {
+ _value = value;
+ IsValid = Validate();
+ onChange?.Invoke();
+ }
+ }
+
+ private readonly Action onChange;
+
+ private T _value;
+
+ public ValidatableObject(Action action = null)
+ {
+ onChange = action;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public List> ValidationRules { get; } = new List>();
+
+ public List Errors { get; set; } = new List();
+
+ public bool IsValid { get; set; }
+
+ public virtual bool Validate()
+ {
+ Errors.Clear();
+ var errors = ValidationRules.Where(v => !v.Check(Value)).Select(v => v.ValidationMessage);
+ Errors = errors.ToList();
+ ErrorMsg = Errors.FirstOrDefault();
+ IsValid = !Errors.Any();
+ return IsValid;
+ }
+
+ public override string ToString()
+ {
+ return $"{Value}";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Interfaces/IValidatable.cs b/CoreServices/ValidationService/Interfaces/IValidatable.cs
new file mode 100644
index 0000000..3fdfe3f
--- /dev/null
+++ b/CoreServices/ValidationService/Interfaces/IValidatable.cs
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using System.ComponentModel;
+
+namespace CoreServices.ValidationService.Interfaces
+{
+ public interface IValidatable : INotifyPropertyChanged
+ {
+ List> ValidationRules { get; }
+
+ List Errors { get; set; }
+
+ bool IsValid { get; set; }
+
+ bool Validate();
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Interfaces/IValidationRule.cs b/CoreServices/ValidationService/Interfaces/IValidationRule.cs
new file mode 100644
index 0000000..86b52ad
--- /dev/null
+++ b/CoreServices/ValidationService/Interfaces/IValidationRule.cs
@@ -0,0 +1,8 @@
+namespace CoreServices.ValidationService.Interfaces
+{
+ public interface IValidationRule
+ {
+ string ValidationMessage { get; set; }
+ bool Check(T value);
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Rules/HasFixedLengthRule.cs b/CoreServices/ValidationService/Rules/HasFixedLengthRule.cs
new file mode 100644
index 0000000..b12004a
--- /dev/null
+++ b/CoreServices/ValidationService/Rules/HasFixedLengthRule.cs
@@ -0,0 +1,22 @@
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Rules
+{
+ public class HasFixedLengthRule : IValidationRule
+ {
+ public int Length { get; set; }
+
+ public HasFixedLengthRule(int length)
+ {
+ Length = length;
+ }
+
+ public string ValidationMessage { get; set; }
+
+ public bool Check(T value)
+ {
+ string val = $"{value}";
+ return val.Length == Length;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Rules/IsNotNullOrEmptyRule.cs b/CoreServices/ValidationService/Rules/IsNotNullOrEmptyRule.cs
new file mode 100644
index 0000000..fa7b7d3
--- /dev/null
+++ b/CoreServices/ValidationService/Rules/IsNotNullOrEmptyRule.cs
@@ -0,0 +1,16 @@
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Rules
+{
+ public class IsNotNullOrEmptyRule : IValidationRule
+ {
+ public string ValidationMessage { get; set; }
+
+ public bool Check(T value)
+ {
+ if (value == null) return false;
+ string str = $"{value}";
+ return !string.IsNullOrWhiteSpace(str);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Rules/IsNumbersOnlyRule.cs b/CoreServices/ValidationService/Rules/IsNumbersOnlyRule.cs
new file mode 100644
index 0000000..fdb8b6a
--- /dev/null
+++ b/CoreServices/ValidationService/Rules/IsNumbersOnlyRule.cs
@@ -0,0 +1,16 @@
+using System.Text.RegularExpressions;
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Rules
+{
+ public class IsNumbersOnlyRule : IValidationRule
+ {
+ public Regex NumberRegex { get; set; } = new Regex(@"^\d+$", RegexOptions.Compiled);
+ public string ValidationMessage { get; set; }
+
+ public bool Check(T value)
+ {
+ return NumberRegex.IsMatch($"{value}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Rules/IsValidEmailRule.cs b/CoreServices/ValidationService/Rules/IsValidEmailRule.cs
new file mode 100644
index 0000000..334bb55
--- /dev/null
+++ b/CoreServices/ValidationService/Rules/IsValidEmailRule.cs
@@ -0,0 +1,24 @@
+using System.Text.RegularExpressions;
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Rules
+{
+ ///
+ /// Make Sure that the object of type T is in the correct Email format
+ ///
+ ///
+ public class IsValidEmailRule : IValidationRule
+ {
+ public Regex EmailRegex { get; set; } =
+ new Regex(
+ @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
+ RegexOptions.Compiled);
+
+ public string ValidationMessage { get; set; }
+
+ public bool Check(T value)
+ {
+ return EmailRegex.IsMatch($"{value}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CoreServices/ValidationService/Rules/IsValidPasswordRule.cs b/CoreServices/ValidationService/Rules/IsValidPasswordRule.cs
new file mode 100644
index 0000000..c243cc5
--- /dev/null
+++ b/CoreServices/ValidationService/Rules/IsValidPasswordRule.cs
@@ -0,0 +1,23 @@
+using System.Text.RegularExpressions;
+using CoreServices.ValidationService.Interfaces;
+
+namespace CoreServices.ValidationService.Rules
+{
+ ///
+ /// Makes sure that a password is between 8-20 digits, one upper case character, one lower case character, one number,
+ /// and one special character.
+ ///
+ ///
+ public class IsValidPasswordRule : IValidationRule
+ {
+ public Regex RegexPassword { get; set; } =
+ new Regex("(?=.*[A-Z])(?=.*\\d)(?=.*[¡!@#$%*¿?\\-_.\\(\\)])[A-Za-z\\d¡!@#$%*¿?\\-\\(\\)&]{8,20}");
+
+ public string ValidationMessage { get; set; }
+
+ public bool Check(T value)
+ {
+ return RegexPassword.IsMatch($"{value}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/TemplateFoundation/Commands/AsyncCommand.cs b/TemplateFoundation/Commands/AsyncCommand.cs
index 6d98b43..e5994f0 100644
--- a/TemplateFoundation/Commands/AsyncCommand.cs
+++ b/TemplateFoundation/Commands/AsyncCommand.cs
@@ -3,6 +3,7 @@
using System.Windows.Input;
using TemplateFoundation.Commands;
using TemplateFoundation.Commands.WeakEventManager;
+using TemplateFoundation.ExtensionMethods;
namespace BaseMvvmToolKIt.Commands
{
diff --git a/TemplateFoundation/Commands/TaskExtensions.cs b/TemplateFoundation/Commands/TaskExtensions.cs
deleted file mode 100644
index 1124419..0000000
--- a/TemplateFoundation/Commands/TaskExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-namespace TemplateFoundation.Commands
-{
- ///
- /// Extension methods for System.Threading.Tasks.Task
- ///
- public static class TaskExtensions
- {
- ///
- /// Safely execute the Task without waiting for it to complete before moving to the next line of code; commonly known as "Fire And Forget". Inspired by John Thiriet's blog post, "Removing Async Void": https://johnthiriet.com/removing-async-void/.
- ///
- /// Task.
- /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
- /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
-#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
- public static async void SafeFireAndForget(this System.Threading.Tasks.Task task, bool continueOnCapturedContext = true, System.Action onException = null)
-#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
- {
- try
- {
- await task.ConfigureAwait(continueOnCapturedContext);
- }
- catch (System.Exception ex) when (onException != null)
- {
- onException(ex);
- }
- }
- }
-}
diff --git a/TemplateFoundation/ExtensionMethods/TaskExtensions.cs b/TemplateFoundation/ExtensionMethods/TaskExtensions.cs
index b9b4b39..9623bc0 100644
--- a/TemplateFoundation/ExtensionMethods/TaskExtensions.cs
+++ b/TemplateFoundation/ExtensionMethods/TaskExtensions.cs
@@ -1,26 +1,25 @@
-using System;
-using System.Threading.Tasks;
-
-namespace TemplateFoundation.ExtensionMethods
+namespace TemplateFoundation.ExtensionMethods
{
+ ///
+ /// Extension methods for System.Threading.Tasks.Task
+ ///
public static class TaskExtensions
{
- // NOTE: Async void is intentional here. This provides a way
- // to call an async method from the constructor while
- // communicating intent to fire and forget, and allow
- // handling of exceptions
- public static async void SafeFireAndForget(this Task task,
- bool returnToCallingContext,
- Action onException = null)
+ ///
+ /// Safely execute the Task without waiting for it to complete before moving to the next line of code; commonly known as "Fire And Forget". Inspired by John Thiriet's blog post, "Removing Async Void": https://johnthiriet.com/removing-async-void/.
+ ///
+ /// Task.
+ /// If set to true continue on captured context; this will ensure that the Synchronization Context returns to the calling thread. If set to false continue on a different context; this will allow the Synchronization Context to continue on a different thread
+ /// If an exception is thrown in the Task, onException will execute. If onException is null, the exception will be re-thrown
+#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
+ public static async void SafeFireAndForget(this System.Threading.Tasks.Task task, bool continueOnCapturedContext = true, System.Action onException = null)
+#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
{
try
{
- await task.ConfigureAwait(returnToCallingContext);
+ await task.ConfigureAwait(continueOnCapturedContext);
}
-
- // if the provided action is not null, catch and
- // pass the thrown exception
- catch (Exception ex) when (onException != null)
+ catch (System.Exception ex) when (onException != null)
{
onException(ex);
}
diff --git a/TemplateFoundation/Helpers/HelperModels/KeyValPair.cs b/TemplateFoundation/Helpers/HelperModels/KeyValPair.cs
deleted file mode 100644
index 87ef242..0000000
--- a/TemplateFoundation/Helpers/HelperModels/KeyValPair.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace TemplateFoundation.Helpers.HelperModels
-{
- public class KeyVal
- {
- public TKey Key { get; set; }
- public TVal Value { get; set; }
-
- public KeyVal()
- {
- }
-
- public KeyVal(TKey key, TVal val)
- {
- this.Key = key;
- Value = val;
- }
- }
-}
\ No newline at end of file
diff --git a/TemplateFoundation/Helpers/HelperServices/SearchService.cs b/TemplateFoundation/Helpers/HelperServices/SearchService.cs
deleted file mode 100644
index 0d10067..0000000
--- a/TemplateFoundation/Helpers/HelperServices/SearchService.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using TemplateFoundation.Helpers.HelperModels;
-
-namespace TemplateFoundation.Helpers.HelperServices
-{
- public static class SearchService
- {
- public static int Lcs(string firstString, string secondString)
- {
- int string1Length = firstString.Length;
- int string2Length = secondString.Length;
- var table = new int[string1Length + 1, string2Length + 1];
- for (int i = 0; i <= string1Length; i++)
- {
- for (int j = 0; j <= string2Length; j++)
- {
- if (i == 0 || j == 0)
- table[i, j] = 0;
- else if (firstString[i - 1] == secondString[j - 1])
- table[i, j] = table[i - 1, j - 1] + 1;
- else
- table[i, j] = Math.Max(table[i - 1, j], table[i, j - 1]);
- }
- }
- return table[string1Length, string2Length];
- }
-
- ///
- /// Returns objects in the collection where its target property is identical or similar to the query string
- ///
- ///
- ///
- ///
- ///
- ///
- public static IEnumerable SearchInCollection(IEnumerable collection, string targetProperty, string query)
- {
- List> searchList = collection.Select(x => new KeyVal(x, 0)).ToList();
- foreach (var pair in searchList)
- {
- string stringValue = (string)typeof(T).GetProperty(targetProperty)?.GetValue(pair.Key, null);
- pair.Value = Lcs(stringValue, query);
- }
-
- return searchList.Where(x => x.Value > 0).OrderByDescending(x => x.Value).Select(x => x.Key);
- }
-
- ///
- /// Returns objects in the collection where its target property is identical or similar to the query string
- ///
- ///
- ///
- ///
- ///
- ///
- public static IEnumerable SearchInCollection(IEnumerable collection, Func targetPropertyFunc,
- string query)
- {
- List> searchList = collection.Select(x => new KeyVal(x, 0)).ToList();
- foreach (var pair in searchList)
- {
- string stringValue =
- (string)typeof(T).GetProperty(targetPropertyFunc(pair.Key))?.GetValue(pair.Key, null);
- pair.Value = Lcs(stringValue, query);
- }
-
- return searchList.Where(x => x.Value > 0).OrderByDescending(x => x.Value).Select(x => x.Key);
- }
- }
-}
\ No newline at end of file
diff --git a/TemplateFoundation/TemplateFoundation.csproj b/TemplateFoundation/TemplateFoundation.csproj
index f68143b..f786699 100644
--- a/TemplateFoundation/TemplateFoundation.csproj
+++ b/TemplateFoundation/TemplateFoundation.csproj
@@ -21,13 +21,11 @@
-
-
-
-
-
-
+
+
+
+
diff --git a/TemplateFoundation/Validation/Implementations/ValidatableObject.cs b/TemplateFoundation/Validation/Implementations/ValidatableObject.cs
deleted file mode 100644
index b02b857..0000000
--- a/TemplateFoundation/Validation/Implementations/ValidatableObject.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Implementations
-{
- public class ValidatableObject : IValidatable
- {
- public event PropertyChangedEventHandler PropertyChanged;
-
- public List> ValidationRules { get; } = new List>();
-
- public List Errors { get; set; } = new List();
-
- public bool IsValid { get; set; } = false;
-
- public string ErrorMsg { get; set; }
-
- private readonly Action onChange;
-
- public ValidatableObject(Action action = null)
- {
- onChange = action;
- }
-
- T _value;
- public T Value
- {
- get => _value;
- set
- {
- _value = value;
- IsValid = Validate();
- onChange?.Invoke();
- }
- }
-
- public virtual bool Validate()
- {
- Errors.Clear();
- IEnumerable errors = ValidationRules.Where(v => !v.Check(Value)).Select(v => v.ValidationMessage);
- Errors = errors.ToList();
- ErrorMsg = Errors.FirstOrDefault();
- IsValid = !Errors.Any();
- return this.IsValid;
- }
- public override string ToString() => $"{Value}";
- }
-}
diff --git a/TemplateFoundation/Validation/Interfaces/IValidatable.cs b/TemplateFoundation/Validation/Interfaces/IValidatable.cs
deleted file mode 100644
index d710e55..0000000
--- a/TemplateFoundation/Validation/Interfaces/IValidatable.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-
-namespace TemplateFoundation.Validation.Interfaces
-{
- public interface IValidatable : INotifyPropertyChanged
- {
- List> ValidationRules { get; }
-
- List Errors { get; set; }
-
- bool Validate();
-
- bool IsValid { get; set; }
- }
-}
diff --git a/TemplateFoundation/Validation/Interfaces/IValidationRule.cs b/TemplateFoundation/Validation/Interfaces/IValidationRule.cs
deleted file mode 100644
index 71349f9..0000000
--- a/TemplateFoundation/Validation/Interfaces/IValidationRule.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace TemplateFoundation.Validation.Interfaces
-{
- public interface IValidationRule
- {
- string ValidationMessage { get; set; }
- bool Check(T value);
- }
-}
diff --git a/TemplateFoundation/Validation/Rules/HasFixedLengthRule.cs b/TemplateFoundation/Validation/Rules/HasFixedLengthRule.cs
deleted file mode 100644
index 07a11db..0000000
--- a/TemplateFoundation/Validation/Rules/HasFixedLengthRule.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Rules
-{
- public class HasFixedLengthRule : IValidationRule
- {
- public int Length { get; set; }
- public HasFixedLengthRule(int length)
- {
- Length = length;
- }
-
- public string ValidationMessage { get; set; }
-
- public bool Check(T value)
- {
- string val = $"{value}";
- return val.Length == Length;
- }
- }
-}
\ No newline at end of file
diff --git a/TemplateFoundation/Validation/Rules/IsNotNullOrEmptyRule.cs b/TemplateFoundation/Validation/Rules/IsNotNullOrEmptyRule.cs
deleted file mode 100644
index 481b24d..0000000
--- a/TemplateFoundation/Validation/Rules/IsNotNullOrEmptyRule.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Rules
-{
- public class IsNotNullOrEmptyRule : IValidationRule
- {
- public string ValidationMessage { get; set; }
-
- public bool Check(T value)
- {
- if (value == null) return false;
- var str = $"{value}";
- return !string.IsNullOrWhiteSpace(str);
- }
- }
-}
diff --git a/TemplateFoundation/Validation/Rules/IsNumbersOnlyRule.cs b/TemplateFoundation/Validation/Rules/IsNumbersOnlyRule.cs
deleted file mode 100644
index 1a82cca..0000000
--- a/TemplateFoundation/Validation/Rules/IsNumbersOnlyRule.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Text.RegularExpressions;
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Rules
-{
- public class IsNumbersOnlyRule : IValidationRule
- {
- public string ValidationMessage { get; set; }
- public Regex NumberRegex { get; set; } = new Regex(@"^\d+$", RegexOptions.Compiled);
- public bool Check(T value)
- {
- return NumberRegex.IsMatch($"{value}");
- }
- }
-}
diff --git a/TemplateFoundation/Validation/Rules/IsValidEmailRule.cs b/TemplateFoundation/Validation/Rules/IsValidEmailRule.cs
deleted file mode 100644
index 611d363..0000000
--- a/TemplateFoundation/Validation/Rules/IsValidEmailRule.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Text.RegularExpressions;
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Rules
-{
- ///
- /// Make Sure that the object of type T is in the correct Email format
- ///
- ///
- public class IsValidEmailRule : IValidationRule
- {
- public string ValidationMessage { get; set; }
- public Regex EmailRegex { get; set; } = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", RegexOptions.Compiled);
- public bool Check(T value)
- {
- return EmailRegex.IsMatch($"{value}");
- }
- }
-}
diff --git a/TemplateFoundation/Validation/Rules/IsValidPasswordRule.cs b/TemplateFoundation/Validation/Rules/IsValidPasswordRule.cs
deleted file mode 100644
index 4bfad16..0000000
--- a/TemplateFoundation/Validation/Rules/IsValidPasswordRule.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.Text.RegularExpressions;
-using TemplateFoundation.Validation.Interfaces;
-
-namespace TemplateFoundation.Validation.Rules
-{
- ///
- /// Makes sure that a password is between 8-20 digits, one upper case character, one lower case character, one number, and one special character.
- ///
- ///
- public class IsValidPasswordRule : IValidationRule
- {
- public string ValidationMessage { get; set; }
- public Regex RegexPassword { get; set; } = new Regex("(?=.*[A-Z])(?=.*\\d)(?=.*[¡!@#$%*¿?\\-_.\\(\\)])[A-Za-z\\d¡!@#$%*¿?\\-\\(\\)&]{8,20}");
-
- public bool Check(T value)
- {
- return RegexPassword.IsMatch($"{value}");
- }
- }
-}
diff --git a/TemplateFoundationUnitTest/TemplateFoundationUnitTest.csproj b/TemplateFoundationUnitTest/TemplateFoundationUnitTest.csproj
index 7e5166c..3b6fe3b 100644
--- a/TemplateFoundationUnitTest/TemplateFoundationUnitTest.csproj
+++ b/TemplateFoundationUnitTest/TemplateFoundationUnitTest.csproj
@@ -1,10 +1,11 @@
-
+
netcoreapp3.1
false
+
all