1 //---------------------------------------------------------------------
2 // <copyright file="OnOperation.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
10 namespace System.Data.EntityModel.SchemaObjectModel
12 using System.Data.Metadata.Edm;
13 using System.Data.Objects.DataClasses;
14 using System.Diagnostics;
18 /// Represents an OnDelete, OnCopy, OnSecure, OnLock or OnSerialize element
20 internal sealed class OnOperation : SchemaElement
22 private Operation _Operation;
23 private Action _Action;
27 /// <param name="parentElement"></param>
28 /// <param name="operation"></param>
29 public OnOperation(RelationshipEnd parentElement, Operation operation)
32 Operation = operation;
38 public Operation Operation
65 protected override bool ProhibitAttribute(string namespaceUri, string localName)
67 if (base.ProhibitAttribute(namespaceUri, localName))
72 if (namespaceUri == null && localName == XmlConstants.Name)
80 protected override bool HandleAttribute(XmlReader reader)
82 if (base.HandleAttribute(reader))
86 else if (CanHandleAttribute(reader, XmlConstants.Action))
88 HandleActionAttribute(reader);
96 /// Handle the Action attribute
98 /// <param name="reader">reader positioned at Action attribute</param>
99 private void HandleActionAttribute(XmlReader reader)
101 Debug.Assert(reader != null);
103 RelationshipKind relationshipKind = ParentElement.ParentElement.RelationshipKind;
105 switch ( reader.Value.Trim() )
108 Action = Action.None;
111 Action = Action.Cascade;
114 AddError( ErrorCode.InvalidAction, EdmSchemaErrorSeverity.Error, reader, System.Data.Entity.Strings.InvalidAction(reader.Value, ParentElement.FQName ) );
120 /// the parent element.
122 private new RelationshipEnd ParentElement
126 return (RelationshipEnd)base.ParentElement;