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

OnOperation.cs « SchemaObjectModel « EntityModel « 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: b1dbc31b21c44a750a89711e3c5cfc41ed867042 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//---------------------------------------------------------------------
// <copyright file="OnOperation.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner       Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------

namespace System.Data.EntityModel.SchemaObjectModel
{
    using System.Data.Metadata.Edm;
    using System.Data.Objects.DataClasses;
    using System.Diagnostics;
    using System.Xml;

    /// <summary>
    /// Represents an OnDelete, OnCopy, OnSecure, OnLock or OnSerialize element
    /// </summary>
    internal sealed class OnOperation : SchemaElement
    {
        private Operation _Operation;
        private Action _Action;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentElement"></param>
        /// <param name="operation"></param>
        public OnOperation(RelationshipEnd parentElement, Operation operation)
        : base(parentElement)
        {
            Operation = operation;
        }

        /// <summary>
        /// The operation
        /// </summary>
        public Operation Operation
        {
            get
            {
                return _Operation;
            }
            private set
            {
                _Operation = value;
            }
        }

        /// <summary>
        /// The action
        /// </summary>
        public Action Action
        {
            get
            {
                return _Action;
            }
            private set
            {
                _Action = value;
            }
        }

        protected override bool ProhibitAttribute(string namespaceUri, string localName)
        {
            if (base.ProhibitAttribute(namespaceUri, localName))
            {
                return true;
            }

            if (namespaceUri == null && localName == XmlConstants.Name)
            {
                return false;
            }
            return false;

        }

        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.Action))
            {
                HandleActionAttribute(reader);
                return true;
            }

            return false;
        }

        /// <summary>
        /// Handle the Action attribute
        /// </summary>
        /// <param name="reader">reader positioned at Action attribute</param>
        private void HandleActionAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);

            RelationshipKind relationshipKind = ParentElement.ParentElement.RelationshipKind;

            switch ( reader.Value.Trim() )
            {
                case "None":
                    Action = Action.None;
                    break;
                case "Cascade":
                    Action = Action.Cascade;
                    break;
                default:
                    AddError( ErrorCode.InvalidAction, EdmSchemaErrorSeverity.Error, reader, System.Data.Entity.Strings.InvalidAction(reader.Value, ParentElement.FQName ) );
                    break;
            }
        }

        /// <summary>
        /// the parent element.
            /// </summary>
        private new RelationshipEnd ParentElement
        {
            get
            {
                return (RelationshipEnd)base.ParentElement;
            }
        }
    }
}