Skip to content

Commit

Permalink
reworked some class interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
braunms committed Aug 25, 2023
1 parent ddb0ffb commit 12a1748
Show file tree
Hide file tree
Showing 25 changed files with 644 additions and 518 deletions.
122 changes: 81 additions & 41 deletions Core/Abstracts/AbstractContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,19 @@
using System.Collections.Generic;
using System.Runtime.Remoting.Contexts;
using System.Windows.Controls;

using Core.Utilities;



/*
* Abstract Child Content
* Abstract Content
*
*/
namespace Core
{
namespace Abstracts
{

// INTERFACE
public interface IAbstractContent
{
/* ------------------------------------------------------------------*/
// interface properties

string Name { get; }

bool MultipleIntances { get; }

List<Type> DependingServices { get; }

bool IsAttached { get; }

string ID { get; }


/* ------------------------------------------------------------------*/
// interface functions

bool Create();

Control Attach();

bool Detach();
}



// ABSTRACT CLASS
public abstract class AbstractContent : IAbstractContent
public abstract class AbstractContent : IAbstractService, IAbstractContent
{

/* ------------------------------------------------------------------*/
Expand All @@ -71,57 +39,129 @@ public AbstractContent()
}


public virtual bool Create()
/// <summary>
/// If derived class might requires additional data on initialization (declaring Initialize taking parameter(s)),
/// throw error when method of base class is called instead.
/// </summary>
public virtual bool Initialize()
{
throw new InvalidOperationException("Call Initialize method of derived class");
}
/* TEMPLATE
public override bool Initialize()
{
if (_initilized)
{
Terminate();
}
_timer.Start();
/// PLACE YOUR STUFF HERE ...
/// ! REQUIRED:
_content.Name = ID;
_timer.Stop();
_initilized = true;
if (_initilized)
{
Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().Name);
}
return _initilized;
}
*/


public abstract bool Create();
/*
{
if (!_initilized)
{
Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution");
return false;
}
if (_created)
{
Log.Default.Msg(Log.Level.Warn, "Content already created");
Log.Default.Msg(Log.Level.Warn, "Content already created, skipping...");
return false;
}
_timer.Start();
//_content.Name = ID;
/// PLACE YOUR STUFF HERE ...
_timer.Stop();
_created = true;
return true;
}
*/


/// <summary>
/// Attach content to provided content_element.
/// </summary>
public virtual Control Attach()
public abstract Control Attach();
/* TEMPLATE
{
if (!_initilized)
{
Log.Default.Msg(Log.Level.Error, "Initialization required prior to execution");
return null;
}
if (!_created)
{
Log.Default.Msg(Log.Level.Error, "Creation of content required prior to execution");
return null;
}
//_attached = true;
/// PLACE YOUR STUFF HERE ...
_attached = true;
return null;
}
*/


public virtual bool Detach()
{
_attached = false;
if (!_attached)
{
/// PLACE YOUR STUFF HERE ...

_attached = false;
}
return true;
}


public abstract bool Terminate();
/* TEMPLATE
{
if (_initilized)
{
/// PLACE YOUR STUFF HERE ...
_initilized = false;
}
return true;
}
*/


/* ------------------------------------------------------------------*/
// protected variables

protected bool _attached = false;
protected bool _initilized = false;
protected bool _created = false;
protected bool _attached = false;


/* ------------------------------------------------------------------*/
// private variables

private readonly string _id = null;
/// DEBUG
protected TimeBenchmark _timer = null;
}
}
Expand Down
53 changes: 31 additions & 22 deletions Core/Abstracts/AbstractService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ namespace Core
{
namespace Abstracts
{

// INTERFACE
public interface IAbstractService
{
/* ------------------------------------------------------------------*/
// interface functions

bool Initialize();

bool Execute();

bool Terminate();
}



// ABSTRACT CLASS
public abstract class AbstractService : IAbstractService
{
/* ------------------------------------------------------------------*/
Expand All @@ -45,26 +28,52 @@ protected AbstractService()
// abstract functions

/// <summary>
/// If derived class requires additional data on initialization (declaring Initialize taking parameter(s)),
/// If derived class might requires additional data on initialization (declaring Initialize taking parameter(s)),
/// throw error when method of base class is called instead.
/// </summary>
public virtual bool Initialize()
{
throw new InvalidOperationException("Call Initialize method of derived class");
}


public abstract bool Execute();
/* TEMPLATE
{
if (_initilized)
{
Terminate();
}
_timer.Start();
/// PLACE YOUR STUFF HERE ...
_timer.Stop();
_initilized = true;
if (_initilized)
{
Log.Default.Msg(Log.Level.Info, "Successfully initialized: " + this.GetType().Name);
}
return _initilized;
}
*/


public abstract bool Terminate();
/* TEMPLATE
{
if (_initilized)
{
/// PLACE YOUR STUFF HERE ...
_initilized = false;
}
return true;
}
*/


/* ------------------------------------------------------------------*/
// protected variables

protected bool _initilized = false;

/// DEBUG
protected TimeBenchmark _timer = null;
}
Expand Down
44 changes: 44 additions & 0 deletions Core/Abstracts/IAbstractContent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;



/*
* Abstract Content Interface
*
*/
namespace Core
{
namespace Abstracts
{
public interface IAbstractContent
{
/* ------------------------------------------------------------------*/
// interface properties

string Name { get; }

bool MultipleIntances { get; }

List<Type> DependingServices { get; }

bool IsAttached { get; }

string ID { get; }


/* ------------------------------------------------------------------*/
// interface functions

bool Create();

Control Attach();

bool Detach();
}
}
}
28 changes: 28 additions & 0 deletions Core/Abstracts/IAbstractService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


/*
* Abstract Service Interface
*
*/
namespace Core
{
namespace Abstracts
{

// INTERFACE
public interface IAbstractService
{
/* ------------------------------------------------------------------*/
// interface functions

bool Initialize();

bool Terminate();
}
}
}
2 changes: 2 additions & 0 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
<ItemGroup>
<Compile Include="Abstracts\AbstractWindow.cs" />
<Compile Include="Abstracts\AbstractContent.cs" />
<Compile Include="Abstracts\IAbstractContent.cs" />
<Compile Include="Abstracts\IAbstractService.cs" />
<Compile Include="GUI\Content\MenuBar.cs" />
<Compile Include="GUI\Windows\WindowBranch.cs" />
<Compile Include="GUI\Windows\WindowLeaf.cs" />
Expand Down
Loading

0 comments on commit 12a1748

Please sign in to comment.