コード例 #1
0
        private FieldDefinition PrepareStateHoldingField(string stateInstanceName, CodeProvider <MethodCodeInjectingCodeProviderArgument> codeProvider, ModuleDefinition module)
        {
            if (codeProvider.HasState)
            {
                if (string.IsNullOrWhiteSpace(stateInstanceName))
                {
                    throw new InvalidOperationException($"Code provider '{codeProvider.GetType().FullName}' has state but '{nameof(stateInstanceName)}' is not defined in configuration of processor.");
                }

                var stateInstanceId = new StateInstanceId(stateInstanceName);
                return(StateInstancesCodeGenerator.PrepareInstanceHoldingField(module, codeProvider.GetStateType(), stateInstanceName, stateInstanceId));
            }
            else
            {
                return(null);
            }
        }