public static void Deserialize(string xmlFilename, string xsdFilename) { var context = new Context (); var config = new Configuration (context, xmlFilename, xsdFilename); Console.WriteLine ("READ CONFIG FROM XML"); DebugUtils.Dump (config); }
private ConfigurationHost (string xmlFilename, string xsdFilename) { context = new Context (); #if MOBILE /* * The Mono.ServiceModel.Configuration.IMonoConfigurationHost * API is public in the mobile profile. */ MonoConfigurationHost.CustomConfigurationHost = this; #else /* * We use reflection here, so we don't depend on Mono * additions to System.ServiceModel.dll which would cause * problems when using the Mono.ServiceModel.Configuration.dll * with Microsoft's runtime on Windows. */ if (Environment.OSVersion.Platform != PlatformID.Unix) throw new InvalidOperationException ( "ConfigurationHost can only be used on Mono."); var asm = typeof (ChannelFactory).Assembly; var type = asm.GetType ("Mono.ServiceModel.Configuration.MonoConfigurationHost", true); var bf = BindingFlags.Static | BindingFlags.NonPublic; var method = type.GetMethod ("SetCustomConfigurationHandler", bf); if (method == null) throw new InvalidOperationException (); var dlgType = type.GetNestedType ("CustomConfigurationDelegate", BindingFlags.NonPublic); if (dlgType == null) throw new InvalidOperationException (); var handler = Delegate.CreateDelegate (dlgType, this, "ConfigureEndpoint"); method.Invoke (null, new object[] { handler }); #endif Console.WriteLine ("Custom configuration handler installed."); config = new Configuration (context, xmlFilename, xsdFilename); foreach (var warning in context.Warnings) Console.WriteLine ("WARNING: {0}", warning.Message); foreach (var error in context.Errors) Console.WriteLine ("ERROR: {0}", error.Message); if (context.HasErrors) Console.WriteLine ("Failed to load configuration!"); DebugUtils.Dump (config); Console.WriteLine ("Configuration loaded."); }
public Configuration(Context context, string xmlFilename, string schemaFilename) { deserialized = true; var schema = new XmlSchemaSet (); schema.Add (Generator.Namespace, Utils.GetFilename (schemaFilename)); schema.Compile (); var settings = new XmlReaderSettings { ValidationType = ValidationType.Schema, ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints, IgnoreComments = true, IgnoreWhitespace = true }; settings.Schemas.Add (schema); using (var xml = XmlReader.Create (Utils.GetFilename (xmlFilename), settings)) { Generator.RootModule.Deserialize (context, xml, this); } }
public abstract void Serialize(Context context, XmlWriter writer, object obj);
public abstract void Deserialize(Context context, XmlReader reader, object obj);
public void Serialize(Context context, XmlWriter writer) { Generator.RootModule.Serialize (context, writer, this); }