mirror of
https://github.com/riperiperi/FreeSO
synced 2026-08-13 20:26:13 -04:00
MPL per-file was used in older project files, but should apply to the whole project, so having it there was redundant.
72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
using FSO.Common.DatabaseService.Framework;
|
|
using FSO.Common.DataService.Framework;
|
|
using FSO.Common.Serialization;
|
|
using FSO.Server.Protocol.Voltron.DataService;
|
|
using Ninject.Activation;
|
|
using Ninject.Modules;
|
|
using System;
|
|
|
|
namespace FSO.Server.DataService
|
|
{
|
|
/// <summary>
|
|
/// Data service classes that can be shared between multiple shards when multi-tenanting
|
|
/// </summary>
|
|
public class GlobalDataServiceModule : NinjectModule
|
|
{
|
|
public override void Load()
|
|
{
|
|
this.Bind<cTSOSerializer>().ToProvider<cTSOSerializerProvider>().InSingletonScope();
|
|
this.Bind<IModelSerializer>().ToProvider<ModelSerializerProvider>().InSingletonScope();
|
|
this.Bind<ISerializationContext>().To<SerializationContext>();
|
|
}
|
|
}
|
|
|
|
class ModelSerializerProvider : IProvider<IModelSerializer>
|
|
{
|
|
private Content.Content Content;
|
|
|
|
public ModelSerializerProvider(Content.Content content)
|
|
{
|
|
this.Content = content;
|
|
}
|
|
|
|
public Type Type
|
|
{
|
|
get
|
|
{
|
|
return typeof(IModelSerializer);
|
|
}
|
|
}
|
|
|
|
public object Create(IContext context)
|
|
{
|
|
var serializer = new ModelSerializer();
|
|
serializer.AddTypeSerializer(new DatabaseTypeSerializer());
|
|
serializer.AddTypeSerializer(new DataServiceModelTypeSerializer(Content.DataDefinition));
|
|
serializer.AddTypeSerializer(new DataServiceModelVectorTypeSerializer(Content.DataDefinition));
|
|
return serializer;
|
|
}
|
|
}
|
|
|
|
class cTSOSerializerProvider : IProvider<cTSOSerializer>
|
|
{
|
|
private Content.Content Content;
|
|
|
|
public cTSOSerializerProvider(Content.Content content)
|
|
{
|
|
this.Content = content;
|
|
}
|
|
|
|
public Type Type
|
|
{
|
|
get
|
|
{
|
|
return typeof(cTSOSerializer);
|
|
}
|
|
}
|
|
|
|
public object Create(IContext context){
|
|
return new cTSOSerializer(this.Content.DataDefinition);
|
|
}
|
|
}
|
|
}
|