Commit b615a32a by dingsongjie

删除不必要的类

parent d94f3747
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace Orleans.Providers.EntityFramework
{
public delegate void ConfigureEntryStateDelegate<TGrainState>(EntityEntry<TGrainState> entry)
where TGrainState : class;
}
\ No newline at end of file
using System.Threading;
namespace Orleans.Providers.EntityFramework
{
/// <summary>
/// An async local context to apply modifications to current behavior of write and clear operations.
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public static class GrainStorageContext<TEntity>
where TEntity : class
{
// ReSharper disable once StaticMemberInGenericType
private static readonly AsyncLocal<bool> IsConfiguredLocal
= new AsyncLocal<bool>();
private static readonly AsyncLocal<ConfigureEntryStateDelegate<TEntity>>
ConfigureStateDelegateLocal
= new AsyncLocal<ConfigureEntryStateDelegate<TEntity>>();
internal static bool IsConfigured => IsConfiguredLocal.Value;
internal static ConfigureEntryStateDelegate<TEntity> ConfigureStateDelegate
=> ConfigureStateDelegateLocal.Value;
/// <summary>
/// Configures the entry state.
/// Use it to modify what gets changed during the write operations.
/// </summary>
/// <param name="configureState">The delegate to be called before saving context's state.</param>
public static void ConfigureEntryState(ConfigureEntryStateDelegate<TEntity> configureState)
{
ConfigureStateDelegateLocal.Value = configureState;
IsConfiguredLocal.Value = true;
}
public static void Clear()
{
ConfigureStateDelegateLocal.Value = null;
IsConfiguredLocal.Value = false;
}
}
}
\ No newline at end of file
using System;
using Orleans.Runtime;
namespace Orleans.Providers.EntityFramework.Conventions
{
public delegate ValueType GetCompoundKeyDelegate(IAddressable addressable, out string keyExt);
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace Orleans.Providers.EntityFramework.Exceptions
namespace Pole.Orleans.Provider.EntityframeworkCore
{
// todo: Use for configuration errors
public class GrainStorageConfigurationException : Exception
......@@ -17,4 +19,4 @@ namespace Orleans.Providers.EntityFramework.Exceptions
{
}
}
}
\ No newline at end of file
}
using System;
using Microsoft.EntityFrameworkCore;
using Orleans.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Orleans.Runtime;
using Pole.Orleans.Provider.EntityframeworkCore;
namespace Orleans.Providers.EntityFramework.Extensions
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public static class GrainStorageOptionsExtensions
{
public static GrainStorageOptions<TContext, TGrain, TGrainState> UseQuery<TContext, TGrain, TGrainState>(
this GrainStorageOptions<TContext, TGrain, TGrainState> options,
Func<TContext, IQueryable<TGrainState>> queryFunc)
Func<TContext, IQueryable<TGrainState>>queryFunc)
where TContext : DbContext
where TGrainState : class
{
......@@ -258,4 +259,4 @@ namespace Orleans.Providers.EntityFramework.Extensions
return options;
}
}
}
\ No newline at end of file
}
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Orleans.Providers.EntityFramework.Conventions;
using Orleans;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Storage;
using Pole.Orleans.Provider.EntityframeworkCore;
using Pole.Orleans.Provider.EntityframeworkCore.Conventions;
using System;
using System.Collections.Generic;
using System.Text;
namespace Orleans.Providers.EntityFramework.Extensions
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public static class GrainStorageServiceCollectionExtensions
{
......@@ -67,4 +69,4 @@ namespace Orleans.Providers.EntityFramework.Extensions
}
}
}
\ No newline at end of file
}
using Microsoft.EntityFrameworkCore;
using Orleans.Hosting;
using Orleans.Providers;
using System;
using System.Collections.Generic;
using System.Text;
namespace Orleans.Providers.EntityFramework.Extensions
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public static class GrainStorageSiloHostBuilderExtensions
{
......@@ -15,15 +19,12 @@ namespace Orleans.Providers.EntityFramework.Extensions
string providerName)
where TContext : DbContext
{
return builder
.ConfigureServices(services =>
{
services.AddEfGrainStorage<TContext>(providerName);
});
.ConfigureServices(services => { services.AddEfGrainStorage<TContext>(providerName); });
}
public static ISiloBuilder AddEfGrainStorageAsDefault<TContext>(this ISiloBuilder builder)
where TContext : DbContext
where TContext : DbContext
{
return builder.AddEfGrainStorage<TContext>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
}
......@@ -36,4 +37,4 @@ namespace Orleans.Providers.EntityFramework.Extensions
.ConfigureServices(services => { services.AddEfGrainStorage<TContext>(providerName); });
}
}
}
\ No newline at end of file
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Pole.Orleans.Provider.EntityframeworkCore
{
// todo: Use for configuration errors
public class GrainStorageConfigurationException : Exception
{
public GrainStorageConfigurationException()
{
}
public GrainStorageConfigurationException(string message) : base(message)
{
}
public GrainStorageConfigurationException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Orleans;
using Orleans.Providers;
using Orleans.Runtime;
using Orleans.Storage;
using Pole.Orleans.Provider.EntityframeworkCore.Conventions;
using System;
using System.Collections.Generic;
using System.Text;
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public static class GrainStorageServiceCollectionExtensions
{
public static IServiceCollection ConfigureGrainStorageOptions<TContext, TGrain, TEntity>(
this IServiceCollection services,
Action<GrainStorageOptions<TContext, TGrain, TEntity>> configureOptions = null)
where TContext : DbContext
where TGrain : Grain<TEntity>
where TEntity : class, new()
{
return services
.AddSingleton<IPostConfigureOptions<GrainStorageOptions<TContext, TGrain, TEntity>>,
GrainStoragePostConfigureOptions<TContext, TGrain, TEntity, TEntity>>()
.Configure<GrainStorageOptions<TContext, TGrain, TEntity>>(typeof(TGrain).FullName, options =>
{
configureOptions?.Invoke(options);
});
}
public static IServiceCollection ConfigureGrainStorageOptions<TContext, TGrain, TGrainState, TEntity>(
this IServiceCollection services,
Action<GrainStorageOptions<TContext, TGrain, TEntity>> configureOptions = null)
where TContext : DbContext
where TGrain : Grain<TGrainState>
where TGrainState : new()
where TEntity : class
{
return services
.AddSingleton<IPostConfigureOptions<GrainStorageOptions<TContext, TGrain, TEntity>>,
GrainStoragePostConfigureOptions<TContext, TGrain, TGrainState, TEntity>>()
.Configure<GrainStorageOptions<TContext, TGrain, TEntity>>(typeof(TGrain).FullName, options =>
{
configureOptions?.Invoke(options);
});
}
public static IServiceCollection AddEfGrainStorage<TContext>(
this IServiceCollection services,
string providerName = ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME)
where TContext : DbContext
{
services.TryAddSingleton(typeof(IEntityTypeResolver), typeof(EntityTypeResolver));
services.TryAddSingleton(typeof(IGrainStorageConvention), typeof(GrainStorageConvention));
services.TryAddSingleton(typeof(IGrainStateEntryConfigurator<,,>),
typeof(DefaultGrainStateEntryConfigurator<,,>));
services.AddSingleton(typeof(EntityFrameworkGrainStorage<TContext>));
services.TryAddSingleton<IGrainStorage>(sp =>
sp.GetServiceByName<IGrainStorage>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME));
services.AddSingletonNamedService<IGrainStorage>(providerName,
(sp, name) => sp.GetRequiredService<EntityFrameworkGrainStorage<TContext>>());
return services;
}
}
}
using Microsoft.EntityFrameworkCore;
using Orleans.Hosting;
using Orleans.Providers;
using System;
using System.Collections.Generic;
using System.Text;
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public static class GrainStorageSiloHostBuilderExtensions
{
public static ISiloHostBuilder AddEfGrainStorageAsDefault<TContext>(this ISiloHostBuilder builder)
where TContext : DbContext
{
return builder.AddEfGrainStorage<TContext>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
}
public static ISiloHostBuilder AddEfGrainStorage<TContext>(this ISiloHostBuilder builder,
string providerName)
where TContext : DbContext
{
return builder
.ConfigureServices(services => { services.AddEfGrainStorage<TContext>(providerName); });
}
public static ISiloBuilder AddEfGrainStorageAsDefault<TContext>(this ISiloBuilder builder)
where TContext : DbContext
{
return builder.AddEfGrainStorage<TContext>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME);
}
public static ISiloBuilder AddEfGrainStorage<TContext>(this ISiloBuilder builder,
string providerName)
where TContext : DbContext
{
return builder
.ConfigureServices(services => { services.AddEfGrainStorage<TContext>(providerName); });
}
}
}
using System.Threading.Tasks;
using Orleans.Runtime;
namespace Orleans.Providers.EntityFramework
{
internal delegate Task ReadWriteStateAsyncDelegate(string grainType, GrainReference grainReference,
IGrainState grainState, object storageOptions);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment