migrating to .NET Core 2.0
This commit is contained in:
14
SharedLibraryCore/Interfaces/IBaseConfiguration.cs
Normal file
14
SharedLibraryCore/Interfaces/IBaseConfiguration.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface IBaseConfiguration
|
||||
{
|
||||
string Name();
|
||||
IBaseConfiguration Generate();
|
||||
}
|
||||
}
|
16
SharedLibraryCore/Interfaces/IConfigurationHandler.cs
Normal file
16
SharedLibraryCore/Interfaces/IConfigurationHandler.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface IConfigurationHandler<T> where T : IBaseConfiguration
|
||||
{
|
||||
Task Save();
|
||||
void Build();
|
||||
T Configuration();
|
||||
void Set(T config);
|
||||
}
|
||||
}
|
20
SharedLibraryCore/Interfaces/IEntityService.cs
Normal file
20
SharedLibraryCore/Interfaces/IEntityService.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface IEntityService<T>
|
||||
{
|
||||
Task<T> CreateProxy();
|
||||
Task<T> Create(T entity);
|
||||
Task<T> Delete(T entity);
|
||||
Task<T> Update(T entity);
|
||||
Task<T> Get(int entityID);
|
||||
Task<T> GetUnique(long entityProperty);
|
||||
Task<IList<T>> Find(Func<T, bool> expression);
|
||||
}
|
||||
}
|
17
SharedLibraryCore/Interfaces/ILogger.cs
Normal file
17
SharedLibraryCore/Interfaces/ILogger.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface ILogger
|
||||
{
|
||||
void WriteVerbose(string msg);
|
||||
void WriteInfo(string msg);
|
||||
void WriteDebug(string msg);
|
||||
void WriteWarning(string msg);
|
||||
void WriteError(string msg);
|
||||
}
|
||||
}
|
25
SharedLibraryCore/Interfaces/IManager.cs
Normal file
25
SharedLibraryCore/Interfaces/IManager.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using SharedLibraryCore.Objects;
|
||||
using SharedLibraryCore.Services;
|
||||
using System.Threading.Tasks;
|
||||
using SharedLibraryCore.Configuration;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface IManager
|
||||
{
|
||||
Task Init();
|
||||
void Start();
|
||||
void Stop();
|
||||
ILogger GetLogger();
|
||||
IList<Server> GetServers();
|
||||
IList<Command> GetCommands();
|
||||
IList<Helpers.MessageToken> GetMessageTokens();
|
||||
IList<Player> GetActiveClients();
|
||||
IConfigurationHandler<ApplicationConfiguration> GetApplicationSettings();
|
||||
ClientService GetClientService();
|
||||
AliasService GetAliasService();
|
||||
PenaltyService GetPenaltyService();
|
||||
IDictionary<int, Player> GetPrivilegedClients();
|
||||
}
|
||||
}
|
18
SharedLibraryCore/Interfaces/IPlugin.cs
Normal file
18
SharedLibraryCore/Interfaces/IPlugin.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
public interface IPlugin
|
||||
{
|
||||
Task OnLoadAsync(IManager manager);
|
||||
Task OnUnloadAsync();
|
||||
Task OnEventAsync(Event E, Server S);
|
||||
Task OnTickAsync(Server S);
|
||||
|
||||
//for logging purposes
|
||||
String Name { get; }
|
||||
float Version { get; }
|
||||
String Author { get; }
|
||||
}
|
||||
}
|
60
SharedLibraryCore/Interfaces/ISerializable.cs
Normal file
60
SharedLibraryCore/Interfaces/ISerializable.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace SharedLibraryCore.Interfaces
|
||||
{
|
||||
interface ISerializable<T>
|
||||
{
|
||||
void Write();
|
||||
}
|
||||
|
||||
public class Serialize<T> : ISerializable<T>
|
||||
{
|
||||
public static T Read(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
string configText = File.ReadAllText(filename);
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(configText);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exceptions.SerializeException($"Could not deserialize file {filename}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Write()
|
||||
{
|
||||
try
|
||||
{
|
||||
string configText = Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
File.WriteAllText(Filename(), configText);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exceptions.SerializeException($"Could not serialize file {Filename()}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Write(string filename, T data)
|
||||
{
|
||||
try
|
||||
{
|
||||
string configText = Newtonsoft.Json.JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented);
|
||||
File.WriteAllText(filename, configText);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exceptions.SerializeException($"Could not serialize file {filename}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string Filename() { return ToString(); }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user