using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.DataAccessLayer;
using Foo.DataAccessLayer.DataTypes;
namespace Foo.ClientServices.GUIWPForms
{
///
/// This class is responsible for launch all secondary threads required for this application as
/// well as hold any variables that are needed by all classes
/// created.
///
[ComVisible(false)]
internal class ComponentState
{
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
///
/// This class manages the state / main variables of the COM+ that maybe needed by multiple classes.
/// It is responsible for starting and stopping any secondary threads.
///
static ComponentState()
{
// We must subscribe to assembly resolver
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Application is starting...", MethodBase.GetCurrentMethod().Name));
// Let's Preload the Database *Right here, right now* that should be good for all of us
Data.Artifacts.DoesArtifactExistInSystem(DataTypeHelpers.CreateLocationOnlyArtifact("C:\\Dummy.file"));
// Start GUI Dispatcher Thread
Log.Info(string.Format("{0}() - GUIWPForms ComponentState() called. Activating DispatcherThread", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = true;
}
///
/// Private Variables
///
private static bool s_bApplicationIsRunning = false;
///
/// Use this to enable/disable all threads and variables for
/// the component states
///
public static bool ApplicationIsRunning
{
get { return s_bApplicationIsRunning; }
set
{
if (!value)
{
Log.Info(string.Format("{0}() - ComponentState() sApplicationRunning set to False", MethodBase.GetCurrentMethod().Name));
DispatcherThread.Run = false;
}
s_bApplicationIsRunning = value;
}
}
///
/// Use this to access the GUIFormsMgr Object in order to
/// communicate to wpfForms (Setter should only be called by
/// DispatcherThread)
///
public static GUIFormsMgr GUIFormsMgr
{
get { return DispatcherThread.s_GUIFormsMgr; }
}
}
}