Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------ // 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
- ViewLoader.cs
- TableLayoutStyle.cs
- ClientType.cs
- returneventsaver.cs
- Literal.cs
- versioninfo.cs
- DocumentViewerBaseAutomationPeer.cs
- TextServicesProperty.cs
- RegexMatch.cs
- CngUIPolicy.cs
- TemplatedAdorner.cs
- ComplexPropertyEntry.cs
- SimpleBitVector32.cs
- ValueSerializer.cs
- HttpCapabilitiesSectionHandler.cs
- SecurityState.cs
- Form.cs
- ListViewGroup.cs
- CheckedPointers.cs
- BypassElementCollection.cs
- BaseProcessor.cs
- MsmqHostedTransportConfiguration.cs
- activationcontext.cs
- DetailsViewDeletedEventArgs.cs
- FatalException.cs
- DrawingContextDrawingContextWalker.cs
- DataGridTextBoxColumn.cs
- OleDbException.cs
- XmlSchemaAttributeGroupRef.cs
- SchemaElement.cs
- OleDbTransaction.cs
- XmlSchemaProviderAttribute.cs
- AudioFormatConverter.cs
- XmlKeywords.cs
- HttpFileCollection.cs
- PathSegmentCollection.cs
- HScrollProperties.cs
- DataControlImageButton.cs
- SiteMapPath.cs
- PageBreakRecord.cs
- RegistrationServices.cs
- AsnEncodedData.cs
- StickyNoteContentControl.cs
- LayoutUtils.cs
- TargetControlTypeCache.cs
- IndentTextWriter.cs
- ScriptingAuthenticationServiceSection.cs
- CodeCatchClauseCollection.cs
- SafeViewOfFileHandle.cs
- NumericUpDownAccelerationCollection.cs
- FormatConvertedBitmap.cs
- StandardTransformFactory.cs
- ConfigurationValidatorAttribute.cs
- DateRangeEvent.cs
- Authorization.cs
- QueryTaskGroupState.cs
- SqlLiftWhereClauses.cs
- PointLightBase.cs
- ObjectView.cs
- SwitchDesigner.xaml.cs
- ServiceModelConfigurationSection.cs
- UniqueConstraint.cs
- SynchronizationContext.cs
- DbParameterCollectionHelper.cs
- BindingGroup.cs
- MemoryStream.cs
- StringToken.cs
- GridViewCommandEventArgs.cs
- PathSegment.cs
- BitmapCodecInfo.cs
- SplitterCancelEvent.cs
- ChangeConflicts.cs
- XmlCodeExporter.cs
- ScrollProperties.cs
- PageThemeParser.cs
- RemotingAttributes.cs
- InputProviderSite.cs
- SqlBuffer.cs
- XmlWellformedWriter.cs
- httpapplicationstate.cs
- StorageScalarPropertyMapping.cs
- PerformanceCountersBase.cs
- InternalBufferOverflowException.cs
- SecurityElement.cs
- UserNameSecurityTokenParameters.cs
- ValueUtilsSmi.cs
- clipboard.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- Rfc2898DeriveBytes.cs
- PropertyDescriptorGridEntry.cs
- XmlDataSourceNodeDescriptor.cs
- ListViewSortEventArgs.cs
- FtpRequestCacheValidator.cs
- TemplateField.cs
- FixUpCollection.cs
- HtmlEncodedRawTextWriter.cs
- _SSPISessionCache.cs
- SecurityPermission.cs
- BinaryMethodMessage.cs
- DataException.cs