Example #1
0
 /// <summary>
 /// Gets the Options containing the Feature specified name.
 /// </summary>
 /// <param name="name">The name of the Feature.</param>
 /// <returns>The Options contained by the Feature specified name.</returns>
 public IReadOnlyList <Option> Get(FeatureName name)
 {
     if (name == null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(_features.Get(name)?.Options());
 }
Example #2
0
 internal Feature(
     FeatureName name,
     ImmutableNamedElementCollection <Property> properties,
     ImmutableList <Option> options,
     ImmutableNamedElementCollection <Feature> nestedFeature)
 {
     Name        = name;
     _properties = properties;
     _options    = options;
     _features   = nestedFeature;
 }
Example #3
0
        /// <summary>
        /// Updates the all <see cref="Option"/> contained by nested <see
        /// cref="Feature"/> via the delegate.
        /// </summary>
        /// <param name="name">The name of the nested <see cref="Feature"/>.</param>
        /// <param name="func">Updater for options.</param>
        /// <returns>The new instance with updated Options.</returns>
        public Feature Update(FeatureName name, Func <Option, Option> func)
        {
            var ft = _features.Get(name)?.Update(func);

            if (ft == null)
            {
                return(this);
            }

            return(new Feature(Name, _properties, _options, _features.SetItem(ft)));
        }
Example #4
0
        /// <summary>
        /// Get a value of the Property of the nested Feature.
        /// </summary>
        /// <param name="name1">The name of nested.Feature containing Property.</param>
        /// <param name="name2">The name of Property of nested Feature.</param>
        /// <returns>The value of property.</returns>
        public Value Get(FeatureName name1, PropertyName name2)
        {
            if (name1 == null)
            {
                throw new ArgumentNullException(nameof(name1));
            }
            if (name2 == null)
            {
                throw new ArgumentNullException(nameof(name2));
            }

            return(_features.Get(name1)?.Get(name2));
        }
Example #5
0
        /// <summary>
        /// Sets the value to the Property of the Feature specified name.
        /// </summary>
        /// <param name="name1">The name of Feature.</param>
        /// <param name="name2">The name of Property.</param>
        /// <param name="value">The value to set.</param>
        /// <returns>The new instance containing new value.</returns>
        public Capabilities Set(FeatureName name1, PropertyName name2, Value value)
        {
            if (name1 == null)
            {
                throw new ArgumentNullException(nameof(name1));
            }
            if (name2 == null)
            {
                throw new ArgumentNullException(nameof(name2));
            }

            var ft = _features.Get(name1)?.Set(name2, value) ?? new Feature(name1, new Property(name2, value));

            return(new Capabilities(_features.SetItem(ft), _parameters, _properties, _declaredNamespaces));
        }
Example #6
0
        /// <summary>
        /// Set a value to the Property of the nested Feature.
        /// </summary>
        /// <param name="name1">The name of nested Feature.</param>
        /// <param name="name2">The name of Property.</param>
        /// <param name="value">The value to set.</param>
        /// <returns>The new instance with updated value.</returns>
        public Feature Set(FeatureName name1, PropertyName name2, Value value)
        {
            if (name1 == null)
            {
                throw new ArgumentNullException(nameof(name1));
            }
            if (name2 == null)
            {
                throw new ArgumentNullException(nameof(name2));
            }

            var ft = _features.Get(name1)?.Set(name2, value)
                     ?? new Feature(name1, new Property(name2, value));

            return(new Feature(Name, _properties, _options, _features.SetItem(ft)));
        }
Example #7
0
        /// <summary>
        /// Update Options contained by the Feature specified name via specified delegate.
        /// </summary>
        /// <param name="name">The name of the Feature.</param>
        /// <param name="func">Option updating delegate.</param>
        /// <returns>The new instance containing updated options</returns>
        public Capabilities Update(FeatureName name, Func <Option, Option> func)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var ft = _features.Get(name);

            if (ft == null)
            {
                return(this);
            }

            return(new Capabilities(_features.SetItem(ft.Update(func)), _parameters, _properties, _declaredNamespaces));
        }
Example #8
0
        /// <summary>
        /// Sets the <see cref="Option"/> to the nested <see cref="Feature"/>
        /// specified name.
        /// </summary>
        /// <param name="name">The name of the nested <see cref="Feature"/>.</param>
        /// <param name="selection">The <see cref="Option"/> to set.</param>
        /// <returns>The new instance contains new <see cref="Option"/>.</returns>
        public Feature Set(FeatureName name, Option selection)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (selection == null)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            var ft = _features.Contains(name)
                ? _features[name].Set(selection)
                : new Feature(name, selection);

            return(new Feature(Name, _properties, _options, _features.SetItem(ft)));
        }
Example #9
0
        /// <summary>
        /// Set an option to the Feature specified by name.
        /// </summary>
        /// <param name="name">The name of Feature to set.</param>
        /// <param name="selection">An option to set to the Feature.</param>
        /// <returns>A new Ticket with the option set.</returns>
        public Ticket Set(FeatureName name, Option selection)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (selection == null)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            var sel = ToPrintTicketOption(selection);
            var ft  = _features.Contains(name)
                ? _features[name].Set(sel)
                : new Feature(name, sel);

            return(new Ticket(_features.SetItem(ft), _parameters, _properties, _declaredNamespaces));
        }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feature"/> class.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        /// <param name="elements">The options of the element.</param>
        public Feature(FeatureName name, params FeatureChild[] elements)
        {
            Name = name;
            var o          = new Option();
            var properties = ImmutableNamedElementCollection.CreatePropertyCollectionBuilder();
            var options    = ImmutableList.CreateBuilder <Option>();
            var features   = ImmutableNamedElementCollection.CreateFeatureCollectionBuilder();

            foreach (var e in elements)
            {
                e.Apply(
                    onProperty: x => properties.Add(x),
                    onOption: x => options.Add(x),
                    onFeature: x => features.Add(x));
            }

            _properties = properties.ToImmutable();
            _options    = options.ToImmutable();
            _features   = features.ToImmutable();
        }
Example #11
0
 /// <summary>
 /// Gets the nested <see cref="Feature"/>.
 /// </summary>
 /// <param name="name">The name of the nested <see cref="Feature"/>.</param>
 /// <returns>The Feature specified name.</returns>
 public Feature Get(FeatureName name)
 {
     return(_features.Get(name));
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Feature"/> class.
 /// </summary>
 /// <param name="name">The name of the element.</param>
 public Feature(FeatureName name)
 {
     Name = name;
 }
Example #13
0
 public PrintSchemaFeature(FeatureName name)
 {
     _name = name;
 }
Example #14
0
 /// <summary>
 /// Gets the nested Feature specified name.
 /// </summary>
 /// <param name="name1">The name of parent Feature.</param>
 /// <param name="name2">The name of nested Feature.</param>
 /// <returns>The nested Feature specified name.</returns>
 public Feature Get(FeatureName name1, FeatureName name2)
 {
     return(_features.Get(name1)?.Features?.Get(name2));
 }