Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / EdmSchemaError.cs / 1305376 / EdmSchemaError.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Data;
using System.Data.Entity;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// This class encapsulates the error information for a schema error that was encountered.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
[Serializable]
public sealed class EdmSchemaError : EdmError
{
#region Instance Fields
private int _errorCode = 0;
private EdmSchemaErrorSeverity _severity = EdmSchemaErrorSeverity.Warning;
private string _schemaLocation = null;
private int _line = -1;
private int _column = -1;
private string _stackTrace = string.Empty;
#endregion
#region Public Methods
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity) :
this(message, errorCode, severity, null)
{
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
/// The exception that caused the error to be filed.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, Exception exception)
: base(message)
{
Initialize(errorCode, severity, null, -1, -1, exception);
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
///
///
///
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column)
: this(message, errorCode, severity, schemaLocation, line, column, null)
{
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
///
///
///
/// The exception that caused the error to be filed.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column, Exception exception)
: base(message)
{
if (severity < EdmSchemaErrorSeverity.Warning || severity > EdmSchemaErrorSeverity.Error)
{
throw new ArgumentOutOfRangeException("severity", severity, System.Data.Entity.Strings.ArgumentOutOfRange(severity));
}
if (line < 0)
{
throw new ArgumentOutOfRangeException("line", line, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(line));
}
if (column < 0)
{
throw new ArgumentOutOfRangeException("column", column, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(column));
}
Initialize(errorCode, severity, schemaLocation, line, column, exception);
}
private void Initialize(int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column, Exception exception)
{
if (errorCode < 0)
{
throw new ArgumentOutOfRangeException("errorCode", errorCode, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(errorCode));
}
_errorCode = errorCode;
_severity = severity;
_schemaLocation = schemaLocation;
_line = line;
_column = column;
if (exception != null)
{
_stackTrace = exception.StackTrace;
}
}
///
/// Creates a string representation of the error.
///
public override string ToString()
{
string text;
string severity;
switch (Severity)
{
case EdmSchemaErrorSeverity.Error:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityError;
break;
case EdmSchemaErrorSeverity.Warning:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityWarning;
break;
default:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityUnknown;
break;
}
if (String.IsNullOrEmpty(SchemaName) && Line < 0 && Column < 0)
{
text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} {1:0000}: {2}",
severity,
ErrorCode,
Message);
}
else
{
text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}({1},{2}) : {3} {4:0000}: {5}",
(SchemaName == null) ? System.Data.Entity.Strings.SourceUriUnknown : SchemaName,
Line,
Column,
severity,
ErrorCode,
Message);
}
return text;
}
#endregion
#region Public Properties
///
/// Gets the ErrorCode.
///
public int ErrorCode
{
get
{
return _errorCode;
}
}
///
/// Gets the Severity of the error.
///
public EdmSchemaErrorSeverity Severity
{
get
{
return _severity;
}
set
{
_severity = value;
}
}
///
/// Gets the LineNumber that the error occured on.
///
public int Line
{
get
{
return _line;
}
}
///
/// Gets the column that the error occured in.
///
public int Column
{
get
{
return _column;
}
}
///
/// Gets the of the schema that contains the error.
///
public string SchemaLocation
{
get
{
return _schemaLocation;
}
}
///
/// Gets the of the schema that contains the error.
///
public string SchemaName
{
get
{
return GetNameFromSchemaLocation(SchemaLocation);
}
}
///
/// Gets the stack trace of when the error occured.
///
///
public string StackTrace
{
get
{
return _stackTrace;
}
}
#endregion
private static string GetNameFromSchemaLocation(string schemaLocation)
{
if (string.IsNullOrEmpty(schemaLocation))
{
return schemaLocation;
}
int pos = Math.Max(schemaLocation.LastIndexOf('/'), schemaLocation.LastIndexOf('\\'));
int start = pos + 1;
if (pos < 0)
{
return schemaLocation;
}
else if (start >= schemaLocation.Length)
{
return string.Empty;
}
return schemaLocation.Substring(start);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Data;
using System.Data.Entity;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// This class encapsulates the error information for a schema error that was encountered.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
[Serializable]
public sealed class EdmSchemaError : EdmError
{
#region Instance Fields
private int _errorCode = 0;
private EdmSchemaErrorSeverity _severity = EdmSchemaErrorSeverity.Warning;
private string _schemaLocation = null;
private int _line = -1;
private int _column = -1;
private string _stackTrace = string.Empty;
#endregion
#region Public Methods
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity) :
this(message, errorCode, severity, null)
{
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
/// The exception that caused the error to be filed.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, Exception exception)
: base(message)
{
Initialize(errorCode, severity, null, -1, -1, exception);
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
///
///
///
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column)
: this(message, errorCode, severity, schemaLocation, line, column, null)
{
}
///
/// Constructs a EdmSchemaError object.
///
/// The explanation of the error.
/// The code associated with this error.
/// The severity of the error.
///
///
///
/// The exception that caused the error to be filed.
internal EdmSchemaError(string message, int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column, Exception exception)
: base(message)
{
if (severity < EdmSchemaErrorSeverity.Warning || severity > EdmSchemaErrorSeverity.Error)
{
throw new ArgumentOutOfRangeException("severity", severity, System.Data.Entity.Strings.ArgumentOutOfRange(severity));
}
if (line < 0)
{
throw new ArgumentOutOfRangeException("line", line, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(line));
}
if (column < 0)
{
throw new ArgumentOutOfRangeException("column", column, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(column));
}
Initialize(errorCode, severity, schemaLocation, line, column, exception);
}
private void Initialize(int errorCode, EdmSchemaErrorSeverity severity, string schemaLocation, int line, int column, Exception exception)
{
if (errorCode < 0)
{
throw new ArgumentOutOfRangeException("errorCode", errorCode, System.Data.Entity.Strings.ArgumentOutOfRangeExpectedPostiveNumber(errorCode));
}
_errorCode = errorCode;
_severity = severity;
_schemaLocation = schemaLocation;
_line = line;
_column = column;
if (exception != null)
{
_stackTrace = exception.StackTrace;
}
}
///
/// Creates a string representation of the error.
///
public override string ToString()
{
string text;
string severity;
switch (Severity)
{
case EdmSchemaErrorSeverity.Error:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityError;
break;
case EdmSchemaErrorSeverity.Warning:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityWarning;
break;
default:
severity = System.Data.Entity.Strings.GeneratorErrorSeverityUnknown;
break;
}
if (String.IsNullOrEmpty(SchemaName) && Line < 0 && Column < 0)
{
text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} {1:0000}: {2}",
severity,
ErrorCode,
Message);
}
else
{
text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}({1},{2}) : {3} {4:0000}: {5}",
(SchemaName == null) ? System.Data.Entity.Strings.SourceUriUnknown : SchemaName,
Line,
Column,
severity,
ErrorCode,
Message);
}
return text;
}
#endregion
#region Public Properties
///
/// Gets the ErrorCode.
///
public int ErrorCode
{
get
{
return _errorCode;
}
}
///
/// Gets the Severity of the error.
///
public EdmSchemaErrorSeverity Severity
{
get
{
return _severity;
}
set
{
_severity = value;
}
}
///
/// Gets the LineNumber that the error occured on.
///
public int Line
{
get
{
return _line;
}
}
///
/// Gets the column that the error occured in.
///
public int Column
{
get
{
return _column;
}
}
///
/// Gets the of the schema that contains the error.
///
public string SchemaLocation
{
get
{
return _schemaLocation;
}
}
///
/// Gets the of the schema that contains the error.
///
public string SchemaName
{
get
{
return GetNameFromSchemaLocation(SchemaLocation);
}
}
///
/// Gets the stack trace of when the error occured.
///
///
public string StackTrace
{
get
{
return _stackTrace;
}
}
#endregion
private static string GetNameFromSchemaLocation(string schemaLocation)
{
if (string.IsNullOrEmpty(schemaLocation))
{
return schemaLocation;
}
int pos = Math.Max(schemaLocation.LastIndexOf('/'), schemaLocation.LastIndexOf('\\'));
int start = pos + 1;
if (pos < 0)
{
return schemaLocation;
}
else if (start >= schemaLocation.Length)
{
return string.Empty;
}
return schemaLocation.Substring(start);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DiscardableAttribute.cs
- TemplateParser.cs
- FixedMaxHeap.cs
- RadialGradientBrush.cs
- UnmanagedMemoryStream.cs
- XmlElement.cs
- PropertyReference.cs
- AnnotationAdorner.cs
- WebBrowser.cs
- DecimalConstantAttribute.cs
- MetadataPropertyvalue.cs
- ToolStripRenderEventArgs.cs
- CroppedBitmap.cs
- AssemblyInfo.cs
- OpCellTreeNode.cs
- OleDbDataAdapter.cs
- ellipse.cs
- HierarchicalDataSourceControl.cs
- ExtendLockCommand.cs
- SAPICategories.cs
- TraceUtility.cs
- BamlTreeUpdater.cs
- WorkflowApplicationTerminatedException.cs
- XLinq.cs
- ModelUtilities.cs
- Hashtable.cs
- BinaryObjectWriter.cs
- SafeNativeMethods.cs
- GenericPrincipal.cs
- DocumentViewerBaseAutomationPeer.cs
- COM2ColorConverter.cs
- DesignBindingPicker.cs
- SrgsElementList.cs
- VerificationAttribute.cs
- DynamicResourceExtensionConverter.cs
- CodeTypeReference.cs
- ExternalDataExchangeClient.cs
- ProtectedConfigurationProviderCollection.cs
- DataTableMappingCollection.cs
- ServicePoint.cs
- TypeHelper.cs
- ToolboxDataAttribute.cs
- XmlReflectionImporter.cs
- StylusDownEventArgs.cs
- FixedHyperLink.cs
- SimpleType.cs
- PolicyValidationException.cs
- WebPartConnectionsConnectVerb.cs
- ETagAttribute.cs
- SqlDataSourceSelectingEventArgs.cs
- SecurityVerifiedMessage.cs
- HTMLTagNameToTypeMapper.cs
- FontFamily.cs
- DrawingCollection.cs
- Slider.cs
- CqlQuery.cs
- HitTestWithGeometryDrawingContextWalker.cs
- DataListItemCollection.cs
- XsdDuration.cs
- ReflectionUtil.cs
- RoutedEventValueSerializer.cs
- Transform.cs
- Assembly.cs
- CalendarDataBindingHandler.cs
- AnnotationComponentChooser.cs
- DbQueryCommandTree.cs
- StrokeNodeData.cs
- TimelineGroup.cs
- SurrogateSelector.cs
- HttpCacheVaryByContentEncodings.cs
- InternalPermissions.cs
- DistributedTransactionPermission.cs
- CustomLineCap.cs
- ConnectionsZoneAutoFormat.cs
- SafeNativeMethods.cs
- PerformanceCounterPermissionAttribute.cs
- ActivityDesigner.cs
- RuleSettings.cs
- ClientCredentialsSecurityTokenManager.cs
- TargetException.cs
- RequestTimeoutManager.cs
- RawStylusSystemGestureInputReport.cs
- UrlPath.cs
- GeneralTransform3D.cs
- UnauthorizedWebPart.cs
- SqlVisitor.cs
- OperationContractGenerationContext.cs
- DataBoundControlHelper.cs
- DataRecord.cs
- ActivityDesignerAccessibleObject.cs
- WorkflowTraceTransfer.cs
- CodePageUtils.cs
- ClientApiGenerator.cs
- WindowsTab.cs
- CreateUserWizardDesigner.cs
- ToolStripPanel.cs
- DataFormat.cs
- DiagnosticsConfigurationHandler.cs
- DrawTreeNodeEventArgs.cs
- CodeDOMProvider.cs