private Tuple <IAssociationSpecImmutable[], IImmutableDictionary <string, ITypeSpecBuilder> > FindAndCreateFieldSpecs(IObjectSpecImmutable spec, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { // now create fieldSpecs for value properties, for collections and for reference properties IList <PropertyInfo> collectionProperties = FacetFactorySet.FindCollectionProperties(properties, ClassStrategy).Where(pi => !FacetFactorySet.Filters(pi, ClassStrategy)).ToArray(); var result1 = CreateCollectionSpecs(collectionProperties, spec, metamodel); IEnumerable <IAssociationSpecImmutable> collectionSpecs = result1.Item1; metamodel = result1.Item2; // every other accessor is assumed to be a reference property. IList <PropertyInfo> allProperties = FacetFactorySet.FindProperties(properties, ClassStrategy).Where(pi => !FacetFactorySet.Filters(pi, ClassStrategy)).ToArray(); IEnumerable <PropertyInfo> refProperties = allProperties.Except(collectionProperties); var result = CreateRefPropertySpecs(refProperties, spec, metamodel); var refSpecs = result.Item1; metamodel = result.Item2; return(new Tuple <IAssociationSpecImmutable[], IImmutableDictionary <string, ITypeSpecBuilder> >(collectionSpecs.Union(refSpecs).ToArray(), metamodel)); }
private Tuple <IActionSpecImmutable[], IImmutableDictionary <string, ITypeSpecBuilder> > FindActionMethods(ITypeSpecImmutable spec, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { 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)) { metamodel = reflector.LoadSpecification(actionMethod.ReturnType, metamodel).Item2; } IIdentifier identifier = new IdentifierImpl(FullName, fullMethodName, actionMethod.GetParameters().ToArray()); //IActionParameterSpecImmutable[] actionParams = parameterTypes. // Select(pt => ImmutableSpecFactory.CreateActionParameterSpecImmutable(reflector.LoadSpecification<IObjectSpecImmutable>(pt, metamodel), identifier)).ToArray(); var actionParams = new List <IActionParameterSpecImmutable>(); foreach (var pt in parameterTypes) { var result = reflector.LoadSpecification(pt, metamodel); metamodel = result.Item2; var ospec = result.Item1 as IObjectSpecImmutable; var actionSpec = ImmutableSpecFactory.CreateActionParameterSpecImmutable(ospec, identifier); actionParams.Add(actionSpec); } var action = ImmutableSpecFactory.CreateActionSpecImmutable(identifier, spec, actionParams.ToArray()); // Process facets on the action & parameters metamodel = FacetFactorySet.Process(reflector, actionMethod, new IntrospectorMethodRemover(actions), action, FeatureType.Actions, metamodel); for (int l = 0; l < actionParams.Count; l++) { metamodel = FacetFactorySet.ProcessParams(reflector, actionMethod, l, actionParams[l], metamodel); } actionSpecs.Add(action); } } return(new Tuple <IActionSpecImmutable[], IImmutableDictionary <string, ITypeSpecBuilder> >(actionSpecs.ToArray(), metamodel)); }
private (IAssociationSpecImmutable[], IImmutableDictionary <string, ITypeSpecBuilder>) FindAndCreateFieldSpecs(IObjectSpecImmutable spec, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { // now create fieldSpecs for value properties, for collections and for reference properties var collectionProperties = FacetFactorySet.FindCollectionProperties(properties, ClassStrategy).Where(pi => !FacetFactorySet.Filters(pi, ClassStrategy)).ToArray(); IEnumerable <IAssociationSpecImmutable> collectionSpecs; (collectionSpecs, metamodel) = CreateCollectionSpecs(collectionProperties, spec, metamodel); // every other accessor is assumed to be a reference property. var allProperties = FacetFactorySet.FindProperties(properties, ClassStrategy).Where(pi => !FacetFactorySet.Filters(pi, ClassStrategy)).ToArray(); var refProperties = allProperties.Except(collectionProperties); IEnumerable <IAssociationSpecImmutable> refSpecs; (refSpecs, metamodel) = CreateRefPropertySpecs(refProperties, spec, metamodel); return(collectionSpecs.Union(refSpecs).ToArray(), metamodel); }