Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScoredProperty"/> class.
        /// </summary>
        /// <param name="name">Name of ScoredProperty element.</param>
        /// <param name="elements">Child Property and/or ScoredProperty.</param>
        public ScoredProperty(ScoredPropertyName name, params ScoredPropertyChild[] elements)
        {
            Name = name;

            var scoredProperties = ImmutableNamedElementCollection.CreateScoredPropertyCollectionBuilder();
            var properties       = ImmutableNamedElementCollection.CreatePropertyCollectionBuilder();

            foreach (var e in elements)
            {
                e.Apply(
                    onScoredProperty: x => scoredProperties.Add(x),
                    onProperty: x => properties.Add(x));
            }

            _scoredProperties = scoredProperties.ToImmutable();
            _properties       = properties.ToImmutable();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Option"/> class.
        /// </summary>
        /// <param name="name">Name of the Option.</param>
        /// <param name="constrained">Constraint value.</param>
        /// <param name="elements">Children of the Option.</param>
        public Option(XName name, XName constrained, params OptionChild[] elements)
        {
            Name        = name;
            Constrained = constrained;

            var properties       = ImmutableNamedElementCollection.CreatePropertyCollectionBuilder();
            var scoredProperties = ImmutableNamedElementCollection.CreateScoredPropertyCollectionBuilder();

            foreach (var e in elements)
            {
                e.Apply(
                    onProperty: x => properties.Add(x),
                    onScoredProperty: x => scoredProperties.Add(x));
            }

            _properties       = properties.ToImmutable();
            _scoredProperties = scoredProperties.ToImmutable();
        }