Example #1
0
        /// <summary>
        /// Add all children (recusive)
        /// </summary>
        /// <param name="parent"></param>
        protected MXFLogicalObject LogicalAddChilds(MXFLogicalObject parent)
        {
            // Check properties for reference
            MXFObject reference = parent.Object;

            if (reference != null)
            {
                foreach (PropertyInfo propertyInfo in reference.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        if (propertyInfo.PropertyType == typeof(MXFRefKey))
                        {
                            // Found one!
                            MXFRefKey refKey = (MXFRefKey)propertyInfo.GetValue(reference, null);
                            if (refKey != null && refKey.Reference != null)
                            {
                                // Add the child
                                MXFLogicalObject lo = new MXFLogicalObject(refKey.Reference, refKey.Reference.ToString());
                                parent.AddChild(lo);

                                // Add all sub stuff
                                LogicalAddChilds(lo);
                            }
                        }
                    }
                }

                if (reference.HasChildren)
                {
                    foreach (MXFObject child in reference.Children)
                    {
                        if (child.HasChildren)
                        {
                            foreach (MXFObject grandchild in child.Children)
                            {
                                MXFRefKey refKey = grandchild as MXFRefKey;
                                if (refKey != null && refKey.Reference != null)
                                {
                                    MXFLogicalObject lo = new MXFLogicalObject(refKey.Reference, refKey.Reference.ToString());

                                    // Add the child
                                    parent.AddChild(lo);

                                    // Add all sub stuff
                                    LogicalAddChilds(lo);
                                }
                            }
                        }
                    }
                }
            }
            return(parent);
        }
Example #2
0
        /// <summary>
        /// Add all children (recursively)
        /// </summary>
        /// <param name="lObj"></param>
        protected MXFLogicalObject LogicalAddChilds(MXFLogicalObject lObj)
        {
            // Check properties for reference
            MXFObject obj = lObj.Object;

            if (obj != null)
            {
                var desc = obj.Descendants().OfType <IResolvable>();

                foreach (var r in desc)
                {
                    // create and add the logical child
                    var refObj = r.GetReference();
                    if (refObj != null)
                    {
                        MXFLogicalObject newLObj = refObj.CreateLogicalObject();
                        lObj.AddChild(newLObj);

                        if (refObj.Children.Any())
                        {
                            LogicalAddChilds(newLObj);
                        }
                    }
                }
            }
            return(lObj);
        }