예제 #1
0
        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);
        }
예제 #2
0
		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.");
		}
예제 #3
0
        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);
            }
        }
예제 #4
0
파일: Module.cs 프로젝트: baulig/wcf-config
 public abstract void Serialize(Context context, XmlWriter writer, object obj);
예제 #5
0
파일: Module.cs 프로젝트: baulig/wcf-config
 public abstract void Deserialize(Context context, XmlReader reader, object obj);
예제 #6
0
 public void Serialize(Context context, XmlWriter writer)
 {
     Generator.RootModule.Serialize (context, writer, this);
 }