/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ namespace prova { using System.Reflection; using System.IO; using System.Xml; using System; public class Validate { public static void Main(string[] args) { if (args.Length == 4) { if (File.Exists(args[0]) == false) { System.Console.WriteLine("dll {0} does not exist", args[0]); return; } else if (File.Exists(args[3]) == false) { System.Console.WriteLine("file {0} does not exist", args[3]); return; } try { Console.Write("validating {0} with resource[{1} ns:{2}]...", args[3], args[1], args[2]); Assembly assembly = Assembly.LoadFrom(args[0]); Stream stream = assembly.GetManifestResourceStream(args[1]); StreamReader streamReader = new StreamReader(stream); XmlTextReader schemaReader = new XmlTextReader(streamReader.BaseStream); XmlValidatingReader reader = new XmlValidatingReader(new XmlTextReader(args[3])); reader.ValidationType = ValidationType.Schema; reader.Schemas.Add(args[2],schemaReader); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); Console.WriteLine("..[OK]"); } catch(System.Exception ex) { Console.WriteLine("..[ERROR]"); Console.WriteLine(ex.Message); } } else { Console.WriteLine("usage: validate source-dll res-name namespace-name file"); } } } }