/// <summary> /// Fills the controls with existing data. /// </summary> private void FillControlsWithExistingData() { if ((_cxInfo == null) || _isNewConnection) { return; } var templateGroupValue = CxInfoHelper.GetTemplateGroup(_cxInfo); switch (templateGroupValue) { case TemplateGroup.None: case TemplateGroup.SelfServicing: _selfServicingRadioButton.Checked = true; break; case TemplateGroup.Adapter: _adapterRadioButton.Checked = true; break; } _ssAssemblyTextBox.Text = CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.SelfServicingAssemblyFilenameElement); _aGenAssemblyTextBox.Text = CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.AdapterDBGenericAssemblyFilenameElement); _aSpecAssemblyTextBox.Text = CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.AdapterDBSpecificAssemblyFilenameElement); _connectionStringTextBox.Text = CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.ConnectionStringElementName); _appConfigFileTextBox.Text = CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.ConfigFileFilenameElement); _enableORMProfilerCheckBox.Checked = XmlConvert.ToBoolean(CxInfoHelper.GetDriverDataElementValue(_cxInfo, DriverDataElements.EnableORMProfilerElement)); }
/// <summary> /// Gets the namespaces to add to the default list of namespaces added to the generateed class executed. /// </summary> /// <param name="cxInfo">The cx info.</param> /// <returns></returns> public override IEnumerable <string> GetNamespacesToAdd(IConnectionInfo cxInfo) { var defaultNamespaces = new List <string>() { "SD.LLBLGen.Pro.LinqSupportClasses", "SD.LLBLGen.Pro.ORMSupportClasses", "SD.LLBLGen.Pro.QuerySpec", }; var templateGroup = CxInfoHelper.GetTemplateGroup(cxInfo); if (templateGroup == TemplateGroup.Adapter) { defaultNamespaces.Add("SD.LLBLGen.Pro.QuerySpec.Adapter"); } else { defaultNamespaces.Add("SD.LLBLGen.Pro.QuerySpec.SelfServicing"); } var toReturn = base.GetNamespacesToAdd(cxInfo).Union(defaultNamespaces); var entityAssemblyNamespaces = CxInfoHelper.GetDriverDataElementValue(cxInfo, DriverDataElements.EntityAssemblyNamespacesElement); if (!string.IsNullOrEmpty(entityAssemblyNamespaces)) { toReturn = toReturn.Union(entityAssemblyNamespaces.Split(',').Where(s => !string.IsNullOrEmpty(s))); } return(toReturn); }
/// <summary> /// Initializes the context. /// </summary> /// <param name="cxInfo">The cx info.</param> /// <param name="context">The context.</param> /// <param name="executionManager">The execution manager.</param> public override void InitializeContext(IConnectionInfo cxInfo, object context, QueryExecutionManager executionManager) { if (CxInfoHelper.GetEnableORMProfiler(cxInfo)) { EnableORMProfiler(cxInfo); } var templateGroup = CxInfoHelper.GetTemplateGroup(cxInfo); switch (templateGroup) { case TemplateGroup.None: throw new InvalidOperationException("Template group hasn't been specified."); case TemplateGroup.Adapter: InitializeContextAdapter(cxInfo, context, executionManager); break; case TemplateGroup.SelfServicing: InitializeContextSelfServicing(cxInfo, context, executionManager); break; default: base.InitializeContext(cxInfo, context, executionManager); break; } var tracer = new ORMPersistenceExecutionListener(executionManager); Trace.Listeners.Clear(); Trace.Listeners.Add(tracer); TraceHelper.PersistenceExecutionSwitch.Level = TraceLevel.Verbose; }
/// <summary> /// Returns the text to display in the root Schema Explorer node for a given connection info. /// </summary> /// <param name="cxInfo">The cx info.</param> /// <returns></returns> public override string GetConnectionDescription(IConnectionInfo cxInfo) { if (cxInfo == null) { return("<null>"); } var templateGroup = CxInfoHelper.GetTemplateGroup(cxInfo); return(string.Format("{0} - {1}", templateGroup.ToString(), Path.GetFileNameWithoutExtension(CxInfoHelper.GetEntityAssemblyFilename(cxInfo, templateGroup)))); }
/// <summary> /// Obtains the and set entity assembly namespaces. /// </summary> /// <param name="cxInfo">The cx info.</param> private void ObtainAndSetEntityAssemblyNamespaces(IConnectionInfo cxInfo) { var entityAssemblyFilename = CxInfoHelper.GetEntityAssemblyFilename(cxInfo, CxInfoHelper.GetTemplateGroup(cxInfo)); if (string.IsNullOrEmpty(entityAssemblyFilename)) { return; } var assembly = DataContextDriver.LoadAssemblySafely(entityAssemblyFilename); var namespaces = assembly.GetTypes().Select(t => t.Namespace).Distinct().ToArray(); CxInfoHelper.SetDriverDataElement(cxInfo, DriverDataElements.EntityAssemblyNamespacesElement, String.Join(",", namespaces)); }
/// <summary> /// Verifies the version of the entity assembly, whether it's of a version this driver can work with. /// </summary> private void VerifyEntityAssemblyVersion() { if (_linqMetaDataType == null) { throw new InvalidOperationException("No ILinqMetaData type found."); } var ormSupportClassesAssemblyName = _linqMetaDataType.Assembly.GetReferencedAssemblies() .Where(an => (an.Name == "SD.LLBLGen.Pro.ORMSupportClasses") && (an.Version.Major == Constants.MajorVersion) && (an.Version.Minor == Constants.MinorVersion)).FirstOrDefault(); if (ormSupportClassesAssemblyName == null) { throw new InvalidOperationException(string.Format("The assembly '{0}' is not compiled against the LLBLGen Pro Runtime Framework v{1}.{2}.", CxInfoHelper.GetEntityAssemblyFilename(_cxInfo, CxInfoHelper.GetTemplateGroup(_cxInfo)), Constants.MajorVersion, Constants.MinorVersion)); } }