Beispiel #1
0
        public ElementContext(ElementContext parent, SceneElement element, OutputAttribute outputAttribute = null)
        {
            this.Parent = parent;
            this.Scene  = element as Scene ?? this.Parent.Scene;
            if (this.Parent != null)
            {
            }

            this.OutputAttribute = outputAttribute ?? OutputAttribute.Default();

            int order = this.OutputAttribute.Order;

            if (order != int.MinValue && order != int.MaxValue)
            {
                // Order elements with deeper inheritance first.
                order = this.OutputAttribute.Order = 10000 + order - this.OutputAttribute.Depth * 1000;
            }

            this.order = order;

            this.Element = element;
            this.Active  = this.Element.HasValue && !this.OutputAttribute.Ignore;

            if (this.Active)
            {
                if (this.Element is IRenderNotify renderNotify)
                {
                    renderNotify.RenderNotify(this);
                }

                if (this.Element is IIdentifiable identifiable)
                {
                    if (identifiable.IdentifierLibrary != null && identifiable.Identifier != null)
                    {
                        this.Scene.Include.Add(identifiable.IdentifierLibrary.Filename);
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>Determines if this element is equal to another - that is, they are the same object.</summary>
 /// <param name="other">The other element.</param>
 /// <returns>true if they're the same object.</returns>
 private bool Equals(SceneElement other)
 {
     return(string.Equals(this.Id, other.Id));
 }
Beispiel #3
0
        /// <summary>Gets the child elements of this element.</summary>
        /// <param name="parent">The parent element's context.</param>
        /// <returns>Enumeration of elements.</returns>
        public virtual IEnumerable <ElementContext> GetElements(ElementContext parent)
        {
            IEnumerable <(object, OutputAttribute)> values =
                this.GetValues(parent)
                .Concat(this.GetAdditionalValues());

            if (parent.OutputAttribute.AdditionalItems != null)
            {
                values = values.Concat(parent.OutputAttribute.AdditionalItems);
            }

            Keyword[] excludeKeywords = parent.OutputAttribute.ExcludeKeywords;
            if (excludeKeywords == null && parent.Parent?.Element is SceneItemWrapper <SceneItem> )
            {
                excludeKeywords = parent.Parent.OutputAttribute.ExcludeKeywords;
            }

            foreach ((object valueOrig, OutputAttribute output) in values)
            {
                object value = valueOrig;
                if (value == null || value is IValue v && !v.HasValue)
                {
                    continue;
                }

                if (output != null)
                {
                    if (output.Wrapper && value is SceneItem item)
                    {
                        value = new SceneItemWrapper <SceneItem>(item);
                    }
                }

                OutputAttribute outputAttribute =
                    OutputAttribute.Combine(value.GetType().GetAllAttributes <OutputAttribute>());

                if (output != null)
                {
                    outputAttribute.Combine(output);
                }

                if (outputAttribute.Ignore)
                {
                    continue;
                }

                if (outputAttribute.PovVersion > parent.Scene.PovVersion)
                {
                    continue;
                }

                if (excludeKeywords != null)
                {
                    if (excludeKeywords.Contains(outputAttribute.Keyword))
                    {
                        continue;
                    }
                }


                SceneElement   element = value as SceneElement ?? SceneElement.CreateElement(value, outputAttribute);
                ElementContext context = new ElementContext(parent, element, outputAttribute);
                yield return(context);
            }
        }