Beispiel #1
0
        /// <summary>
        /// Modifies and returns a copy of the modified Immutable.
        /// </summary>
        /// <typeparam name="TValue">The type of the value to set.</typeparam>
        /// <param name="assignment">An action that assigns a new value to the immutable.</param>
        /// <returns>A new modified Immutable instance.</returns>
        public Immutable <T> Modify(Action <T> assignment)
        {
            if (DelegateCache <T> .CloneDelegate == null)
            {
                DelegateCache <T> .CloneDelegate = DelegateBuilder.BuildCloner <T>();
            }

            var immutable = new Immutable <T>();

            immutable._self = DelegateCache <T> .CloneDelegate(immutable._self, _self);

            assignment(immutable._self);

            return(immutable);
        }
Beispiel #2
0
 /// <summary>
 /// Freezes a builder into an Immutable.
 /// </summary>
 /// <returns>A new Immutable with the enclosed instance.</returns>
 public Immutable <T> ToImmutable()
 {
     return(Immutable <T> .Create(_self));
 }