Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity.Design / System / Data / Entity / Design / PluralizationService / EntityDesignPluralizationHandler.cs
1 //---------------------------------------------------------------------
2 // <copyright file="EntityDesignPluralizationHandler.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System;
10 using System.Collections.Generic;
11 using System.Text;
12 using System.Globalization;
13 using System.Data.Entity.Design.PluralizationServices;
14 using System.Data.Metadata.Edm;
15 using System.IO;
16 using System.Data.Entity.Design.SsdlGenerator;
17 using System.Data.Entity.Design.Common;
18 using System.Diagnostics;
19
20 namespace System.Data.Entity.Design
21 {
22     internal class EntityDesignPluralizationHandler
23     {
24         /// <summary>
25         /// user might set the service to null, so we have to check the null when using this property
26         /// </summary>
27         internal PluralizationService Service
28         {
29             get;
30             set;
31         }
32
33         /// <summary>
34         /// Handler for pluralization service in Entity Design
35         /// </summary>
36         /// <param name="doPluralization">overall switch for the service, the service only start working when the value is true</param>
37         /// <param name="userDictionaryPath"></param>
38         /// <param name="errors"></param>
39         internal EntityDesignPluralizationHandler(PluralizationService service)
40         {
41             this.Service = service;
42         }
43
44         internal string GetEntityTypeName(string storeTableName)
45         {
46             return this.Service != null ? this.Service.Singularize(storeTableName) : storeTableName;
47         }
48
49         internal string GetEntitySetName(string storeTableName)
50         {
51             return this.Service != null ? this.Service.Pluralize(storeTableName) : storeTableName;
52         }
53
54         internal string GetNavigationPropertyName(AssociationEndMember toEnd, string storeTableName)
55         {
56             if (this.Service != null)
57             {
58                 return toEnd.RelationshipMultiplicity == RelationshipMultiplicity.Many ?
59                     this.Service.Pluralize(storeTableName) : this.Service.Singularize(storeTableName);
60             }
61             else
62             {
63                 return storeTableName;
64             }
65         }
66     }
67 }