Click here to Skip to main content
15,887,329 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Make a MDI form itself XP theme aware Pin
Heath Stewart29-Apr-04 4:25
protectorHeath Stewart29-Apr-04 4:25 
AnswerRe: How to Make a MDI form itself XP theme aware Pin
Heath Stewart29-Apr-04 4:27
protectorHeath Stewart29-Apr-04 4:27 
GeneralRe: How to Make a MDI form itself XP theme aware Pin
TaoLi29-Apr-04 4:37
TaoLi29-Apr-04 4:37 
GeneralRe: How to Make a MDI form itself XP theme aware Pin
Jon G29-Apr-04 5:24
Jon G29-Apr-04 5:24 
GeneralRe: Calling an exported Function - Issue with different calling convention in C# Pin
Heath Stewart29-Apr-04 3:09
protectorHeath Stewart29-Apr-04 3:09 
QuestionRichTextBox-Coul you help me out? Pin
kumaru_san29-Apr-04 2:31
kumaru_san29-Apr-04 2:31 
GeneralNewbie: login screen Pin
ziwez029-Apr-04 2:15
ziwez029-Apr-04 2:15 
GeneralRe: Newbie: login screen Pin
Heath Stewart29-Apr-04 4:14
protectorHeath Stewart29-Apr-04 4:14 
You have several options. The way that the .NET Framework is heading is the provider pattern, which is a pretty good system. See a recent article in MSDN - Provider Model Design Pattern and Specification, Part 1[^] - for more information.

A conceptually similar way without all the overhead of the typed class factories is what we currently use in our application.

Basically, you design an abstract class that performs the authentication. Then you extend this class (either in a different project or the same project) with Access-specific functionality. Later, you could extend this base class with SQL-specific functionality. In either case, you read-in a type from your application's .config file as a string (like "MyNamespace.MyAccessAuthClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef"). You could, for example, simply store this in the <appSettings> section of your .config file and associate that with a key, like "authenticator". You then get that type, create an instance of it, and cast it to your base class (or interface, whichever you prefer - use a base class if you want to have basic functionality implemented, or use an interface if you want no default implementation of anything):
string type = 
  ConfigurationSettings.AppSettings["authenticator"];
if (type == null)
  type = "MyNamespace.MyAccessAuthClass, MyAssembly, " +
    "Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef"
AuthenticatorBase auth = null;
try
{
  Type t = Type.GetType(type);
  auth = (AuthenticatorBase)Activator.CreateInstance(t);
}
catch (Exception ex)
{
  MessageBox.Show("Could not create the authentication package: " + ex.Message,
    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  Environment.Exit(1);
}
// Authenticate using the auth variable
Obviously, the Type string is just an example, and you could use a partial type (namespace + classname, assembly name).

 

Microsoft MVP, Visual C#
My Articles
Generalnetzwerk / network Pin
Anonymous29-Apr-04 1:56
Anonymous29-Apr-04 1:56 
GeneralRe: netzwerk / network Pin
Anonymous29-Apr-04 2:08
Anonymous29-Apr-04 2:08 
GeneralRe: netzwerk / network Pin
Daniel Turini29-Apr-04 2:28
Daniel Turini29-Apr-04 2:28 
Generaldetermine mouse button from System.EventArgs Pin
mookeroo29-Apr-04 1:16
mookeroo29-Apr-04 1:16 
GeneralRe: determine mouse button from System.EventArgs Pin
Stefan Troschuetz29-Apr-04 1:49
Stefan Troschuetz29-Apr-04 1:49 
GeneralRe: determine mouse button from System.EventArgs Pin
mookeroo29-Apr-04 1:53
mookeroo29-Apr-04 1:53 
GeneralRe: determine mouse button from System.EventArgs Pin
Syed Abdul Khader29-Apr-04 2:39
Syed Abdul Khader29-Apr-04 2:39 
GeneralRe: determine mouse button from System.EventArgs Pin
mookeroo29-Apr-04 2:32
mookeroo29-Apr-04 2:32 
GeneralWin32 Interop: Returning BSTR from ATL C++ DLL Pin
inter8ection29-Apr-04 0:07
inter8ection29-Apr-04 0:07 
GeneralRe: Win32 Interop: Returning BSTR from ATL C++ DLL Pin
Mike Dimmick29-Apr-04 0:53
Mike Dimmick29-Apr-04 0:53 
GeneralRe: Win32 Interop: Returning BSTR from ATL C++ DLL Pin
inter8ection29-Apr-04 1:06
inter8ection29-Apr-04 1:06 
GeneralRe: Win32 Interop: Returning BSTR from ATL C++ DLL Pin
Mike Dimmick29-Apr-04 2:15
Mike Dimmick29-Apr-04 2:15 
GeneralJustify alignment in c# ritchtextbox control!!! Pin
hassan azizi28-Apr-04 22:47
hassan azizi28-Apr-04 22:47 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart29-Apr-04 4:03
protectorHeath Stewart29-Apr-04 4:03 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi29-Apr-04 4:42
hassan azizi29-Apr-04 4:42 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart29-Apr-04 4:48
protectorHeath Stewart29-Apr-04 4:48 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi29-Apr-04 12:24
hassan azizi29-Apr-04 12:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.