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
- XmlDataSourceDesigner.cs
- TabletCollection.cs
- CrossContextChannel.cs
- ValidatingPropertiesEventArgs.cs
- GlyphShapingProperties.cs
- MarkupExtensionParser.cs
- ElementHostAutomationPeer.cs
- ComplexTypeEmitter.cs
- CompoundFileDeflateTransform.cs
- StreamGeometryContext.cs
- XmlMapping.cs
- FilterElement.cs
- HttpClientChannel.cs
- NavigateUrlConverter.cs
- Enlistment.cs
- DSACryptoServiceProvider.cs
- BuildManager.cs
- Stylus.cs
- SrgsGrammarCompiler.cs
- ItemCollection.cs
- _TransmitFileOverlappedAsyncResult.cs
- XmlObjectSerializerContext.cs
- RuleSetDialog.cs
- CompareInfo.cs
- GuidConverter.cs
- ActivityTypeResolver.xaml.cs
- LowerCaseStringConverter.cs
- ReferentialConstraint.cs
- ISCIIEncoding.cs
- WebPartDisplayModeCollection.cs
- HttpResponseWrapper.cs
- SystemIPGlobalStatistics.cs
- ConcurrentBag.cs
- WebBrowser.cs
- SessionState.cs
- Accessible.cs
- ADMembershipProvider.cs
- ColumnPropertiesGroup.cs
- ContentDefinition.cs
- DEREncoding.cs
- PermissionRequestEvidence.cs
- TextFormatter.cs
- TableItemStyle.cs
- UserControlBuildProvider.cs
- ToolStripItemRenderEventArgs.cs
- PropertyInformationCollection.cs
- WpfGeneratedKnownProperties.cs
- TextBoxRenderer.cs
- SqlDataSourceEnumerator.cs
- DesignerEventService.cs
- DoubleLinkList.cs
- CustomErrorsSection.cs
- OdbcUtils.cs
- TargetFrameworkUtil.cs
- Region.cs
- FrameworkRichTextComposition.cs
- SoapInteropTypes.cs
- MenuItemStyleCollection.cs
- WebConfigurationFileMap.cs
- DataGridViewCheckBoxCell.cs
- MemberPathMap.cs
- SettingsProperty.cs
- EventLogPermissionEntryCollection.cs
- TdsParameterSetter.cs
- _OverlappedAsyncResult.cs
- CqlWriter.cs
- ControlType.cs
- CompilationUtil.cs
- OutputScopeManager.cs
- BitmapEncoder.cs
- WsdlBuildProvider.cs
- RegexCompilationInfo.cs
- FixedBufferAttribute.cs
- SQLByteStorage.cs
- ProtocolsConfigurationEntry.cs
- FrameworkElementAutomationPeer.cs
- X509CertificateCollection.cs
- HtmlTableRow.cs
- TableCellCollection.cs
- TreeNodeEventArgs.cs
- UnsafeNativeMethods.cs
- XPathExpr.cs
- xml.cs
- ControlBuilder.cs
- DoubleLinkList.cs
- ValueProviderWrapper.cs
- ListDependantCardsRequest.cs
- ObjectDataSourceWizardForm.cs
- XamlFilter.cs
- OperationAbortedException.cs
- SoapTypeAttribute.cs
- TextProperties.cs
- ListView.cs
- XsltLoader.cs
- cookiecontainer.cs
- InputScopeNameConverter.cs
- Transform3DGroup.cs
- ConnectionPoint.cs
- ObjectPersistData.cs
- FacetValueContainer.cs