22using FlowSynx . Plugins . Amazon . S3 . Models ;
33using FlowSynx . Plugins . Amazon . S3 . Services ;
44using FlowSynx . PluginCore . Extensions ;
5+ using FlowSynx . PluginCore . Helpers ;
56
67namespace FlowSynx . Plugins . Amazon . S3 ;
78
89public class AmazonS3Plugin : IPlugin
910{
1011 private IAmazonS3Manager _manager = null ! ;
1112 private AmazonS3Specifications _s3Specifications = null ! ;
13+ private bool _isInitialized ;
1214
1315 public PluginMetadata Metadata {
1416 get
@@ -30,16 +32,26 @@ public PluginMetadata Metadata {
3032
3133 public Task Initialize ( IPluginLogger logger )
3234 {
35+ if ( ReflectionHelper . IsCalledViaReflection ( ) )
36+ throw new InvalidOperationException ( Resources . ReflectionBasedAccessIsNotAllowed ) ;
37+
3338 ArgumentNullException . ThrowIfNull ( logger ) ;
3439 var connection = new AmazonS3Connection ( ) ;
3540 _s3Specifications = Specifications . ToObject < AmazonS3Specifications > ( ) ;
3641 var client = connection . Connect ( _s3Specifications ) ;
3742 _manager = new AmazonS3Manager ( logger , client , _s3Specifications . Bucket ) ;
43+ _isInitialized = true ;
3844 return Task . CompletedTask ;
3945 }
4046
4147 public async Task < object ? > ExecuteAsync ( PluginParameters parameters , CancellationToken cancellationToken )
4248 {
49+ if ( ReflectionHelper . IsCalledViaReflection ( ) )
50+ throw new InvalidOperationException ( Resources . ReflectionBasedAccessIsNotAllowed ) ;
51+
52+ if ( ! _isInitialized )
53+ throw new InvalidOperationException ( $ "Plugin '{ Metadata . Name } ' v{ Metadata . Version } is not initialized.") ;
54+
4355 var operationParameter = parameters . ToObject < OperationParameter > ( ) ;
4456 var operation = operationParameter . Operation ;
4557
0 commit comments