You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework.Service.../Connected.ServiceModel.Clie.../TableSchemaMiddleware.cs

58 lines
1.8 KiB

using Connected.Annotations;
using Connected.Data.Schema;
using Connected.Entities.Storage;
using Connected.Middleware;
using Connected.ServiceModel.Client.Net;
using Connected.ServiceModel.Data;
namespace Connected.ServiceModel.Client.Data;
[Priority(2)]
internal sealed class TableSchemaMiddleware : MiddlewareComponent, ISchemaMiddleware
{
public TableSchemaMiddleware(IMiddlewareService middleware, IStorageProvider storage, IConnectedServer connected)
{
Storage = storage;
Connected = connected;
}
private IStorageProvider Storage { get; }
public IConnectedServer Connected { get; }
public Type ConnectionType => typeof(TableDataConnection);
public string DefaultConnectionString { get; private set; } = default!;
protected override async Task OnInitialize()
{
DefaultConnectionString = await Connected.SelectUrl(new ConnectedServerUrlArgs { Kind = ConnectedUrlKind.TableStorage });
}
public async Task<bool> IsEntitySupported(Type entityType)
{
await Task.CompletedTask;
/*
* This middleware supports all ITableEntity<> entities.
*/
return entityType.IsAssignableTo(typeof(ITableEntity<,>));
}
public async Task Synchronize(Type entity, ISchema schema)
{
await Synchronize(schema, DefaultConnectionString);
}
private async Task Synchronize(ISchema schema, string connectionString)
{
//var args = new SchemaExecutionContext(Storage, schema, connectionString);
///*
// * Sinchronize schema object first.
// */
//await new SchemaSynchronize().Execute(args);
///*
// * Only tables are supported
// */
//if (string.IsNullOrWhiteSpace(schema.Type) || string.Equals(schema.Type, SchemaAttribute.SchemaTypeTable, StringComparison.OrdinalIgnoreCase))
// await new TableSynchronize().Execute(args);
await Task.CompletedTask;
}
}