private void PopulateContributedActions(IObjectSpecBuilder spec, Type[] services, IMetamodel metamodel) { var result = services. AsParallel(). Select(serviceType => { var serviceSpecification = (IServiceSpecImmutable)metamodel.GetSpecification(serviceType); IActionSpecImmutable[] serviceActions = serviceSpecification.ObjectActions.Where(sa => sa != null).ToArray(); var matchingActionsForObject = serviceType != spec.Type ? serviceActions.Where(sa => sa.IsContributedTo(spec)).ToList() : new List <IActionSpecImmutable>(); var matchingActionsForCollection = serviceType != spec.Type ? serviceActions.Where(sa => sa.IsContributedToCollectionOf(spec)).ToList() : new List <IActionSpecImmutable>(); var finderActions = serviceActions.Where(sa => sa.IsFinderMethodFor(spec)).ToList(); if (finderActions.Any()) { finderActions.Sort(new MemberOrderComparator <IActionSpecImmutable>()); } return(new Tuple <List <IActionSpecImmutable>, List <IActionSpecImmutable>, List <IActionSpecImmutable> >(matchingActionsForObject, matchingActionsForCollection, finderActions)); }). Aggregate(new Tuple <List <IActionSpecImmutable>, List <IActionSpecImmutable>, List <IActionSpecImmutable> >(new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>()), (a, t) => { a.Item1.AddRange(t.Item1); a.Item2.AddRange(t.Item2); a.Item3.AddRange(t.Item3); return(a); }); spec.AddContributedActions(result.Item1); spec.AddCollectionContributedActions(result.Item2); spec.AddFinderActions(result.Item3); }
private void PopulateContributedActions(IObjectSpecBuilder spec, Type[] services, IMetamodel metamodel) { var result = services. AsParallel(). Select(serviceType => { var serviceSpecification = (IServiceSpecImmutable)metamodel.GetSpecification(serviceType); IActionSpecImmutable[] serviceActions = serviceSpecification.ObjectActions.Where(sa => sa != null).ToArray(); var matchingActionsForObject = new List <IActionSpecImmutable>(); var matchingActionsForCollection = new List <IActionSpecImmutable>(); var finderActions = new List <IActionSpecImmutable>(); foreach (var sa in serviceActions) { if (serviceType != spec.Type) { if (sa.IsContributedTo(spec)) { matchingActionsForObject.Add(sa); } if (sa.IsContributedToCollectionOf(spec)) { matchingActionsForCollection.Add(sa); } } if (sa.IsFinderMethodFor(spec)) { finderActions.Add(sa); } } return(new Tuple <List <IActionSpecImmutable>, List <IActionSpecImmutable>, List <IActionSpecImmutable> >(matchingActionsForObject, matchingActionsForCollection, finderActions.OrderBy(a => a, new MemberOrderComparator <IActionSpecImmutable>()).ToList())); }). Aggregate(new Tuple <List <IActionSpecImmutable>, List <IActionSpecImmutable>, List <IActionSpecImmutable> >(new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>()), (a, t) => { a.Item1.AddRange(t.Item1); a.Item2.AddRange(t.Item2); a.Item3.AddRange(t.Item3); return(a); }); // var contribActions = new List <IActionSpecImmutable>(); // group by service - probably do this better - TODO foreach (var service in services) { var matching = result.Item1.Where(i => i.OwnerSpec.Type == service); contribActions.AddRange(matching); } spec.AddContributedActions(contribActions); spec.AddCollectionContributedActions(result.Item2); spec.AddFinderActions(result.Item3); }
private IdentifierImpl(IMetamodel metamodel, string className, string fieldName, string[] parameterNames, string[] parameterTypeNames, bool isField) { this.className = className; name = fieldName; parameterTypes = parameterTypeNames; MemberParameterSpecifications = parameterTypes.Select(x => metamodel.GetSpecification(TypeNameUtils.DecodeTypeName(x))).ToArray(); this.parameterNames = parameterNames; this.isField = isField; }
private static void PopulateContributedActions(IObjectSpecBuilder spec, Type[] services, IMetamodel metamodel) { var(contribActions, collContribActions, finderActions) = services.AsParallel().Select(serviceType => { var serviceSpecification = (IServiceSpecImmutable)metamodel.GetSpecification(serviceType); var serviceActions = serviceSpecification.ObjectActions.Where(sa => sa != null).ToArray(); var matchingActionsForObject = new List <IActionSpecImmutable>(); var matchingActionsForCollection = new List <IActionSpecImmutable>(); var matchingFinderActions = new List <IActionSpecImmutable>(); foreach (var sa in serviceActions) { if (serviceType != spec.Type) { if (sa.IsContributedTo(spec)) { matchingActionsForObject.Add(sa); } if (sa.IsContributedToCollectionOf(spec)) { matchingActionsForCollection.Add(sa); } } if (sa.IsFinderMethodFor(spec)) { matchingFinderActions.Add(sa); } } return(matchingActionsForObject, matchingActionsForCollection, matchingFinderActions.OrderBy(a => a, new MemberOrderComparator <IActionSpecImmutable>()).ToList()); }).Aggregate((new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>(), new List <IActionSpecImmutable>()), (a, t) => { var(contrib, collContrib, finder) = a; var(ca, cca, fa) = t; contrib.AddRange(ca); collContrib.AddRange(cca); finder.AddRange(fa); return(a); }); var groupedContribActions = contribActions.GroupBy(i => i.OwnerSpec.Type, i => i, (service, actions) => new { service, actions }).OrderBy(a => Array.IndexOf(services, a.service)).SelectMany(a => a.actions).ToList(); spec.AddContributedActions(groupedContribActions); spec.AddCollectionContributedActions(collContribActions); spec.AddFinderActions(finderActions); }
public IObjectSpecImmutable GetValueSpec(INakedObjectAdapter collection, IMetamodel metamodel) { return (IObjectSpecImmutable) metamodel.GetSpecification(GetValue(collection)); }
public IObjectSpecImmutable GetValueSpec(INakedObjectAdapter collection, IMetamodel metamodel) => (IObjectSpecImmutable)metamodel.GetSpecification(GetValue(collection));
public IObjectSpecImmutable GetValueSpec(INakedObject collection, IMetamodel metamodel) { return(metamodel.GetSpecification(GetValue(collection))); }