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; IListeventArgs; 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
- ColorDialog.cs
- commandenforcer.cs
- BitmapScalingModeValidation.cs
- UnsignedPublishLicense.cs
- CodeGeneratorOptions.cs
- Operand.cs
- DoubleAnimation.cs
- UTF8Encoding.cs
- DataTrigger.cs
- ConnectionManagementElementCollection.cs
- ToolStripContentPanel.cs
- CodeTypeMemberCollection.cs
- Rect3DValueSerializer.cs
- HtmlLinkAdapter.cs
- DesignerAttribute.cs
- DecoderFallback.cs
- TemplatedWizardStep.cs
- MergePropertyDescriptor.cs
- DataRowChangeEvent.cs
- RequestStatusBarUpdateEventArgs.cs
- ResourcePool.cs
- KeyValuePair.cs
- StagingAreaInputItem.cs
- AbstractSvcMapFileLoader.cs
- StringUtil.cs
- PersonalizationAdministration.cs
- OdbcConnectionStringbuilder.cs
- FactoryMaker.cs
- XmlSchemaAll.cs
- Focus.cs
- EntityProxyFactory.cs
- XPathNavigatorReader.cs
- BitmapEffectDrawingContextWalker.cs
- DecoderExceptionFallback.cs
- InitiatorServiceModelSecurityTokenRequirement.cs
- TextRunTypographyProperties.cs
- QueryOutputWriterV1.cs
- _ChunkParse.cs
- JsonObjectDataContract.cs
- PeerApplicationLaunchInfo.cs
- PackWebRequestFactory.cs
- Control.cs
- NativeCompoundFileAPIs.cs
- AlternateView.cs
- ChannelTracker.cs
- ACL.cs
- ProfilePropertySettingsCollection.cs
- UserControlCodeDomTreeGenerator.cs
- LoginCancelEventArgs.cs
- AbandonedMutexException.cs
- SQLString.cs
- ScrollEventArgs.cs
- StrokeNodeOperations2.cs
- XappLauncher.cs
- RIPEMD160Managed.cs
- odbcmetadatafactory.cs
- TableLayoutSettingsTypeConverter.cs
- ColorAnimation.cs
- ListControlBuilder.cs
- StrokeIntersection.cs
- PlatformCulture.cs
- XmlDataSource.cs
- DocumentApplicationJournalEntry.cs
- AncestorChangedEventArgs.cs
- SessionStateModule.cs
- UnauthorizedWebPart.cs
- DnsEndPoint.cs
- HttpRequestCacheValidator.cs
- InvokeMemberBinder.cs
- DeviceContext.cs
- WebSysDescriptionAttribute.cs
- ProviderUtil.cs
- PrintPreviewDialog.cs
- FixedSOMLineCollection.cs
- FixedSOMFixedBlock.cs
- WebPartHelpVerb.cs
- TypeGeneratedEventArgs.cs
- AuthenticationModuleElementCollection.cs
- ToolBarTray.cs
- AnimationClock.cs
- AuthenticationManager.cs
- MachineSettingsSection.cs
- ContentElementAutomationPeer.cs
- DataShape.cs
- Parsers.cs
- BitmapDecoder.cs
- EntityType.cs
- ImagingCache.cs
- UriTemplateTable.cs
- FormViewModeEventArgs.cs
- SatelliteContractVersionAttribute.cs
- SvcMapFile.cs
- SafeTokenHandle.cs
- EventHandlersStore.cs
- ImageField.cs
- StylusPoint.cs
- BrowserCapabilitiesFactoryBase.cs
- Link.cs
- SynchronizationLockException.cs
- CharEntityEncoderFallback.cs