public ElementBuilder(ElementType type,
                              params IContent[] contents)
        {
            Type = type;

            Contents.AddRange(contents);
            ContentType = Contents.Aggregate(
                ContentTypeEnum.None,
                (typeAcc,
                 content) => typeAcc | content.ContentType
                );

            ShouldDisplay = true;
            Title         = null;

            LinkedConceptsInternal = new List <IConcept>();
            ComponentsInternal     = new List <IComponent>();
        }
Exemple #2
0
        public override int GetHashCode()
        {
            var hash = 17;

            hash = hash * 23 + TagName.GetHashCode();
            foreach (
                var attribute in
                this.Where(attribute => !string.Equals(attribute.Key, "style") && !string.Equals(attribute.Key, "class"))
                .OrderBy(attribute => attribute.Key))
            {
                hash = hash * 23 + attribute.Key.GetHashCode();
                hash = hash * 23 + attribute.Value.GetHashCode();
            }
            foreach (var style in Styles.OrderBy(style => style.Key))
            {
                hash = hash * 23 + style.Key.GetHashCode();
                hash = hash * 23 + style.Value.GetHashCode();
            }
            hash = Classes.OrderBy(c => c).Aggregate(hash, (current, @class) => current * 23 + @class.GetHashCode());
            return(Contents.Aggregate(hash, (current, content) => current * 23 + content.GetHashCode()));
        }
Exemple #3
0
        public ElementBuilder(ElementType type,
                              string layoutName = null,
                              params ContentBase[] contents)
        {
            Type = type;

            Layout = layoutName;

            if (contents != null)
            {
                Contents.AddRange(contents);
            }
            ContentType = Contents.Aggregate(
                ContentTypeFlag.None,
                (typeAcc,
                 content) => typeAcc | content.ContentType
                );

            Status        = ElementStatus.Memorized;
            ShouldDisplay = true;
            Title         = null;
        }
Exemple #4
0
 public override int GetHashCode()
 {
     return(Contents.Aggregate(Name?.GetHashCode() ?? 0, (current, content) => current ^ content.GetHashCode()));
 }