migrating to .NET Core 2.0

This commit is contained in:
RaidMax
2018-04-08 01:44:42 -05:00
parent 57fd5fae22
commit fdde7dfdba
121 changed files with 534 additions and 1157 deletions

View 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();
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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();
}
}

View 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; }
}
}

View 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(); }
}
}