コード例 #1
0
        public bool ValidateXaml(XamlReader xamlReader, bool failOnFirstError, string assemblyName, out IList<LogData> 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<ValidationEventArgs>(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;
        }
コード例 #2
0
        public bool ValidateXaml(XamlReader xamlReader, bool failOnFirstError, string assemblyName, out IList <LogData> 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 <ValidationEventArgs>(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);
        }