Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Mapping / ViewGeneration / ViewGenResults.cs
1 //---------------------------------------------------------------------
2 // <copyright file="ViewgenResults.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner [....]
7 // @backupOwner [....]
8 //---------------------------------------------------------------------
9
10 using System.Data.Common.Utils;
11 using System.Data.Metadata.Edm;
12 using System.Data.Mapping.ViewGeneration.Structures;
13 using System.Data.EntityModel;
14 using System.Collections.Generic;
15 using System.Text;
16
17 namespace System.Data.Mapping.ViewGeneration
18 {
19
20     // This class is responsible for keeping track of the results from view
21     // generation - errors and correct views
22     internal class ViewGenResults : InternalBase
23     {
24
25         #region Constructor
26         internal ViewGenResults()
27         {
28             m_views = new KeyToListMap<EntitySetBase, GeneratedView>(EqualityComparer<EntitySetBase>.Default);
29             m_errorLog = new ErrorLog();
30         }
31         #endregion
32
33         #region Fields
34         private KeyToListMap<EntitySetBase, GeneratedView> m_views;
35         private ErrorLog m_errorLog;
36         #endregion
37
38         #region Properties
39         // effects: Returns the generated views
40         internal KeyToListMap<EntitySetBase, GeneratedView> Views
41         {
42             get
43             {
44                 return m_views;
45             }
46         }
47
48         // effects: Returns the errors that were generated. If no errors,
49         // returns an empty list
50         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] // referenced (indirectly) by System.Data.Entity.Design.dll
51         internal IEnumerable<EdmSchemaError> Errors
52         {
53             get
54             {
55                 return m_errorLog.Errors;
56             }
57         }
58
59         // effects: Returns true iff any error was generated
60         internal bool HasErrors
61         {
62             get
63             {
64                 return m_errorLog.Count > 0;
65             }
66         }
67         #endregion
68
69         #region Methods
70         // effects: Add the set of errors in errorLog to this
71         internal void AddErrors(ErrorLog errorLog)
72         {
73             m_errorLog.Merge(errorLog);
74         }
75
76         // effects: Returns all the errors as a string (not to be used for
77         // end user strings, i.e., in exceptions etc)
78         internal string ErrorsToString()
79         {
80             return m_errorLog.ToString();
81         }
82
83         internal override void ToCompactString(StringBuilder builder)
84         {
85             // Number of views
86             builder.Append(m_errorLog.Count);
87             builder.Append(" ");
88             // Print the errors only
89             m_errorLog.ToCompactString(builder);
90         }
91         #endregion
92     }
93 }