public bool IsTemplateForReference(ConditionalTemplate template, Citation citation) { if (citation == null) { return(false); } var reference = citation.Reference as Reference; if (reference == null) { return(false); } IEnumerable <ReferencePropertyId> fieldsToCheck = (from kvp in FieldsToCheck where kvp.Value == Ensure.IsEmpty || kvp.Value == Ensure.IsNotEmpty select kvp.Key).ToList(); if (!fieldsToCheck.Any()) { return(false); } foreach (ReferencePropertyId propertyId in fieldsToCheck) { ReferencePropertyDescriptor property = ReferencePropertyDescriptor.GetPropertyDescriptor(propertyId); if (property == null) { continue; } if (!IsConditionMet(reference, property, FieldsToCheck[propertyId])) { return(false); } } return(true); }