Example #1
0
 /// <summary>
 /// Adds the transformations in the given set to the current set.
 /// </summary>
 /// <param name="transformSet">The transforms to add.</param>
 internal void AddRange(TransformationPerTypeMap transformSet)
 {
     foreach (var pair in transformSet.transforms)
     {
         var withSameType = this.GetForType(pair.Key);
         withSameType.AddRange(pair.Value);
     }
 }
Example #2
0
        /// <summary>
        /// Gets a scope that can be used to modify what transforms are returned by the factory in a way that does not corrupt the factory itself.
        /// </summary>
        /// <param name="empty">A value indicating whether the scope should start out empty. If false, the current set of default transformations will be used.</param>
        /// <returns>A scope which can be used to fluently add/remove transforms without modifying the factory's long-term state.</returns>
        public IPayloadTransformationScope GetScope(bool empty)
        {
            var initialSet = new TransformationPerTypeMap();

            if (!empty)
            {
                initialSet.AddRange(this.GetCurrentTransforms());
            }

            return(new TransformationScope(initialSet, this.ApplyScope));
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the TransformationScope class.
 /// </summary>
 /// <param name="initialTransforms">The initial set of transforms.</param>
 /// <param name="onApply">The function to run on applying the scope.</param>
 internal TransformationScope(TransformationPerTypeMap initialTransforms, Func <TransformationScope, IDisposable> onApply)
 {
     this.Transforms = new TransformationPerTypeMap();
     this.Transforms.AddRange(initialTransforms);
     this.onApply = onApply;
 }