コード例 #1
0
 public static void ThrowIfNotFrozen(this IFreezable that, string name = null)
 {
     if ((object)that != null)
     {
         if (!(that.IsFrozen()))
         {
             if (name is null)
             {
                 throw new InvalidOperationException($"{that.GetType().FullName} is NOT frozen.");
             }
             else
             {
                 throw new InvalidOperationException($"{name} is NOT frozen.");
             }
         }
     }
 }
コード例 #2
0
 public static void SetOrThrowIfFrozen <T>(this IFreezable that, ref T target, T value, string name = null)
 {
     if ((object)that != null)
     {
         if (that.IsFrozen())
         {
             if (name is null)
             {
                 throw new InvalidOperationException($"{that.GetType().FullName} is frozen.");
             }
             else
             {
                 throw new InvalidOperationException($"{name} is frozen.");
             }
         }
     }
     target = value;
 }