public List <CF> Query <CF>(contentRelationQueryType qType, contentRelationType qRelation, IContentElement qReference, int limit = -1) { List <CF> output = new List <CF>(); contentElementList elements = Query(qRelation, qReference, limit); foreach (IContentElement element in elements) { switch (qType) { case contentRelationQueryType.gatherFlags: IContentToken ict = element as IContentToken; if (ict != null) { output.AddRange(ict.flags.getEnumListFromFlags <CF>()); // output.populateWith(ict.flags); } break; case contentRelationQueryType.gatherSentenceFlags: IContentSentence ics = element as IContentSentence; if (ics != null) { output.AddRange(ics.sentenceFlags.getEnumListFromFlags <CF>()); // output.populateWith(ics.sentenceFlags); } break; case contentRelationQueryType.gatherParagraphFlags: IContentParagraph icp = element as IContentParagraph; if (icp != null) { output.AddRange(icp.flags.getEnumListFromFlags <CF>()); // output.populateWith(icp.flags); } // output.populateWith(icp.flags); break; case contentRelationQueryType.gatherBlockTags: IContentBlock icb = element as IContentBlock; if (icb != null) { output.AddRange(icb.flags.getEnumListFromFlags <CF>()); // output.populateWith(icb.flags); } break; case contentRelationQueryType.gatherOrigins: throw new NotImplementedException("gatherOrigin"); //IContentToken icto = element as IContentToken; //if (icto != null) output.Add((CF)icto.origin); break; default: //output.populateWith(element.flags); break; } } return(output); }
public List <string> Query(contentRelationQueryType qType, contentRelationType qRelation, IContentElement qReference, int limit = -1) { List <string> output = new List <string>(); contentElementList elements = Query(qRelation, qReference, limit); foreach (IContentElement element in elements) { switch (qType) { case contentRelationQueryType.gatherContents: output.Add(element.content); break; default: break; } } return(output); }
/// <summary> /// Vraca listu elemenata u skladu sa upitom /// </summary> /// <param name="qRelation"></param> /// <param name="qReference"></param> /// <param name="limit"></param> /// <returns></returns> public contentElementList Query(contentRelationType qRelation, IContentElement qReference, int limit = -1) { contentElementList output = new contentElementList(); int i = 0; IContentElement hIndex; switch (qRelation) { case contentRelationType.self: output.AddNullSafe(qReference); break; case contentRelationType.next: output.AddNullSafe(qReference.next); break; case contentRelationType.prev: output.AddNullSafe(qReference.prev); break; case contentRelationType.both: output.AddNullSafe(qReference.next); output.AddNullSafe(qReference.prev); break; case contentRelationType.manyBoth: break; case contentRelationType.manyNext: hIndex = qReference; do { hIndex = takeIndex(hIndex, contentRelationType.next, i, limit); output.AddNullSafe(hIndex); i++; } while (hIndex != null); break; case contentRelationType.manyPrev: hIndex = qReference; do { hIndex = takeIndex(hIndex, contentRelationType.prev, i, limit); output.AddNullSafe(hIndex); i++; } while (hIndex != null); break; case contentRelationType.parent: output.AddNullSafe(qReference.parent); break; case contentRelationType.manyParent: hIndex = qReference; do { hIndex = takeIndex(hIndex, contentRelationType.parent, i, limit); output.AddNullSafe(hIndex); i++; } while (hIndex != null); break; case contentRelationType.parentOneBefore: hIndex = qReference.parent; if (hIndex != null) { hIndex = take(hIndex, contentRelationType.prev); output.AddNullSafe(hIndex); } break; case contentRelationType.parentOneAfter: hIndex = qReference.parent; if (hIndex != null) { hIndex = take(hIndex, contentRelationType.next); output.AddNullSafe(hIndex); } break; case contentRelationType.parentManyBefore: hIndex = qReference.parent; do { hIndex = takeIndex(hIndex, contentRelationType.prev, i, limit); output.AddNullSafe(hIndex); i++; } while (hIndex != null); break; case contentRelationType.parentManyAfter: hIndex = qReference.parent; do { hIndex = takeIndex(hIndex, contentRelationType.next, i, limit); output.AddNullSafe(hIndex); i++; } while (hIndex != null); break; default: logSystem.log("contentCollection Query :: contentRelationType not supported: [" + qRelation.ToString() + "]", logType.ExecutionError); break; } return(output); }