Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Metadata / Edm / util.cs
1 //---------------------------------------------------------------------
2 // <copyright file="Util.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9
10 using System;
11 using System.Collections.Generic;
12 using System.Data.Common;
13 using System.Diagnostics;
14 using System.Text;
15
16 namespace System.Data.Metadata.Edm
17 {
18     /// <summary>
19     /// Class holding utility functions for metadata
20     /// </summary>
21     internal static class Util
22     {
23         #region Methods
24         /// <summary>
25         /// Throws an appropriate exception if the given item is a readonly, used when an attempt is made to change
26         /// a property
27         /// </summary>
28         /// <param name="item">The item whose readonly is being tested</param>
29         internal static void ThrowIfReadOnly(MetadataItem item)
30         {
31             Debug.Assert(item != null, "The given item is null");
32             if (item.IsReadOnly)
33             {
34                 throw EntityUtil.OperationOnReadOnlyItem();
35             }
36         }
37
38         /// <summary>
39         /// Check to make sure the given item do have identity
40         /// </summary>
41         /// <param name="item">The item to check for valid identity</param>
42         /// <param name="argumentName">The name of the argument</param>
43         [Conditional("DEBUG")]
44         internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
45         {
46             Debug.Assert(!string.IsNullOrEmpty(item.Identity), "Item has empty identity.");
47             EntityUtil.GenericCheckArgumentNull(item, argumentName);
48         }
49         #endregion
50     }
51 }