示例#1
0
        /// <summary>
        /// Gets the content from the SIFElement for the specified version of SIF. Only
        /// elements that apply to the requested version of SIF will be returned.
        /// </summary>
        /// <param name="element">The element to retrieve content from</param>
        /// <param name="version"></param>
        /// <returns></returns>
        public virtual IList <Element> GetContent(SifElement element, SifVersion version)
        {
            List <Element>            returnValue = new List <Element>();
            ICollection <SimpleField> fields      = element.GetFields();

            foreach (SimpleField val in fields)
            {
                IElementDef def = val.ElementDef;
                if (def.IsSupported(version) &&
                    !def.IsAttribute(version) &&
                    def.Field)
                {
                    returnValue.Add(val);
                }
            }

            IList <SifElement> children = element.GetChildList();

            foreach (SifElement val in children)
            {
                IElementDef def = val.ElementDef;
                if (def.IsSupported(version))
                {
                    returnValue.Add(val);
                }
            }


            MergeSort.Sort <Element>(returnValue, ElementSorter <Element> .GetInstance(version));
            //returnValue.Sort( ElementSorter<Element>.GetInstance( version ) );
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// Gets the content from the SIFElement for the specified version of SIF. Only
        /// elements that apply to the requested version of SIF will be returned.
        /// </summary>
        /// <param name="element">The element to retrieve content from</param>
        /// <param name="version"></param>
        /// <returns></returns>
        public override IList <Element> GetContent(SifElement element, SifVersion version)
        {
            List <Element>            returnValue = new List <Element>();
            ICollection <SimpleField> fields      = element.GetFields();

            foreach (SimpleField val in fields)
            {
                IElementDef def = val.ElementDef;
                if (def.IsSupported(version) &&
                    !def.IsAttribute(version) &&
                    def.Field)
                {
                    returnValue.Add(val);
                }
            }

            IList <SifElement> children = element.GetChildList();

            foreach (SifElement val in children)
            {
                IElementDef def = val.ElementDef;
                if (def.IsSupported(version))
                {
                    if (def.IsCollapsed(version))
                    {
                        ICollection <Element> subElements = GetContent(val, version);
                        // FIXUP the ElementDef for this version of SIF.
                        // for example, StudentPersonal/EmailList/Email needs it's
                        // ElementDef set to "StudentPersonal_Email"
                        foreach (Element e in subElements)
                        {
                            IElementDef subElementDef = e.ElementDef;
                            if (version.CompareTo(subElementDef.EarliestVersion) >= 0)
                            {
                                String      tag         = subElementDef.Tag(Adk.SifVersion);
                                IElementDef restoredDef = Adk.Dtd.LookupElementDef(element.ElementDef, tag);
                                if (restoredDef != null)
                                {
                                    e.ElementDef = restoredDef;
                                }
                                returnValue.Add(e);
                            }
                        }
                    }
                    else
                    {
                        returnValue.Add(val);
                    }
                }
            }
            MergeSort.Sort <Element>(returnValue, ElementSorter <Element> .GetInstance(version));
            //returnValue.Sort(ElementSorter<Element>.GetInstance(version));
            return(returnValue);
        }
        internal AdkAttributeIterator(SifElementPointer parent) : base(parent)
        {
            SifVersion version = parent.Version;

            SifElement node = (SifElement)parent.Node;

            // Capture all fields
            foreach (SimpleField field in node.GetFields())
            {
                IElementDef fieldDef = field.ElementDef;
                if (fieldDef.IsSupported(version) &&
                    fieldDef.IsAttribute(version))
                {
                    addNodeToIterate(field);
                }
            }
        }