static void ValidateType(Type parameterType, IDataContractSurrogate surrogate, IEnumerable<Type> knownTypes) { XsdDataContractExporter dataContractExporter = new XsdDataContractExporter(); if (surrogate != null || knownTypes != null) { ExportOptions options = new ExportOptions(); options.DataContractSurrogate = surrogate; if (knownTypes != null) { foreach (Type knownType in knownTypes) { options.KnownTypes.Add(knownType); } } dataContractExporter.Options = options; } dataContractExporter.GetSchemaTypeName(parameterType); // throws if parameterType is not a valid data contract }
private void ValidateDataContractType(System.Type type) { if (this.dataContractExporter == null) { this.dataContractExporter = new XsdDataContractExporter(); if ((this.serializerFactory != null) && (this.serializerFactory.DataContractSurrogate != null)) { ExportOptions options = new ExportOptions { DataContractSurrogate = this.serializerFactory.DataContractSurrogate }; this.dataContractExporter.Options = options; } } this.dataContractExporter.GetSchemaTypeName(type); }
private void ValidateDataContractType(Type type) { if (dataContractExporter == null) { dataContractExporter = new XsdDataContractExporter(); if (serializerFactory != null && serializerFactory.DataContractSurrogate != null) { ExportOptions options = new ExportOptions(); options.DataContractSurrogate = serializerFactory.DataContractSurrogate; dataContractExporter.Options = options; } } dataContractExporter.GetSchemaTypeName(type); //Throws if the type is not a valid data contract }