private FunctionDeclaration ProcessXmlFragment(XmlFragmentContext xmlFragmentContext, FileInfo file) { // fragment complete, process it StringReader stringReader = new StringReader(xmlFragmentContext.XmlFragment.ToString()); XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(FunctionDeclaration.SchemaUri, FunctionDeclaration.GetSchemaReader()); XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas = schemas; settings.ValidationType = ValidationType.Schema; settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings; var schemaValidationObject = new SchemaValidationObject(file, xmlFragmentContext.FirstLineNumber, xmlFragmentContext.Indents); settings.ValidationEventHandler += schemaValidationObject.CreateValidationHandler(); XmlReader xmlReader = XmlReader.Create(stringReader, settings, file.FullName); XmlSerializer serializer = new XmlSerializer(typeof(FunctionDeclaration), FunctionDeclaration.SchemaUri); try { FunctionDeclaration declaration = (FunctionDeclaration)serializer.Deserialize(xmlReader); if (schemaValidationObject.HasFailed) { return(null); } else { return(declaration); } } catch (InvalidOperationException e) { XmlException xmlException = e.InnerException as XmlException; if (xmlException != null) { throw new InputException( InputError.XmlError, file.FullName, xmlException.LineNumber + xmlFragmentContext.FirstLineNumber - 1, xmlException.LinePosition + xmlFragmentContext.Indents[xmlException.LineNumber - 1], xmlException); } else { throw; } } }
private CommentLineContext ProcessXmlFragmentClosingTagLine(XmlFragmentContext xmlFragmentContext, FileInfo file) { FunctionDeclaration declaration = ProcessXmlFragment(xmlFragmentContext, file); if (declaration == null) { return(new CommentLineContext(xmlFragmentContext, null, true)); } if (string.IsNullOrEmpty(declaration.TemplateControlMarkupFile)) { string cd = Environment.CurrentDirectory; string path = file.FullName; // TODO: geht nicht wenn parameter filemask ein ..\ o.ä. enthält Assertion.IsTrue(path.StartsWith(cd)); path = path.Substring(cd.Length + 1); string ext = file.Extension; if (!string.IsNullOrEmpty(ext)) { path = path.Substring(0, path.Length - ext.Length); } declaration.TemplateControlMarkupFile = path; } if (declaration.TemplateControlMode == TemplateMode.AutoDetect) { bool isPageFile = file.Name.EndsWith(".aspx" + file.Extension); bool isUserControlFile = file.Name.EndsWith(".ascx" + file.Extension); Assertion.IsTrue(isPageFile || isUserControlFile); declaration.TemplateControlMode = isPageFile ? TemplateMode.Page : TemplateMode.UserControl; } // replace built-in types foreach (VariableDeclaration var in declaration.ParametersAndVariables) { var.TypeName = _languageProvider.ConvertTypeName(var.TypeName); } if (string.IsNullOrEmpty(declaration.FunctionBaseType)) { declaration.FunctionBaseType = _functionBaseType; } return(new CommentLineContext(xmlFragmentContext, declaration, true)); }
public CommentLineContext(XmlFragmentContext xmlFragmentContext, FunctionDeclaration functionDeclaration, bool isXmlFragmentComplete) { XmlFragmentContext = xmlFragmentContext; FunctionDeclaration = functionDeclaration; IsXmlFragmentComplete = isXmlFragmentComplete; }