Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        /// <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))));
        }
Exemplo n.º 5
0
        /// <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));
            }
        }