コード例 #1
0
ファイル: DesignerSettings.cs プロジェクト: zixing131/LAEACC
        private void FindConnectorType()
        {
            FApplicationConnectionType = null;
            if (FApplicationConnection == null)
            {
                return;
            }

            // find appropriate connector
            List <ObjectInfo> registeredObjects = new List <ObjectInfo>();

            RegisteredObjects.Objects.EnumItems(registeredObjects);

            foreach (ObjectInfo info in registeredObjects)
            {
                if (info.Object != null && info.Object.IsSubclassOf(typeof(DataConnectionBase)))
                {
                    using (DataConnectionBase conn = Activator.CreateInstance(info.Object) as DataConnectionBase)
                        using (DbConnection dbConn = conn.GetConnection())
                        {
                            if (dbConn != null && dbConn.GetType() == FApplicationConnection.GetType())
                            {
                                FApplicationConnectionType = conn.GetType();
                                return;
                            }
                        }
                }
            }

            throw new Exception(FApplicationConnection.GetType().Name + " connection is not supported.");
        }
コード例 #2
0
 internal void OnDatabaseLogin(DataConnectionBase sender, DatabaseLoginEventArgs e)
 {
   if (Config.DesignerSettings.ApplicationConnection != null && 
     sender.GetType() == Config.DesignerSettings.ApplicationConnectionType)
   {
     e.ConnectionString = Config.DesignerSettings.ApplicationConnection.ConnectionString;
   }
   
   if (DatabaseLogin != null)
     DatabaseLogin(sender, e);
 }