1 //---------------------------------------------------------------------
2 // <copyright file="ViewgenResults.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //---------------------------------------------------------------------
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;
17 namespace System.Data.Mapping.ViewGeneration
20 // This class is responsible for keeping track of the results from view
21 // generation - errors and correct views
22 internal class ViewGenResults : InternalBase
26 internal ViewGenResults()
28 m_views = new KeyToListMap<EntitySetBase, GeneratedView>(EqualityComparer<EntitySetBase>.Default);
29 m_errorLog = new ErrorLog();
34 private KeyToListMap<EntitySetBase, GeneratedView> m_views;
35 private ErrorLog m_errorLog;
39 // effects: Returns the generated views
40 internal KeyToListMap<EntitySetBase, GeneratedView> Views
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
55 return m_errorLog.Errors;
59 // effects: Returns true iff any error was generated
60 internal bool HasErrors
64 return m_errorLog.Count > 0;
70 // effects: Add the set of errors in errorLog to this
71 internal void AddErrors(ErrorLog errorLog)
73 m_errorLog.Merge(errorLog);
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()
80 return m_errorLog.ToString();
83 internal override void ToCompactString(StringBuilder builder)
86 builder.Append(m_errorLog.Count);
88 // Print the errors only
89 m_errorLog.ToCompactString(builder);