public static FeatureClass FromFeatureInstance(Feature featureInstance)
        {
            if (featureInstance == null)
            {
                throw new ArgumentNullException(nameof(featureInstance));
            }

            Type featureType     = featureInstance.GetType();
            var  featureFilePath = FeatureClassInfo.FromFeatureClassType(featureType).FeatureFilePath;

            var stepMethods = featureType.GetTypeInfo().GetMethods()
                              .Where(m => m.IsDefined(typeof(BaseStepDefinitionAttribute)))
                              .Select(m => StepMethodInfo.FromMethodInfo(m, featureInstance))
                              .ToList();

            return(new FeatureClass(featureFilePath, stepMethods));
        }
Exemple #2
0
        public static FeatureClass FromFeatureInstance(Feature featureInstance)
        {
            if (featureInstance == null)
            {
                throw new ArgumentNullException(nameof(featureInstance));
            }

            Type featureType = featureInstance.GetType();

            var featureFileAttribute = featureType
                                       .GetTypeInfo()
                                       .GetCustomAttribute <FeatureFileAttribute>();
            var featureFilePath = featureFileAttribute?.Path ?? $"{featureType.Name}.feature";

            var stepMethods = featureType.GetTypeInfo().GetMethods()
                              .Where(m => m.IsDefined(typeof(BaseStepDefinitionAttribute)))
                              .Select(m => StepMethodInfo.FromMethodInfo(m, featureInstance))
                              .ToList();

            return(new FeatureClass(featureFilePath, stepMethods)
            {
                _instance = featureInstance,
            });
        }