Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the fields from the SIFElement for the specified version of SIF. Only
        /// the fields that apply to the requested version of SIF will be returned.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public virtual ICollection <SimpleField> GetFields(SifElement element, SifVersion version)
        {
            ICollection <SimpleField> fields      = element.GetFields();
            List <SimpleField>        returnValue = new List <SimpleField>();

            // remove any fields that do not belong in this version of SIF
            foreach (SimpleField field in fields)
            {
                IElementDef def = field.ElementDef;
                if (version.CompareTo(def.EarliestVersion) > -1 &&
                    version.CompareTo(def.LatestVersion) < 1)
                {
                    returnValue.Add(field);
                }
            }
            returnValue.Sort(ElementSorter <SimpleField> .GetInstance(version));
            return(returnValue);
        }
Esempio n. 6
0
        //private const int CLOSE = 2;

        private Boolean HasContent(SifElement o,
                                   SifVersion version)
        {
            if (o.ChildCount > 0)
            {
                return(true);
            }
            ICollection <SimpleField> fields = o.GetFields();

            foreach (SimpleField f in fields)
            {
                // TODO: This is a perfect place to optimize. Version-specific lookups
                // should be optimized

                if (f.ElementDef.IsSupported(version) && !f.ElementDef.IsAttribute(version))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 7
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;
        }
Esempio n. 8
0
 /// <summary>
 /// Gets the fields from the SIFElement for the specified version of SIF. Only
 /// the fields that apply to the requested version of SIF will be returned.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="version"></param>
 /// <returns></returns>
 public virtual ICollection<SimpleField> GetFields(SifElement element, SifVersion version)
 {
     ICollection<SimpleField> fields = element.GetFields();
     List<SimpleField> returnValue = new List<SimpleField>();
     // remove any fields that do not belong in this version of SIF
     foreach(SimpleField field in fields )
     {
         IElementDef def = field.ElementDef;
         if (version.CompareTo(def.EarliestVersion) > -1 &&
                 version.CompareTo(def.LatestVersion) < 1)
         {
             returnValue.Add( field );
         }
     }
     returnValue.Sort( ElementSorter<SimpleField>.GetInstance( version ) );
     return returnValue;
 }
Esempio n. 9
0
        //private const int CLOSE = 2;
        private Boolean HasContent( SifElement o,
                                    SifVersion version )
        {
            if ( o.ChildCount > 0 )
            {
                return true;
            }
            ICollection<SimpleField> fields = o.GetFields();
            foreach ( SimpleField f in fields )
            {
                // TODO: This is a perfect place to optimize. Version-specific lookups
                // should be optimized

                if ( f.ElementDef.IsSupported( version ) && !f.ElementDef.IsAttribute( version ) )
                {
                    return true;
                }
            }
            return false;
        }