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
- ThreadStateException.cs
- basecomparevalidator.cs
- MulticastOption.cs
- TemplateBuilder.cs
- DependencySource.cs
- basevalidator.cs
- WebPartUtil.cs
- X509RawDataKeyIdentifierClause.cs
- BufferedGraphics.cs
- Operator.cs
- OdbcException.cs
- InternalControlCollection.cs
- CodeAttachEventStatement.cs
- SystemParameters.cs
- TextEditorParagraphs.cs
- JsonDeserializer.cs
- HttpModulesSection.cs
- TypeContext.cs
- RuleElement.cs
- SecurityPolicySection.cs
- DescriptionAttribute.cs
- DataGridViewCellStyleChangedEventArgs.cs
- ByteAnimationUsingKeyFrames.cs
- coordinatorscratchpad.cs
- InputLanguageEventArgs.cs
- FullTrustAssemblyCollection.cs
- InternalControlCollection.cs
- InternalsVisibleToAttribute.cs
- NullableFloatAverageAggregationOperator.cs
- GeneralEndpointIdentity.cs
- XmlNavigatorFilter.cs
- _UncName.cs
- PackWebRequestFactory.cs
- HyperLink.cs
- ZipIOLocalFileDataDescriptor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- LoopExpression.cs
- SQLBinaryStorage.cs
- AuthStoreRoleProvider.cs
- DefaultShape.cs
- ExtendedPropertyCollection.cs
- BitmapFrameDecode.cs
- RadioButton.cs
- EntityConnectionStringBuilderItem.cs
- Clock.cs
- XMLUtil.cs
- ActivationServices.cs
- AnonymousIdentificationModule.cs
- BitmapSource.cs
- Walker.cs
- TypeInitializationException.cs
- EdmSchemaError.cs
- Attribute.cs
- WebBrowserEvent.cs
- PerfCounterSection.cs
- Perspective.cs
- CellIdBoolean.cs
- EndpointAddressMessageFilter.cs
- XPathSelectionIterator.cs
- Baml2006ReaderFrame.cs
- WebRequestModulesSection.cs
- FrameworkElementFactoryMarkupObject.cs
- DBSqlParser.cs
- IMembershipProvider.cs
- WindowsButton.cs
- IndependentlyAnimatedPropertyMetadata.cs
- PinnedBufferMemoryStream.cs
- DataGridViewCellConverter.cs
- ControlCodeDomSerializer.cs
- DiffuseMaterial.cs
- FaultException.cs
- ListenerPerfCounters.cs
- ToolStripSystemRenderer.cs
- RequestResizeEvent.cs
- DataBindEngine.cs
- TaskHelper.cs
- safex509handles.cs
- DbMetaDataColumnNames.cs
- AutoGeneratedFieldProperties.cs
- RefreshPropertiesAttribute.cs
- OleDbReferenceCollection.cs
- LightweightCodeGenerator.cs
- AnnotationResource.cs
- ReadOnlyTernaryTree.cs
- OrderingQueryOperator.cs
- OutOfProcStateClientManager.cs
- PropertyMap.cs
- GifBitmapDecoder.cs
- DetailsView.cs
- ColumnHeader.cs
- XmlDataProvider.cs
- CompareInfo.cs
- ToolStrip.cs
- SaveFileDialogDesigner.cs
- ContentDesigner.cs
- ByteStack.cs
- TreeSet.cs
- HtmlProps.cs
- HostUtils.cs
- WebPartCollection.cs