コード例 #1
0
        public virtual IEnumerable <string> GetAllPendingMessages()
        {
            var messageCollectorType = _assemblyLoader.GetLibType(LibType.MessageCollector);

            return(_reflectionWrapper.InvokeMethod(messageCollectorType, null, "GetAllPendingMessages",
                                                   BindingFlags.Static | BindingFlags.Public) as IEnumerable <string>);
        }
コード例 #2
0
        public IEnumerable <string> GetStepTexts(GaugeMethod gaugeMethod)
        {
            var stepMethod = MethodMap[gaugeMethod.Name];

            return(stepMethod.GetCustomAttributes(_assemblyLoader.GetLibType(LibType.Step))
                   .SelectMany(x => x.GetType().GetProperty("Names").GetValue(x, null) as string[]));
        }
コード例 #3
0
ファイル: HookMethod.cs プロジェクト: zabil/gauge-dotnet
        public HookMethod(LibType hookType, MethodInfo methodInfo, IAssemblyLoader assemblyLoader)
        {
            Method     = methodInfo.FullyQuallifiedName();
            FilterTags = Enumerable.Empty <string>();

            var type = assemblyLoader.GetLibType(hookType);

            if (!type.IsSubclassOf(assemblyLoader.GetLibType(LibType.FilteredHookAttribute)))
            {
                return;
            }
            var customAttributes      = methodInfo.GetCustomAttributes(false);
            var filteredHookAttribute = customAttributes.FirstOrDefault(type.IsInstanceOfType);

            if (filteredHookAttribute == null)
            {
                return;
            }

            FilterTags = (string[])GetPropValue(filteredHookAttribute, "FilterTags");

            var     targetTagBehaviourType           = assemblyLoader.GetLibType(LibType.TagAggregationBehaviourAttribute);
            dynamic tagAggregationBehaviourAttribute =
                customAttributes.FirstOrDefault(targetTagBehaviourType.IsInstanceOfType);

            if (tagAggregationBehaviourAttribute != null)
            {
                TagAggregation = (int)GetPropValue(tagAggregationBehaviourAttribute, "TagAggregation");
            }
        }
コード例 #4
0
        public static bool IsRecoverableStep(this MethodInfo info, IAssemblyLoader assemblyLoader)
        {
            var stepType = assemblyLoader.GetLibType(LibType.Step);
            var continueOnFailureType = assemblyLoader.GetLibType(LibType.ContinueOnFailure);
            var customAttributes      = info.GetCustomAttributes(false).ToList();

            return(customAttributes.Any(stepType.IsInstanceOfType) &&
                   customAttributes.Any(continueOnFailureType.IsInstanceOfType));
        }
コード例 #5
0
 protected HookExecutionProcessor(IMethodExecutor methodExecutor, IAssemblyLoader assemblyLoader, IReflectionWrapper reflectionWrapper)
 {
     _messageCollectorType = assemblyLoader.GetLibType(LibType.MessageCollector);
     MethodExecutor        = methodExecutor;
     _reflectionWrapper    = reflectionWrapper;
     Strategy = new HooksStrategy();
 }
コード例 #6
0
        public ExecutionStatusResponse Process()
        {
            try
            {
                var initMethod = _assemblyLoader.GetLibType(LibType.DataStoreFactory)
                                 .GetMethod($"Initialize{_dataStoreType}DataStore");
                initMethod.Invoke(null, null);
                return(new ExecutionStatusResponse
                {
                    ExecutionResult = new ProtoExecutionResult
                    {
                        Failed = false,
                        ExecutionTime = 0
                    }
                });
            }
            catch (Exception ex)
            {
                var executionResult = new ProtoExecutionResult
                {
                    Failed        = true,
                    ExecutionTime = 0
                };
                var innerException = ex.InnerException ?? ex;
                executionResult.ErrorMessage = innerException.Message;
                executionResult.StackTrace   = innerException is AggregateException
                    ? innerException.ToString()
                    : innerException.StackTrace;

                return(new ExecutionStatusResponse {
                    ExecutionResult = executionResult
                });
            }
        }
コード例 #7
0
        public Message Process(Message request)
        {
            var initMethod = _assemblyLoader.GetLibType(LibType.DataStoreFactory)
                             .GetMethod($"Initialize{_dataStoreType}DataStore");

            initMethod.Invoke(null, null);
            return(new DefaultProcessor().Process(request));
        }
コード例 #8
0
        private object GetTable(string jsonString)
        {
            var serializer = new DataContractJsonSerializer(_assemblyLoader.GetLibType(LibType.Table));

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)))
            {
                return(serializer.ReadObject(ms));
            }
        }
コード例 #9
0
        public ExecutionStatusResponse Process()
        {
            var initMethod = _assemblyLoader.GetLibType(LibType.DataStoreFactory)
                             .GetMethod($"Initialize{_dataStoreType}DataStore");

            initMethod.Invoke(null, null);
            return(new ExecutionStatusResponse
            {
                ExecutionResult = new ProtoExecutionResult
                {
                    Failed = false,
                    ExecutionTime = 0
                }
            });
        }
コード例 #10
0
        public string GetJSON(ProtoTable table)
        {
            Type    tableType = _assemblyLoader.GetLibType(LibType.Table);
            dynamic table1    = _activatorWrapper.CreateInstance(tableType, table.Headers.Cells.ToList());

            foreach (var protoTableRow in table.Rows)
            {
                table1.AddRow(protoTableRow.Cells.ToList());
            }
            var serializer = new DataContractJsonSerializer(tableType);

            using (var memoryStream = new MemoryStream())
            {
                serializer.WriteObject(memoryStream, table1);
                return(Encoding.UTF8.GetString(memoryStream.ToArray()));
            }
        }
コード例 #11
0
 protected DataStoreInitProcessorBase(IAssemblyLoader assemblyLoader, DataStoreType scenario)
 {
     _dataStoreType        = scenario;
     _dataStoreFactoryType = assemblyLoader.GetLibType(LibType.DataStoreFactory);
 }
コード例 #12
0
 public ExecutionInfoMapper(IAssemblyLoader assemblyLoader, IActivatorWrapper activatorWrapper)
 {
     _executionContextType = assemblyLoader.GetLibType(LibType.ExecutionContext);
     this.activatorWrapper = activatorWrapper;
 }