Welcome to mirror list, hosted at ThFree Co, Russian Federation.

util.cs « Edm « Metadata « Data « System « System.Data.Entity « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ea3b7036a0c5cf77a3aa6e24bb9fd3c0e768808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//---------------------------------------------------------------------
// <copyright file="Util.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner       Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics;
using System.Text;

namespace System.Data.Metadata.Edm
{
    /// <summary>
    /// Class holding utility functions for metadata
    /// </summary>
    internal static class Util
    {
        #region Methods
        /// <summary>
        /// Throws an appropriate exception if the given item is a readonly, used when an attempt is made to change
        /// a property
        /// </summary>
        /// <param name="item">The item whose readonly is being tested</param>
        internal static void ThrowIfReadOnly(MetadataItem item)
        {
            Debug.Assert(item != null, "The given item is null");
            if (item.IsReadOnly)
            {
                throw EntityUtil.OperationOnReadOnlyItem();
            }
        }

        /// <summary>
        /// Check to make sure the given item do have identity
        /// </summary>
        /// <param name="item">The item to check for valid identity</param>
        /// <param name="argumentName">The name of the argument</param>
        [Conditional("DEBUG")]
        internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
        {
            Debug.Assert(!string.IsNullOrEmpty(item.Identity), "Item has empty identity.");
            EntityUtil.GenericCheckArgumentNull(item, argumentName);
        }
        #endregion
    }
}