Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Objects / DataClasses / RelationshipFixer.cs
1 //---------------------------------------------------------------------
2 // <copyright file="RelationshipFixer.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System.Data.Metadata.Edm;
10
11 namespace System.Data.Objects.DataClasses
12 {
13     [Serializable]
14     internal class RelationshipFixer<TSourceEntity, TTargetEntity> : IRelationshipFixer
15         where TSourceEntity : class
16         where TTargetEntity : class
17     {
18         // The following fields are serialized.  Adding or removing a serialized field is considered
19         // a breaking change.  This includes changing the field type or field name of existing
20         // serialized fields. If you need to make this kind of change, it may be possible, but it
21         // will require some custom serialization/deserialization code.
22         RelationshipMultiplicity _sourceRoleMultiplicity;
23         RelationshipMultiplicity _targetRoleMultiplicity;
24
25         internal RelationshipFixer(RelationshipMultiplicity sourceRoleMultiplicity, RelationshipMultiplicity targetRoleMultiplicity)
26         {
27             _sourceRoleMultiplicity = sourceRoleMultiplicity;
28             _targetRoleMultiplicity = targetRoleMultiplicity;
29         }
30
31         /// <summary>
32         /// Used during relationship fixup when the source end of the relationship is not
33         /// yet in the relationships list, and needs to be created
34         /// </summary>
35         /// <param name="navigation">RelationshipNavigation to be set on new RelatedEnd</param>
36         /// <param name="relationshipManager">RelationshipManager to use for creating the new end</param>
37         /// <returns>Reference to the new collection or reference on the other end of the relationship</returns>
38         RelatedEnd IRelationshipFixer.CreateSourceEnd(RelationshipNavigation navigation, RelationshipManager relationshipManager)
39         {            
40             return relationshipManager.CreateRelatedEnd<TTargetEntity, TSourceEntity>(navigation, _targetRoleMultiplicity, _sourceRoleMultiplicity, /*existingRelatedEnd*/ null);
41         }        
42     }
43
44 }