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
- BufferedGraphicsContext.cs
- SerializationAttributes.cs
- PropertyDescriptorComparer.cs
- CompilerResults.cs
- LZCodec.cs
- _SSPIWrapper.cs
- AssociatedControlConverter.cs
- SubMenuStyle.cs
- NavigationWindow.cs
- Permission.cs
- HtmlImage.cs
- BuilderInfo.cs
- RelatedView.cs
- SqlMetaData.cs
- UriSection.cs
- CodeDelegateCreateExpression.cs
- WorkflowElementDialog.cs
- WhileDesigner.cs
- MemoryStream.cs
- HostProtectionPermission.cs
- TabControlEvent.cs
- DefaultValidator.cs
- QuaternionKeyFrameCollection.cs
- PlatformNotSupportedException.cs
- JapaneseCalendar.cs
- CanonicalizationDriver.cs
- PeerNameRecord.cs
- EditorZone.cs
- ServiceHostingEnvironment.cs
- WebWorkflowRole.cs
- GeneralTransformCollection.cs
- SetIterators.cs
- WebPartDescription.cs
- DataMemberListEditor.cs
- NamedPipeHostedTransportConfiguration.cs
- Attributes.cs
- SourceInterpreter.cs
- SafeMILHandle.cs
- DataGridColumn.cs
- PerformanceCounterCategory.cs
- OptimizedTemplateContentHelper.cs
- Section.cs
- FunctionNode.cs
- Clipboard.cs
- SqlDependency.cs
- DataGridDesigner.cs
- SetterBaseCollection.cs
- WebPartUserCapability.cs
- TokenBasedSet.cs
- XPathDocumentIterator.cs
- mongolianshape.cs
- StyleConverter.cs
- AppDomainManager.cs
- EntityDataSourceEntityTypeFilterItem.cs
- AdapterUtil.cs
- XmlAnyAttributeAttribute.cs
- FunctionQuery.cs
- basecomparevalidator.cs
- HttpRequestContext.cs
- RadioButtonAutomationPeer.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- UnsafeNativeMethods.cs
- _OverlappedAsyncResult.cs
- CookielessHelper.cs
- ExtractedStateEntry.cs
- URI.cs
- COM2EnumConverter.cs
- QuaternionConverter.cs
- LinearGradientBrush.cs
- SafeNativeMethodsCLR.cs
- XmlSchemaInclude.cs
- HierarchicalDataTemplate.cs
- CompatibleIComparer.cs
- DBDataPermission.cs
- PartitionerQueryOperator.cs
- DictionaryEntry.cs
- PointAnimation.cs
- NativeMethods.cs
- StructuredTypeInfo.cs
- ProgressBar.cs
- RunClient.cs
- TemplateBindingExpressionConverter.cs
- AdRotatorDesigner.cs
- TextMetrics.cs
- HttpCookieCollection.cs
- DataGridColumnHeadersPresenter.cs
- OleAutBinder.cs
- LoginName.cs
- MetadataUtilsSmi.cs
- Encoding.cs
- Vector3DAnimationBase.cs
- SingleTagSectionHandler.cs
- CanonicalFontFamilyReference.cs
- BridgeDataRecord.cs
- ParsedAttributeCollection.cs
- Base64Decoder.cs
- TcpServerChannel.cs
- EnumerableRowCollection.cs
- SynchronizedPool.cs
- OperatingSystemVersionCheck.cs