private IActionSpecImmutable[] FindActionMethods(ITypeSpecImmutable spec) { Log.Debug("Looking for action methods"); var actionSpecs = new List <IActionSpecImmutable>(); var actions = FacetFactorySet.FindActions(methods.Where(m => m != null).ToArray(), reflector.ClassStrategy).Where(a => !FacetFactorySet.Filters(a, reflector.ClassStrategy)).ToArray(); methods = methods.Except(actions).ToArray(); // ReSharper disable once ForCanBeConvertedToForeach // kepp for look as actions are nulled out within loop for (int i = 0; i < actions.Length; i++) { MethodInfo actionMethod = actions[i]; // actions are potentially being nulled within this loop if (actionMethod != null) { string fullMethodName = actionMethod.Name; Type[] parameterTypes = actionMethod.GetParameters().Select(parameterInfo => parameterInfo.ParameterType).ToArray(); // build action & its parameters if (actionMethod.ReturnType != typeof(void)) { reflector.LoadSpecification(actionMethod.ReturnType); } IIdentifier identifier = new IdentifierImpl(FullName, fullMethodName, actionMethod.GetParameters().ToArray()); IActionParameterSpecImmutable[] actionParams = parameterTypes.Select(pt => ImmutableSpecFactory.CreateActionParameterSpecImmutable(reflector.LoadSpecification <IObjectSpecImmutable>(pt), identifier)).ToArray(); var action = ImmutableSpecFactory.CreateActionSpecImmutable(identifier, spec, actionParams); // Process facets on the action & parameters FacetFactorySet.Process(reflector, actionMethod, new IntrospectorMethodRemover(actions), action, FeatureType.Actions); for (int l = 0; l < actionParams.Length; l++) { FacetFactorySet.ProcessParams(reflector, actionMethod, l, actionParams[l]); } actionSpecs.Add(action); } } return(actionSpecs.ToArray()); }
private IActionSpecImmutable[] FindActionMethods(IObjectSpecImmutable spec) { Log.Debug("Looking for action methods"); var actionSpecs = new List <IActionSpecImmutable>(); for (int i = 0; i < methods.Length; i++) { // careful in here - methods are being nulled out within the methods array as we iterate. if (methods[i] != null) { MethodInfo actionMethod = methods[i]; string fullMethodName = actionMethod.Name; if (!FacetFactorySet.Filters(actionMethod, reflector.ClassStrategy)) { Log.DebugFormat("Identified action {0}", actionMethod); methods[i] = null; Type[] parameterTypes = actionMethod.GetParameters().Select(parameterInfo => parameterInfo.ParameterType).ToArray(); // build action & its parameters IActionParameterSpecImmutable[] actionParams = parameterTypes.Select(pt => new ActionParameterSpecImmutable(GetSpecification(pt))).Cast <IActionParameterSpecImmutable>().ToArray(); IIdentifier identifier = new IdentifierImpl(metamodel, FullName, fullMethodName, actionMethod.GetParameters().ToArray()); var action = new ActionSpecImmutable(identifier, spec, actionParams); // Process facets on the action & parameters FacetFactorySet.Process(reflector, actionMethod, new IntrospectorMethodRemover(methods), action, FeatureType.Action); for (int l = 0; l < actionParams.Length; l++) { FacetFactorySet.ProcessParams(reflector, actionMethod, l, actionParams[l]); } if (actionMethod.ReturnType != typeof(void)) { reflector.LoadSpecification(actionMethod.ReturnType); } actionSpecs.Add(action); } } } return(actionSpecs.ToArray()); }