Beispiel #1
0
 private void PopulateRelatedActions(INakedObject[] services) {
     var relatedActionSets = new List<INakedObjectAction>();
     foreach (INakedObject serviceAdapter in services) {
         var matchingActions = new List<INakedObjectAction>();
         foreach (INakedObjectAction serviceAction in serviceAdapter.Specification.GetActionLeafNodes().Where(a => a.IsFinderMethod)) {
             INakedObjectSpecification returnType = serviceAction.ReturnType;
             if (returnType != null && returnType.IsCollection) {
                 INakedObjectSpecification elementType = returnType.GetFacet<ITypeOfFacet>().ValueSpec;
                 if (elementType.IsOfType(this)) {
                     matchingActions.Add(serviceAction);
                 }
             }
             else if (returnType != null && returnType.IsOfType(this)) {
                 matchingActions.Add(serviceAction);
             }
         }
         if (matchingActions.Count > 0) {
             var nakedObjectActionSet = new NakedObjectActionSet(serviceAdapter.Specification.Identifier.ClassName,
                                                                 serviceAdapter.TitleString(),
                                                                 matchingActions.ToArray());
             relatedActionSets.Add(nakedObjectActionSet);
         }
     }
     relatedActions = relatedActionSets.ToArray();
 }
Beispiel #2
0
        private  void PopulateContributedActions(INakedObject[] services) {
            var serviceActionSets = new List<INakedObjectAction>();

            if (!IsService) {
                foreach (INakedObject serviceAdapter in services) {
                    INakedObjectSpecification specification = serviceAdapter.Specification;
                    if (specification != this) {
                        INakedObjectAction[] matchingServiceActions = specification.GetActionLeafNodes().Where(serviceAction => serviceAction.IsContributedTo(this)).ToArray();
                        if (matchingServiceActions.Any()) {
                            var nakedObjectActionSet = new NakedObjectActionSet(serviceAdapter.Specification.Identifier.ClassName,
                                                                                serviceAdapter.TitleString(),
                                                                                matchingServiceActions);
                            serviceActionSets.Add(nakedObjectActionSet);
                        }
                    }
                }
            }
            contributedActions = serviceActionSets.ToArray();
        }