private void ValidateSetup() { using (var stringReader = new StringReader(new TTransform().XmlContent)) using (var xmlReader = XmlReader.Create(stringReader, new XmlReaderSettings { XmlResolver = null })) { var navigator = new XPathDocument(xmlReader).CreateNavigator(); var output = navigator.SelectSingleNode("/xsl:stylesheet/xsl:output/@method", navigator.GetNamespaceManager().AddNamespaces <TTransform>()); if (output != null && !output.Value.Equals("xml", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Transform produces a {output.Value} output and not an XML one."); } } switch (ContentProcessing) { case XmlSchemaContentProcessing.None: case XmlSchemaContentProcessing.Skip: break; case XmlSchemaContentProcessing.Lax: case XmlSchemaContentProcessing.Strict: if (!Schemas.Any()) { throw new InvalidOperationException("At least one XML Schema to which the output must conform to must be setup."); } break; } }
private SqlSchemaName AddSchemaIfNotExists(string schemaName) { if (!Schemas.Any(x => x.Name.Equals(schemaName, StringComparison.OrdinalIgnoreCase))) { Schemas.Add(new SqlSchemaName(schemaName) { Database = this }); } return(Schemas.Get(schemaName)); }
protected void AddArgument(string name, string shortName = "", string description = "", bool isReqruied = false, bool isUnary = false, string format = null) { if (Schemas.Any(c => c.Name.Equals(name))) { throw new ArgumentException($"Argument {name} is already defined."); } Schemas.Add(new CommandArgument { Name = name, ShortName = shortName, Description = description, IsRequired = isReqruied, IsUninary = isUnary, Format = format }); }
private void ValidateSetup() { switch (ContentProcessing) { case XmlSchemaContentProcessing.None: case XmlSchemaContentProcessing.Skip: break; case XmlSchemaContentProcessing.Lax: case XmlSchemaContentProcessing.Strict: if (!Schemas.Any()) { throw new InvalidOperationException("At least one XML Schema to which the output must conform to must be setup."); } break; } }
public void UpdateSchemas() { var currSchemaGuid = powerWraper.GetActiveGuid(); var newSchemas = powerWraper.GetCurrentSchemas(); //Add and update new / changed schemas foreach (var newSchema in newSchemas) { var originalSchema = Schemas.FirstOrDefault(sch => sch.Guid == newSchema.Guid); if (originalSchema == null) { InsertNewSchema(newSchemas, newSchema); originalSchema = newSchema; } if (newSchema.Guid == currSchemaGuid && originalSchema?.IsActive != true) { SetNewCurrSchema(originalSchema); } if (originalSchema?.Name != newSchema.Name) { ((PowerSchema)originalSchema).Name = newSchema.Name; } } if (!Schemas.Any(sch => currSchemaGuid == sch.Guid)) { NoSchemaIsActive(); } //remove old schemas var schemasToBeRemoved = new List <IPowerSchema>(); foreach (var oldSchema in Schemas) { if (newSchemas.FirstOrDefault(sch => sch.Guid == oldSchema.Guid) == null) { schemasToBeRemoved.Add(oldSchema); } } schemasToBeRemoved.ForEach(sch => Schemas.Remove(sch)); }