Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / XamlBuildTask / Microsoft / Build / Tasks / Xaml / ClassValidator.cs / 1305376 / ClassValidator.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace Microsoft.Build.Tasks.Xaml
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Xaml;
using System.Runtime;
using System.Reflection;
using System;
using System.Xaml.Schema;
class ClassValidator
{
string xamlFileName;
IExceptionLogger buildLogger;
IList eventArgs;
Assembly localAssembly;
string rootNamespace;
public ClassValidator(IExceptionLogger buildLogger, string xamlFileName, Assembly localAssembly, string rootNamespace)
{
this.buildLogger = buildLogger;
this.xamlFileName = xamlFileName;
this.localAssembly = localAssembly;
this.eventArgs = null;
this.rootNamespace = rootNamespace;
}
public bool ValidateXaml(XamlReader xamlReader, bool failOnFirstError, string assemblyName, out IList validationErrors)
{
if (xamlReader == null)
{
throw FxTrace.Exception.ArgumentNull("xamlReader");
}
validationErrors = null;
// We loop through the provided XAML using a XamlValidatingReader to ensure that:
// 1. XAML is valid.
// 2. All types referenced in XAML are validate-able. At this point, any types defined in the local
// assembly should be referenced, so this should be possible.
XamlValidatingReader reader = new XamlValidatingReader(xamlReader, this.localAssembly, rootNamespace, assemblyName);
reader.OnValidationError += new EventHandler(reader_OnValidationError);
while (reader.Read())
{
if (this.eventArgs != null && failOnFirstError)
{
validationErrors = this.eventArgs;
return false;
}
}
validationErrors = this.eventArgs;
if (validationErrors != null && validationErrors.Count > 0)
{
return false;
}
return true;
}
void reader_OnValidationError(object sender, ValidationEventArgs e)
{
if (this.eventArgs == null)
{
this.eventArgs = new List();
}
this.eventArgs.Add(new LogData()
{
FileName = this.xamlFileName,
LineNumber = e.LineNumber,
LinePosition = e.LinePosition,
Message = e.Message
});
}
}
}
// 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
- AssemblyNameProxy.cs
- SpanIndex.cs
- objectquery_tresulttype.cs
- JsonDeserializer.cs
- ComplexLine.cs
- DataObjectPastingEventArgs.cs
- AdvancedBindingEditor.cs
- FilterElement.cs
- DbMetaDataFactory.cs
- PointUtil.cs
- BitmapEffectGroup.cs
- SystemIPv6InterfaceProperties.cs
- HttpCacheVary.cs
- DetailsViewRow.cs
- ModelPropertyImpl.cs
- cookie.cs
- MetadataItemEmitter.cs
- EventLogEntryCollection.cs
- TrackingMemoryStream.cs
- PasswordRecovery.cs
- SmtpMail.cs
- MenuBindingsEditorForm.cs
- WizardStepBase.cs
- InputLangChangeRequestEvent.cs
- IpcPort.cs
- LazyTextWriterCreator.cs
- AppSettings.cs
- SchemaEntity.cs
- RangeBaseAutomationPeer.cs
- DataErrorValidationRule.cs
- ConvertBinder.cs
- FactoryGenerator.cs
- FactoryMaker.cs
- SqlStatistics.cs
- RowsCopiedEventArgs.cs
- CompletedAsyncResult.cs
- ManualResetEvent.cs
- Matrix.cs
- XmlSerializationGeneratedCode.cs
- SmtpReplyReader.cs
- TdsEnums.cs
- ReliableReplySessionChannel.cs
- MetafileHeaderEmf.cs
- UserControlAutomationPeer.cs
- WmlCalendarAdapter.cs
- EntityContainerAssociationSet.cs
- ObjectAnimationBase.cs
- Geometry.cs
- TextEditorParagraphs.cs
- ArcSegment.cs
- CompressedStack.cs
- BitmapEffectDrawingContextWalker.cs
- WebPartCancelEventArgs.cs
- SHA384Managed.cs
- Compiler.cs
- Html32TextWriter.cs
- ByteKeyFrameCollection.cs
- X509Certificate2Collection.cs
- SchemaNamespaceManager.cs
- OleDbDataAdapter.cs
- SingleSelectRootGridEntry.cs
- ThaiBuddhistCalendar.cs
- RoleGroup.cs
- WebRequestModuleElementCollection.cs
- HMACSHA256.cs
- JsonWriter.cs
- XsdDateTime.cs
- ToolStripContentPanel.cs
- ProxyHwnd.cs
- SessionIDManager.cs
- ComponentChangedEvent.cs
- VisualBasicDesignerHelper.cs
- FormsAuthenticationTicket.cs
- TextPattern.cs
- LocalFileSettingsProvider.cs
- IResourceProvider.cs
- SystemMulticastIPAddressInformation.cs
- DefaultValueConverter.cs
- PropertyEmitterBase.cs
- ToolStripRenderEventArgs.cs
- CreateUserErrorEventArgs.cs
- HtmlInputText.cs
- autovalidator.cs
- SymbolDocumentGenerator.cs
- StatusBar.cs
- ParallelTimeline.cs
- PageRequestManager.cs
- DataListAutoFormat.cs
- LambdaCompiler.Generated.cs
- AsyncSerializedWorker.cs
- RuleSetReference.cs
- Cursor.cs
- SigningCredentials.cs
- SkinBuilder.cs
- DataControlCommands.cs
- DataGridViewCellFormattingEventArgs.cs
- precedingquery.cs
- PerspectiveCamera.cs
- Models.cs
- SqlRecordBuffer.cs