Exemple #1
0
        /// <inheritdoc />
        public virtual bool TryAddContextObject(object key, object value, BlockProcessor blockProcessor)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (blockProcessor == null)
            {
                throw new ArgumentNullException(nameof(blockProcessor));
            }

            if (blockProcessor.Context != null)
            {
                blockProcessor.Context.Properties[key] = value;
                return(true);
            }

            ContextObjectsStore contextObjectsStore = TryGetContextObjectsStore(blockProcessor);

            if (contextObjectsStore != null)
            {
                contextObjectsStore[key] = value;
                return(true);
            }

            return(false);
        }
 /// <summary>
 /// Creates a <see cref="ContextObjectsExtension"/>.
 /// </summary>
 /// <param name="contextObjectsStore">The context objects store.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="contextObjectsStore"/> is <c>null</c>.</exception>
 public ContextObjectsExtension(ContextObjectsStore contextObjectsStore)
 {
     ContextObjectsStore = contextObjectsStore ?? throw new ArgumentNullException(nameof(contextObjectsStore));
 }