public override void ValidateField(Enums.ColladaElementType parent_type)
        {
            if (Value == null)
            {
                return;
            }

            ColladaElement value = Value as ColladaElement;

            if (value != null)
            {
                value.ValidateElement(parent_type);
            }
        }
Example #2
0
        public override string ToString()
        {
            var baseString = base.ToString();

            if (String.IsNullOrEmpty(baseString))
            {
                return("");
            }

            if (ColladaElement.TestFormat <T>(baseString))
            {
                return(baseString);
            }
            else
            {
                return(ColladaElement.FormatID <T>(base.ToString()));
            }
        }
        /// <summary>
        /// Gets a list containing all of this elements children
        /// </summary>
        /// <returns></returns>
        List <ColladaElement> GetChildElements()
        {
            List <ColladaElement> children = new List <ColladaElement>();

            // enumerate all of the elements fields
            foreach (var field in Fields)
            {
                // if the field type is not derived from ColladaElement of its value is null, continue
                if (!field.GetObjectType().IsSubclassOf(typeof(ColladaElement)) || (field.GetValue() == null))
                {
                    continue;
                }

                // if the actual values type is ColladaElement, add it to the list (it could be a list, which we can't add directly)
                if (field.GetValue().GetType().IsSubclassOf(typeof(ColladaElement)))
                {
                    children.Add(field.GetValue() as ColladaElement);
                }
                // if the value is a list add each elment individually
                else if (field.GetValue().GetType().GetInterface("IList") != null)
                {
                    // the list derives from IEnumerable so we can get a generic enumerator from it
                    IEnumerable element_list = field.GetValue() as IEnumerable;

                    if (element_list == null)
                    {
                        continue;
                    }

                    // get a generic enumerator, enumate through the list add add each entry assuming it is a ColladaElement
                    IEnumerator    enumerator = element_list.GetEnumerator();
                    ColladaElement element    = null;
                    while (enumerator.MoveNext() && (element = (enumerator.Current as ColladaElement)) != null)
                    {
                        children.Add(element);
                    }
                }
            }

            return(children);
        }