Esempio n. 1
0
        /// <summary>
        /// Returns a list of all properties in the class.  Note that it will create
        /// a DOGenerator class for each DataObject entity that it finds as a property and
        /// will call that class to get it's entities.
        /// </summary>
        /// <param name="namePrefix">Prefix to add to the name representing parent entities.</param>
        /// <param name="entities">List of all entities in system.  Used to determine if property is a DataObject entity type</param>
        /// <param name="parentEntities">Stack of all parent entities.  Used to avoid loops.</param>
        /// <returns></returns>
        public static ArrayList GetPropertyNames(ConfigurationElement options, IList entities, EntityElement entity, String prefix, System.Collections.Stack parentEntities)
        {
            ArrayList propertyNames = new ArrayList();

            // avoid loops
            bool matchedParent = false;

            foreach (EntityElement searchEntity in parentEntities)
            {
                if (ReferenceEquals(searchEntity, entity))
                {
                    matchedParent = true;
                    break;
                }
            }

            // Add current entity to parent stack
            parentEntities.Push(entity);

            if (!matchedParent)
            {
                foreach (PropertyElement property in entity.Properties)
                {
                    if (property.Name.IndexOf(".") < 0)
                    {
                        PropertyName propertyName = new PropertyName(prefix, property.Name);
                        propertyNames.Add(propertyName);

                        // Determine if this is a data object and if so append it's members.
                        foreach (EntityElement subEntity in entities)
                        {
                            if (property.Type != null && property.Type.Name.Equals(options.GetDOClassName(subEntity.Name)) || ReferenceEquals(subEntity, property.EntityType))
                            {
                                ArrayList subProperties = GetPropertyNames(options, entities, subEntity, PropertyName.AppendPrefix(prefix, property.Name), parentEntities);
                                foreach (PropertyName subProperty in subProperties)
                                {
                                    propertyNames.Add(subProperty);
                                }
                                break;
                            }
                        } // end of loop through entities
                    }     // end of if on indexOf(".")
                }         // end of loop through fields.
            }             // end of matched parent check

            parentEntities.Pop();
            return(propertyNames);
        } // end of GetPropertyNames