示例#1
0
        public IExampleStorage <TState> Create <TState>(IExampleStorageConfig config)
        {
            var storage = this.context.ActivationServices.GetRequiredService <BlobExampleStorage <TState> >();

            storage.Configure(config);
            return(storage);
        }
示例#2
0
        public IExampleStorage <TState> Create <TState>(IExampleStorageConfig config)
        {
            var storage = this.context.ActivationServices.GetRequiredService <TableExampleStorage <TState> >();

            storage.Configure(config);
            storage.Participate(this.context.ObservableLifecycle);
            return(storage);
        }
        public IExampleStorage <TState> Create <TState>(string name, IExampleStorageConfig cfg)
        {
            IExampleStorageFactory factory = string.IsNullOrEmpty(name)
                ? this.services.GetService <IExampleStorageFactory>()
                : this.services.GetServiceByName <IExampleStorageFactory>(name);

            if (factory != null)
            {
                return(factory.Create <TState>(cfg));
            }
            throw new InvalidOperationException($"Storage feature with name {name} not found.");
        }
示例#4
0
        public Factory <IGrainActivationContext, object> GetFactory(ParameterInfo parameter, ExampleStorageAttribute attribute)
        {
            IExampleStorageConfig config = attribute;

            // set state name to parameter name, if not already specified
            if (string.IsNullOrEmpty(config.StateName))
            {
                config = new ExampleStorageConfig(parameter.Name);
            }
            // use generic type args to define collection type.
            MethodInfo genericCreate = create.MakeGenericMethod(parameter.ParameterType.GetGenericArguments());

            object[] args = new object[] { attribute.StorageProviderName, config };
            return(context => Create(context, genericCreate, args));
        }
 public void Configure(IExampleStorageConfig cfg)
 {
     this.config = cfg;
 }