/// <summary> /// Builds an assembly containing a typed data pContext, and returns data for the Schema Explorer. /// </summary> /// <param name="pCxInfo">Connection information, as entered by the user</param> /// <param name="pAssemblyToBuild">Name and location of the target assembly to build</param> /// <param name="pNameSpace">The suggested namespace of the typed data pContext. You must update this /// parameter if you don't use the suggested namespace.</param> /// <param name="pTypeName">The suggested type name of the typed data pContext. You must update this /// parameter if you don't use the suggested type name.</param> /// <returns>Schema which will be subsequently loaded into the Schema Explorer.</returns> public override List <ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo pCxInfo, AssemblyName pAssemblyToBuild, ref string pNameSpace, ref string pTypeName) { var lProp = new VelocityDBProperties(pCxInfo); VelocityDBBuilder lBuilder = new VelocityDBBuilder(this, lProp); lBuilder.BuildAssembly(pAssemblyToBuild, pNameSpace, pTypeName); return(lBuilder.BuildSchema()); }
/// <summary> /// Returns a list of additional namespaces that should be imported automatically into all /// queries that use this driver. This should include the commonly used namespaces of your ORM or /// querying technology .</summary> public override IEnumerable <string> GetNamespacesToAdd(IConnectionInfo pCxInfo) { var lProp = new VelocityDBProperties(pCxInfo); return(new List <string> { "VelocityDb" }); }
/// <summary> /// Returns a list of additional assemblies to reference when building queries. To refer to /// an assembly in the GAC, specify its fully qualified name, otherwise specified the assembly's full /// location on the hard drive. Assemblies in the same folder as the driver, however, don't require a /// folder name. If you're unable to find the necessary assemblies, throw an exception, with a message /// indicating the problem assembly.</summary> public override IEnumerable <string> GetAssembliesToAdd(IConnectionInfo pCxInfo) { List <string> lAssemblies = new List <string>(); VelocityDBProperties lProp = new VelocityDBProperties(pCxInfo); Assembly[] lLoaded = AppDomain.CurrentDomain.GetAssemblies(); // Add only not loaded assemblies. (Skip(8) removes the file:/// prefix. string[] lRes = lProp.ActualDepencies.Where(lDep => !lLoaded.Where(lAssembly => new string(lAssembly.CodeBase.Skip(8).ToArray()).Equals(lDep)).Any()).ToArray(); return(lRes); }
public VelocityDBBuilder(VelocityDBDynamicDriver pDriver, VelocityDBProperties pProperties) { schema = SchemaExtractor.Extract(pProperties.ClassesFilenamesArray, pProperties.DependencyFilesArray); sessionInfo = new SessionInfo() { DBFolder = pProperties.DBFolder, Host = pProperties.Host, PessimisticLocking = pProperties.PessimisticLocking, SessionType = pProperties.SessionType, WindowsAuth = pProperties.WindowsAuth }; }
public override string GetConnectionDescription(IConnectionInfo pCxInfo) { // Format VelocityDB@<server>-<database>. If local, <server> = local. var lProp = new VelocityDBProperties(pCxInfo); string lDesc = Path.GetFileNameWithoutExtension(lProp.DBFolder); string lServ = "local"; if (lProp.SessionType.Equals(VelocityDBProperties.ServerClientSession)) { lServ = lProp.Host; } return("VelocityDB@" + lServ + "-" + lDesc); }
public ConnectionDialog(IConnectionInfo pCxInfo) { DataContext = properties = new VelocityDBProperties(pCxInfo); InitializeComponent(); // Check current session type. switch (properties.SessionType) { case SessionInfo.SessionTypeEnum.NoServerSession: RadioNoServ.IsChecked = true; break; case SessionInfo.SessionTypeEnum.NoServerSharedSession: RadioNoShared.IsChecked = true; break; case SessionInfo.SessionTypeEnum.ServerClientSession: RadioServer.IsChecked = true; HostTextBox.IsEnabled = true; break; default: RadioNoServ.IsChecked = true; break; } // Fill current classes filenames. foreach (string lClassFilename in properties.ClassesFilenamesArray) { if (lClassFilename.Length < 1) { continue; } ListViewItem lItem = new ListViewItem(); lItem.Content = lClassFilename; AssemblyList.Items.Add(lItem); } // Fill current dependencies filename. foreach (string lDependency in properties.DependencyFilesArray) { if (lDependency.Length < 1) { continue; } ListViewItem lItem = new ListViewItem(); lItem.Content = lDependency; DependencyList.Items.Add(lItem); } }
/// <summary> /// Displays a dialog prompting the user for connection details. The isNewConnection /// parameter will be true if the user is creating a new connection rather than editing an /// existing connection. This should return true if the user clicked OK. If it returns false, /// any changes to the IConnectionInfo object will be rolled back.</summary> public override bool ShowConnectionDialog(IConnectionInfo pCxInfo, bool pIsNewConnection) { VelocityDBProperties lProp; if (pIsNewConnection) { lProp = new VelocityDBProperties(pCxInfo) { Host = Dns.GetHostName(), WindowsAuth = false, PessimisticLocking = false }; } else { lProp = new VelocityDBProperties(pCxInfo); } bool?result = new ConnectionDialog(pCxInfo).ShowDialog(); if (result != true) { return(false); } // This function, as well as GetSchemaAndBuildAssembly, runs on a separeted appdomain. But different from // GetSchemaAndBuildAssembly, pCxInfo gets persisted if true is returned. So this is the best (found) place to create // a list of dependencies. // Save already loaded assemblies. SchemaInfo lSchema = SchemaExtractor.Extract(lProp.ClassesFilenamesArray, lProp.DependencyFilesArray); SessionInfo lSessionInfo = new SessionInfo() { DBFolder = lProp.DBFolder, Host = lProp.Host, PessimisticLocking = lProp.PessimisticLocking, SessionType = lProp.SessionType, WindowsAuth = lProp.WindowsAuth }; VelocityDBAccessBuilder lBuilder = new VelocityDBAccessBuilder(lSchema, lSessionInfo); lBuilder.BuildAssembly(new AssemblyName("DummyName"), "DummyName", "DummyName", false); lProp.ActualDepencies = lSchema.LoadedAssemblies; return(true); }
public ConnectionDialog(IConnectionInfo pCxInfo) { DataContext = properties = new VelocityDBProperties(pCxInfo); InitializeComponent(); // Check current session type. switch (properties.SessionType) { case SessionInfo.SessionTypeEnum.NoServerSession: RadioNoServ.IsChecked = true; break; case SessionInfo.SessionTypeEnum.NoServerSharedSession: RadioNoShared.IsChecked = true; break; case SessionInfo.SessionTypeEnum.ServerClientSession: RadioServer.IsChecked = true; HostTextBox.IsEnabled = true; break; default: RadioNoServ.IsChecked = true; break; } // Fill current classes filenames. foreach(string lClassFilename in properties.ClassesFilenamesArray) { if (lClassFilename.Length < 1) continue; ListViewItem lItem = new ListViewItem(); lItem.Content = lClassFilename; AssemblyList.Items.Add(lItem); } // Fill current dependencies filename. foreach (string lDependency in properties.DependencyFilesArray) { if (lDependency.Length < 1) continue; ListViewItem lItem = new ListViewItem(); lItem.Content = lDependency; DependencyList.Items.Add(lItem); } }
/// <summary> /// Returns a list of additional assemblies to reference when building queries. To refer to /// an assembly in the GAC, specify its fully qualified name, otherwise specified the assembly's full /// location on the hard drive. Assemblies in the same folder as the driver, however, don't require a /// folder name. If you're unable to find the necessary assemblies, throw an exception, with a message /// indicating the problem assembly.</summary> public override IEnumerable<string> GetAssembliesToAdd(IConnectionInfo pCxInfo) { List<string> lAssemblies = new List<string>(); VelocityDBProperties lProp = new VelocityDBProperties(pCxInfo); Assembly[] lLoaded = AppDomain.CurrentDomain.GetAssemblies(); // Add only not loaded assemblies. (Skip(8) removes the file:/// prefix. string[] lRes = lProp.ActualDepencies.Where(lDep => !lLoaded.Where(lAssembly => new string(lAssembly.CodeBase.Skip(8).ToArray()).Equals(lDep)).Any()).ToArray(); return lRes; }
/// <summary> /// Displays a dialog prompting the user for connection details. The isNewConnection /// parameter will be true if the user is creating a new connection rather than editing an /// existing connection. This should return true if the user clicked OK. If it returns false, /// any changes to the IConnectionInfo object will be rolled back.</summary> public override bool ShowConnectionDialog(IConnectionInfo pCxInfo, bool pIsNewConnection) { VelocityDBProperties lProp; if (pIsNewConnection) { lProp = new VelocityDBProperties(pCxInfo) { Host = Dns.GetHostName(), WindowsAuth = false, PessimisticLocking = false }; } else lProp = new VelocityDBProperties(pCxInfo); bool? result = new ConnectionDialog(pCxInfo).ShowDialog(); if (result != true) return false; // This function, as well as GetSchemaAndBuildAssembly, runs on a separeted appdomain. But different from // GetSchemaAndBuildAssembly, pCxInfo gets persisted if true is returned. So this is the best (found) place to create // a list of dependencies. // Save already loaded assemblies. SchemaInfo lSchema = SchemaExtractor.Extract(lProp.ClassesFilenamesArray, lProp.DependencyFilesArray); SessionInfo lSessionInfo = new SessionInfo() { DBFolder = lProp.DBFolder, Host = lProp.Host, PessimisticLocking = lProp.PessimisticLocking, SessionType = lProp.SessionType, WindowsAuth = lProp.WindowsAuth }; VelocityDBAccessBuilder lBuilder = new VelocityDBAccessBuilder(lSchema, lSessionInfo); lBuilder.BuildAssembly(new AssemblyName("DummyName"), "DummyName", "DummyName", false); lProp.ActualDepencies = lSchema.LoadedAssemblies; return true; }
/// <summary> /// Builds an assembly containing a typed data pContext, and returns data for the Schema Explorer. /// </summary> /// <param name="pCxInfo">Connection information, as entered by the user</param> /// <param name="pAssemblyToBuild">Name and location of the target assembly to build</param> /// <param name="pNameSpace">The suggested namespace of the typed data pContext. You must update this /// parameter if you don't use the suggested namespace.</param> /// <param name="pTypeName">The suggested type name of the typed data pContext. You must update this /// parameter if you don't use the suggested type name.</param> /// <returns>Schema which will be subsequently loaded into the Schema Explorer.</returns> public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo pCxInfo, AssemblyName pAssemblyToBuild, ref string pNameSpace, ref string pTypeName) { var lProp = new VelocityDBProperties(pCxInfo); VelocityDBBuilder lBuilder = new VelocityDBBuilder(this, lProp); lBuilder.BuildAssembly(pAssemblyToBuild, pNameSpace, pTypeName); return lBuilder.BuildSchema(); }
/// <summary> /// Returns a list of additional namespaces that should be imported automatically into all /// queries that use this driver. This should include the commonly used namespaces of your ORM or /// querying technology .</summary> public override IEnumerable<string> GetNamespacesToAdd(IConnectionInfo pCxInfo) { var lProp = new VelocityDBProperties(pCxInfo); return new List<string> { "VelocityDb" }; }
public override string GetConnectionDescription(IConnectionInfo pCxInfo) { // Format VelocityDB@<server>-<database>. If local, <server> = local. var lProp = new VelocityDBProperties(pCxInfo); string lDesc = Path.GetFileNameWithoutExtension(lProp.DBFolder); string lServ = "local"; if (lProp.SessionType.Equals(VelocityDBProperties.ServerClientSession)) { lServ = lProp.Host; } return "VelocityDB@" + lServ + "-" + lDesc; }