/// <summary>
 /// Creates a new style value expression for the style key with the expression and an optional convertor and base value
 /// </summary>
 /// <param name="key">The style key this expression is assigned for</param>
 /// <param name="expressionString">The exppresion to be evaluated at runtime</param>
 /// <param name="convertor">An otpional convertor to make the result the required type</param>
 /// <param name="baseValue">An optional base value that will be returned before the expression is bound</param>
 public StyleValueExpression(PDFStyleKey <T> key, string expressionString, StyleValueConvertor <T> convertor, T baseValue)
     : base(key, baseValue)
 {
     this._expressionString = expressionString ?? throw new ArgumentNullException(nameof(expressionString));
     this._convertor        = convertor;
     this._variableProvider = null;
     this._expression       = null;
 }
Beispiel #2
0
 /// <summary>
 /// Creates a new Border style
 /// </summary>
 public BorderSideStyle(Sides forSide, StyleKey forKey, PDFStyleKey <PDFColor> colorKey, PDFStyleKey <PDFUnit> widthkey, PDFStyleKey <LineType> lineStyleKey, PDFStyleKey <PDFDash> dashkey) :
     base(forKey)
 {
     _side  = forSide;
     _color = colorKey;
     _width = widthkey;
     _line  = lineStyleKey;
     _dash  = dashkey;
 }
        /// <summary>
        /// Sets a value of a known type for this style item, based on the specified key.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="itembase"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void SetValue <T>(this StyleItemBase itembase, PDFStyleKey <T> key, T value)
        {
            StyleValue <T> found;

            if (itembase.AssertOwner().TryGetValue(key, out found))
            {
                found.SetValue(value);
            }
            else
            {
                found = new StyleValue <T>(key, value);
                itembase.AddBaseValue(found);
            }
        }
        /// <summary>
        /// Attempts to retrieve a value of the known type from this StyleItem
        /// </summary>
        /// <typeparam name="T">The type of value to retrieve</typeparam>
        /// <param name="itembase">This style item</param>
        /// <param name="key">The style key of the value to retrieve</param>
        /// <param name="found">Set to the value of any found item, or default value.</param>
        /// <returns>True if the item has a reference to the value required, otherwise false.</returns>
        public static bool TryGetValue <T>(this StyleItemBase itembase, PDFStyleKey <T> key, out T found)
        {
            StyleValue <T> exist;

            if (itembase.AssertOwner().TryGetValue(key, out exist))
            {
                found = exist.Value;
                return(true);
            }
            else
            {
                found = default(T);
                return(false);
            }
        }
Beispiel #5
0
 public StyleValue(PDFStyleKey <T> key, T value)
     : base(key)
 {
     this._value = value;
 }
        //
        // .ctor
        //

        #region public StyleValueExpression(PDFStyleKey<T> key, string expressionString, StyleValueConvertor<T> convertor)

        /// <summary>
        /// Creates a new style value expression for the style key with the expression and an optional convertor
        /// </summary>
        /// <param name="key">The style key this expression is assigned for</param>
        /// <param name="expressionString">The exppresion to be evaluated at runtime</param>
        /// <param name="convertor">An otpional convertor to make the result the required type</param>
        public StyleValueExpression(PDFStyleKey <T> key, string expressionString, StyleValueConvertor <T> convertor)
            : this(key, expressionString, convertor, default)
        {
        }