aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
committerAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
commit6c208c90bc45aff4a7fa214356a42fe7757c5e6f (patch)
tree0d77bc6a0ecfbb53cf42c5462ee19212197ee1bd /Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml
parentb0823127f152fe97a6e8fce29e427c7f3db9cf5a (diff)
parent1a573aaa346ec4b8bd58a0e35ab9df571a09b855 (diff)
downloadTango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.tar.gz
Tango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.zip
MERGE
Diffstat (limited to 'Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml')
-rw-r--r--Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml60
1 files changed, 60 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml b/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml
new file mode 100644
index 000000000..2094c0999
--- /dev/null
+++ b/Software/Visual_Studio/Tango.CodeGeneration/Templates/ObservablesContextCodeFile.cshtml
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Settings;
+
+namespace Tango.Integration.Observables
+{
+ public class ObservablesContext : DbContext
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ObservablesContext" /> class.
+ /// </summary>
+ /// <param name="path">The server file path.</param>
+ /// <param name="isFile">if set to <c>true</c> will try to connect to an .mdf file.</param>
+ public ObservablesContext(String path, bool isFile) : base(ComposeConnectionString(path, isFile))
+ {
+
+ }
+
+ /// <summary>
+ /// Composes the connection string.
+ ///</summary>
+ /// <param name="source">The source.</param>
+ /// <param name="isFile">if set to <c>true</c> [is file].</param>
+ /// <returns></returns>
+ private static String ComposeConnectionString(String source, bool isFile)
+ {
+ if (!isFile)
+ {
+ return String.Format("Data Source={0};Initial Catalog=Tango;Integrated Security=true", source);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Creates a default remote database context by the address specified in <see cref="SettingsManager.Default.DataBase.SQLServerAddress" />.
+ /// </summary>
+ /// <returns></returns>
+ public static ObservablesContext CreateDefault()
+ {
+ return new ObservablesContext(SettingsManager.Default.DataBase.SQLServerAddress, false);
+ }
+
+ @foreach (var prop in Model.Properties)
+ {
+ <div>
+ /// <summary>
+ /// Gets or sets the @(prop.Name).
+ /// </summary>
+ public @(prop.Type) @(prop.Name) { get; set; }
+ </div>
+ }
+ }
+}