예제 #1
0
        internal static List <string> GetTargetedReferenceTypes(this Criterium chainCriterium, string resourceType)
        {
            if (chainCriterium.Type != Operator.CHAIN)
            {
                throw new ArgumentException("Targeted reference types are only relevent for chained criteria.");
            }

            var critSp        = chainCriterium.FindSearchParamDefinition(resourceType);
            var modifier      = chainCriterium.Modifier;
            var nextInChain   = (Criterium)chainCriterium.Operand;
            var nextParameter = nextInChain.ParamName;
            // The modifier contains the type of resource that the referenced resource must be. It is optional.
            // If not present, search all possible types of resources allowed at this reference.
            // If it is present, it should be of one of the possible types.

            var searchResourceTypes = GetTargetedReferenceTypes(critSp, modifier);

            // Afterwards, filter on the types that actually have the requested searchparameter.
            return(searchResourceTypes.Where(rt => InternalField.All.Contains(nextParameter) || ModelInfo.SearchParameters.Exists(sp => rt.Equals(sp.Resource) && nextParameter.Equals(sp.Name))).ToList());
        }