internal SerializationContext(int depth, SerializationOptions options, PSRemotingCryptoHelper cryptoHelper) { this.cimClassSerializationIdCache = new CimClassSerializationCache<CimClassSerializationId>(); if (depth < 1) { throw PSTraceSource.NewArgumentException("writer", "serialization", "DepthOfOneRequired", new object[0]); } this.depth = depth; this.options = options; this.cryptoHelper = cryptoHelper; }
/// <summary> /// /// </summary> /// <param name="options">Options that control how the serialization is to be performed.</param> /// <param name="namingConvention">Naming strategy to use for serialized property names</param> public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null) { this.options = options; this.namingConvention = namingConvention ?? new NullNamingConvention(); Converters = new List<IYamlTypeConverter>(); typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType) ? (ITypeResolver)new StaticTypeResolver() : (ITypeResolver)new DynamicTypeResolver(); }
public SerializationAttribute(SerializationOptions options, DynamicDeserializationBehavior dynamicBehavior) { if ((options & SerializationOptions.Omit) != 0 && dynamicBehavior != DynamicDeserializationBehavior.InvokeCallback) { throw new ArgumentException("When using SerializationOptions.Omit, " + "the DynamicDeserializationBehavior.InvokeCallback value is invalid " + "because no callback will be invoked."); } _options = options; _dynamicBehavior = dynamicBehavior; }
public Stream GetXml(string referenceMemberName, SerializationOptions options = null) { var stream = new MemoryStream(); var writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true }); writer.WriteStartDocument(); WriteXml(writer, referenceMemberName, options); writer.Flush(); stream.Position = 0; return stream; }
public RockOptions(OptimizationSetting level = OptimizationSetting.Release, CodeFileOptions codeFile = CodeFileOptions.None, SerializationOptions serialization = SerializationOptions.NotSupported, CachingOptions caching = CachingOptions.UseCache, AllowWarnings allowWarnings = AllowWarnings.No) { this.Optimization = level; this.CodeFile = codeFile; this.Serialization = serialization; this.Caching = caching; this.AllowWarnings = allowWarnings; }
/// <summary> /// /// </summary> /// <param name="options">Options that control how the serialization is to be performed.</param> /// <param name="namingConvention">Naming strategy to use for serialized property names</param> public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null) { this.options = options; this.namingConvention = namingConvention ?? new NullNamingConvention(); Converters = new List<IYamlTypeConverter>(); foreach (IYamlTypeConverter yamlTypeConverter in Utilities.YamlTypeConverters.BuiltInConverters) { Converters.Add(yamlTypeConverter); } typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType) ? (ITypeResolver)new StaticTypeResolver() : (ITypeResolver)new DynamicTypeResolver(); }
/// <summary> /// /// </summary> /// <param name="options">Options that control how the serialization is to be performed.</param> /// <param name="namingConvention">Naming strategy to use for serialized property names</param> /// <param name="overrides">Yaml attribute overrides</param> public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null, YamlAttributeOverrides overrides = null) { this.options = options; this.namingConvention = namingConvention ?? new NullNamingConvention(); this.overrides = overrides; Converters = new List<IYamlTypeConverter>(); foreach (IYamlTypeConverter yamlTypeConverter in Utilities.YamlTypeConverters.GetBuiltInConverters(IsOptionSet(SerializationOptions.JsonCompatible))) { Converters.Add(yamlTypeConverter); } typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType) ? (ITypeResolver)new StaticTypeResolver() : (ITypeResolver)new DynamicTypeResolver(); }
public static string MakeYamlString( object obj, SerializationOptions options = SerializationOptions.None ) { var serializer = new Serializer( options ); var sw = new StringWriter(); serializer.Serialize( sw, obj ); return sw .ToString() .UnescapeSlashes() .Replace( "\r", "" ) .Replace( "\n\n", "\n" ) .Replace( ": >-\n", ":\n" ) .Replace( ": >\n", ":\n" ) ; }
private Stream GetXml(bool withChildren, string queryFilter, QuerySettings querySettings, SerializationOptions options) { if (options == null) options = SerializationOptions.Default; var stream = new MemoryStream(); var writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true }); writer.WriteStartDocument(); //if a filter or query settings is present, we have to filter children if (!string.IsNullOrEmpty(queryFilter) || querySettings != null) WriteXml(writer, queryFilter, querySettings, options); else WriteXml(writer, withChildren, options); writer.Flush(); stream.Position = 0; return stream; }
private async void OnSerializeDataGrid(object sender, RoutedEventArgs e) { var folder = ApplicationData.Current.LocalFolder; try { var storageFile = await folder.CreateFileAsync("SfDataGrid.xml", CreationCollisionOption.ReplaceExisting); var options = new SerializationOptions() { SerializeColumns = (bool)this.SerializeColumns.IsChecked, SerializeFiltering = (bool)this.SerializeFiltering.IsChecked, SerializeGrouping = (bool)this.SerializeGrouping.IsChecked, SerializeSorting = (bool)this.SerializeSorting.IsChecked, SerializeGroupSummaries = (bool)this.SerializeGroupSummaries.IsChecked, SerializeTableSummaries = (bool)this.SerializeTableSummaries.IsChecked, SerializeStackedHeaders = (bool)this.SerializeStackedHeaders.IsChecked }; this.sfDataGrid.Serialize(storageFile, options); } catch (Exception) { } }
protected override void WriteXml(XmlWriter writer, bool withChildren, SerializationOptions options) { const string thisName = "SearchFolder"; const string thisPath = "/Root/SearchFolder"; writer.WriteStartElement("Content"); base.WriteHead(writer, thisName, thisName, thisName, thisPath, true); if (_query != null) { writer.WriteStartElement("Query"); writer.WriteRaw(_query.ToXml()); writer.WriteEndElement(); } if (withChildren && Children != null) { writer.WriteStartElement("Children"); this.WriteXml(Children, writer, options); writer.WriteEndElement(); } writer.WriteEndElement(); }
protected override void WriteXml(XmlWriter writer, bool withChildren, SerializationOptions options) { const string thisName = "SearchFolder"; const string thisPath = "/Root/SearchFolder"; writer.WriteStartElement("Content"); base.WriteHead(writer, thisName, thisName, thisName, thisPath, true); if (_query != null) { writer.WriteStartElement("Query"); writer.WriteRaw(_query.ToXml()); writer.WriteEndElement(); } if (withChildren && Children != null) { writer.WriteStartElement("Children"); this.WriteXml(Children, writer, options); writer.WriteEndElement(); } writer.WriteEndElement(); }
public void TestGlobalSerializerOverride() { var config = new SerializationOptions(); var globalListSerializer = new GlobalListSerializer(); config.GlobalSerializer = new GlobalSerializerOptions { Creator = () => globalListSerializer, OverrideClrSerialization = true }; var ss = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build(); var list = new List <string> { "foo", "bar" }; var d = ss.ToData(list); var input = ss.CreateObjectDataInput(d); var actual = (List <string>)globalListSerializer.Read(input); Assert.AreEqual(list, actual); }
private void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result) { var guid = request.Path; // Get document info var documentInfo = _imageHandler.GetDocumentInfo(guid); // Serialize document info SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions) .Serialize(); // Build result result.documentDescription = documentInfoJson; result.docType = documentInfo.DocumentType; result.fileType = documentInfo.FileType; int[] pageNumbers = documentInfo.Pages.Select(_ => _.Number).ToArray(); result.imageUrls = ImageUrlHelper.GetImageUrls(GetApplicationHost(), pageNumbers, request); }
private async void OnSerializeDataGrid(object sender, RoutedEventArgs e) { var folder = ApplicationData.Current.LocalFolder; try { var storageFile = await folder.CreateFileAsync("DataGrid.xml", CreationCollisionOption.ReplaceExisting); var options = new SerializationOptions() { SerializeColumns = (bool)this.SerializeColumns.IsChecked, SerializeFiltering = (bool)this.SerializeFiltering.IsChecked, SerializeGrouping = (bool)this.SerializeGrouping.IsChecked, SerializeSorting = (bool)this.SerializeSorting.IsChecked, SerializeGroupSummaries = (bool)this.SerializeGroupSummaries.IsChecked, SerializeTableSummaries = (bool)this.SerializeTableSummaries.IsChecked, SerializeStackedHeaders = (bool)this.SerializeStackedHeaders.IsChecked }; this.sfGrid.Serialize(storageFile, options); } catch (Exception) { } }
private static void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result, string fileName) { var docInfo = _imageHandler.GetDocumentInfo(request.Path); var maxWidth = 0; var maxHeight = 0; foreach (var pageData in docInfo.Pages) { if (pageData.Height > maxHeight) { maxHeight = pageData.Height; maxWidth = pageData.Width; } } var fileData = new FileData { DateCreated = DateTime.Now, DateModified = docInfo.LastModificationDate, PageCount = docInfo.Pages.Count, Pages = docInfo.Pages, MaxWidth = maxWidth, MaxHeight = maxHeight }; int[] pageNumbers = new int[docInfo.Pages.Count]; for (int i = 0; i < docInfo.Pages.Count; i++) { pageNumbers[i] = docInfo.Pages[i].Number; } string applicationHost = GetApplicationHost(); var documentUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, request); string[] attachmentUrls = new string[0]; foreach (AttachmentBase attachment in docInfo.Attachments) { List <PageImage> pages = _imageHandler.GetPages(attachment); var attachmentInfo = _imageHandler.GetDocumentInfo(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name); fileData.PageCount += pages.Count; fileData.Pages.AddRange(attachmentInfo.Pages); ViewDocumentParameters attachmentResponse = request; attachmentResponse.Path = attachmentInfo.Guid; int[] attachmentPageNumbers = new int[pages.Count]; for (int i = 0; i < pages.Count; i++) { attachmentPageNumbers[i] = pages[i].PageNumber; } Array.Resize <string>(ref attachmentUrls, (attachmentUrls.Length + pages.Count)); string[] attachmentImagesUrls = new string[pages.Count]; attachmentImagesUrls = ImageUrlHelper.GetImageUrls(applicationHost, attachmentPageNumbers, attachmentResponse); attachmentImagesUrls.CopyTo(attachmentUrls, (attachmentUrls.Length - pages.Count)); } SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(docInfo, serializationOptions).Serialize(); result.documentDescription = documentInfoJson; result.docType = docInfo.DocumentType; result.fileType = docInfo.FileType; if (docInfo.Attachments.Count > 0) { var imagesUrls = new string[attachmentUrls.Length + documentUrls.Length]; documentUrls.CopyTo(imagesUrls, 0); attachmentUrls.CopyTo(imagesUrls, documentUrls.Length); result.imageUrls = imagesUrls; } else { result.imageUrls = documentUrls; } }
/// <summary> /// Internal constructor. /// </summary> /// <param name="opt"></param> protected XmlSerializer(SerializationOptions opt) { Options = opt; }
/// <summary> /// Serialize an object /// </summary> /// <typeparam name="T">Any reference type</typeparam> /// <param name="obj">Object to serialize</param> /// <param name="options">Serialization options</param> /// <returns>Byte array containing the serialized object</returns> public static byte[] Serialize <T>(T obj, SerializationOptions options) { return(Serializer.Serialize(obj, options)); }
public SerializationAttribute(SerializationOptions options) : this(options, DynamicDeserializationBehavior.UseDefaultValue) { }
public SerializerClientPipe(SerializationOptions options) { _options = options; }
public static string Serialize(object instance, Encoding encoding, SerializationOptions options) { bool omit_declaration = (options & SerializationOptions.OmitDeclaration) == SerializationOptions.OmitDeclaration; bool exclude_namespaces = (options & SerializationOptions.ExcludeNamespaces) == SerializationOptions.ExcludeNamespaces; string xml = null; XmlSerializer xs = new XmlSerializer(instance.GetType()); using (MemoryStream ms = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = encoding; settings.OmitXmlDeclaration = omit_declaration; XmlWriter xw = XmlTextWriter.Create(ms, settings); if (exclude_namespaces) { XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); namespaces.Add("", ""); xs.Serialize(xw, instance, namespaces); } else xs.Serialize(xw, instance); ms.Flush(); xml = encoding.GetString(ms.ToArray()); ms.Close(); } return xml; }
public static object Deserialize(Type objectType, Stream msgPackInput, SerializationOptions options) { return(Deserialize(objectType, msgPackInput, CreateDefaultContext(options))); }
private IObjectGraphVisitor CreateEmittingVisitor(Emitter emitter, SerializationOptions options, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, object graph, Type type) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, converters); if ((options & SerializationOptions.DisableAliases) == 0) { var anchorAssigner = new AnchorAssigner(); traversalStrategy.Traverse(graph, type, anchorAssigner); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if ((options & SerializationOptions.EmitDefaults) == 0) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return emittingVisitor; }
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="emitter">The <see cref="Emitter" /> where to serialize the object.</param> /// <param name="graph">The object to serialize.</param> /// <param name="type">The static type of the object to serialize.</param> /// <param name="options">Options that control how the serialization is to be performed.</param> public void Serialize(Emitter emitter, object graph, Type type, SerializationOptions options = SerializationOptions.None) { if (emitter == null) { throw new ArgumentNullException("emitter"); } if (type == null) { throw new ArgumentNullException("type"); } var traversalStrategy = CreateTraversalStrategy(options); var eventEmitter = CreateEventEmitter(emitter, options); var emittingVisitor = CreateEmittingVisitor(emitter, options, traversalStrategy, eventEmitter, graph, type); EmitDocument(emitter, traversalStrategy, emittingVisitor, graph, type); }
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="emitter">The <see cref="Emitter" /> where to serialize the object.</param> /// <param name="graph">The object to serialize.</param> /// <param name="options">Options that control how the serialization is to be performed.</param> public void Serialize(Emitter emitter, object graph, SerializationOptions options = SerializationOptions.None) { Serialize(emitter, graph, graph != null ? graph.GetType() : typeof(object), options); }
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="writer">The <see cref="TextWriter" /> where to serialize the object.</param> /// <param name="graph">The object to serialize.</param> /// <param name="type">The static type of the object to serialize.</param> /// <param name="options">Options that control how the serialization is to be performed.</param> public void Serialize(TextWriter writer, object graph, Type type, SerializationOptions options = SerializationOptions.None) { Serialize(new Emitter(writer), graph, type, options); }
protected abstract void WriteXml(XmlWriter writer, bool withChildren, SerializationOptions options);
private bool IsOptionSet(SerializationOptions option) { return((options & option) != 0); }
private IEventEmitter CreateEventEmitter(Emitter emitter, SerializationOptions options) { var writer = new WriterEventEmitter(emitter); if ((options & SerializationOptions.JsonCompatible) != 0) { return new JsonEventEmitter(writer); } else { return new TypeAssigningEventEmitter(writer); } }
private IObjectGraphTraversalStrategy CreateTraversalStrategy(SerializationOptions options) { if ((options & SerializationOptions.Roundtrip) != 0) { return new RoundtripObjectGraphTraversalStrategy(50); } else { return new FullObjectGraphTraversalStrategy(50); } }
public ExRelationSerializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null) : base(options, namingConvention) { }
protected override void WriteXml(XmlWriter writer, string queryFilter, QuerySettings querySettings, SerializationOptions options) { WriteXml(writer, false, options); }
internal static string Validate(this Type @this, SerializationOptions options, NameGenerator generator) { if (@this.IsSealed && [email protected]() .Where(_ => _.GetParameters().Length == 1 && typeof(ReadOnlyDictionary<int, ReadOnlyCollection<HandlerInformation>>).IsAssignableFrom(_.GetParameters()[0].ParameterType)).Any()) { return ErrorMessages.GetCannotMockSealedType(@this.GetSafeName()); } if (options == SerializationOptions.Supported && [email protected] && @this.GetConstructor(Type.EmptyTypes) == null) { return ErrorMessages.GetCannotMockTypeWithSerializationRequestedAndNoPublicNoArgumentConstructor(@this.GetSafeName()); } if (@this.IsAbstract && (@this.GetConstructors(ReflectionValues.NonPublicInstance).Where(_ => _.IsAssembly).Any() || @this.GetMethods(ReflectionValues.NonPublicInstance).Where(_ => _.IsAssembly && _.IsAbstract).Any() || @this.GetProperties(ReflectionValues.NonPublicInstance).Where(_ => _.GetDefaultMethod().IsAssembly && _.GetDefaultMethod().IsAbstract).Any() || @this.GetEvents(ReflectionValues.NonPublicInstance).Where(_ => _.AddMethod.IsAssembly && _.AddMethod.IsAbstract).Any())) { if ([email protected](false, false, false, false, generator)) { return ErrorMessages.GetCannotMockTypeWithInternalAbstractMembers(@this.GetSafeName()); } } if([email protected] && @this.GetMockableConstructors(generator).Count == 0) { return ErrorMessages.GetCannotMockTypeWithNoAccessibleConstructors(@this.GetSafeName()); } return string.Empty; }
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="writer">The <see cref="TextWriter" /> where to serialize the object.</param> /// <param name="graph">The object to serialize.</param> /// <param name="options">Options that control how the serialization is to be performed.</param> public void Serialize(TextWriter writer, object graph, SerializationOptions options = SerializationOptions.None) { Serialize(new Emitter(writer), graph, options); }
public static object Deserialize(Type objectType, Stream jsonStream, SerializationOptions options, Encoding encoding) { return(Deserialize(objectType, jsonStream, CreateDefaultContext(options, encoding))); }
protected abstract void WriteXml(XmlWriter writer, string queryFilter, QuerySettings querySettings, SerializationOptions options);
/// <summary> /// Serializes the specified object. /// </summary> /// <param name="emitter">The <see cref="Emitter" /> where to serialize the object.</param> /// <param name="graph">The object to serialize.</param> /// <param name="options">Options that control how the serialization is to be performed.</param> public void Serialize(Emitter emitter, object graph, SerializationOptions options = SerializationOptions.None) { Serialize(emitter, graph, graph != null ? graph.GetType() : typeof(object), options); }
public static object Deserialize(Type objectType, TextReader textReader, SerializationOptions options) { return(Deserialize(objectType, textReader, CreateDefaultContext(options))); }
private bool HasOption(SerializationOptions option) { return((_options & option) == option); }
public static object Deserialize(Type objectType, string jsonString, SerializationOptions options) { return(Deserialize(objectType, jsonString, CreateDefaultContext(options))); }
private static void AppendMembers(StringBuilder text, IConceptInfo ci, SerializationOptions serializationOptions, bool exceptionOnNullMember = false, Type asBaseConceptType = null) { IEnumerable<ConceptMember> members = ConceptMembers.Get(asBaseConceptType ?? ci.GetType()); if (serializationOptions == SerializationOptions.KeyMembers) members = members.Where(member => member.IsKey); bool firstMember = true; foreach (ConceptMember member in members) { string separator = member.IsKey ? "." : " "; if (!firstMember) text.Append(separator); firstMember = false; AppendMember(text, ci, member, exceptionOnNullMember); } }
public static T Deserialize <T>(Stream jsonStream, SerializationOptions options, Encoding encoding) { return((T)Deserialize(typeof(T), jsonStream, CreateDefaultContext(options, encoding))); }
public void TransformPropertyOnSerializationTest() { var serializer = new JsonSerializer(); var person = new { name = "Sue", age = 5 }; var transformAge = new PropertyTransformation( /*name*/ "age", /*transform*/ (age) => { return (int)age * 2; } ); var options = new SerializationOptions { Include = new[] { "age" }, Transformations = new[] { transformAge } }; var doc = serializer.Serialize(person, options); Assert.Equal(@"{ ""age"": 10 }", doc.ToString()); }
public static T Deserialize <T>(TextReader textReader, SerializationOptions options) { return((T)Deserialize(typeof(T), textReader, CreateDefaultContext(options))); }
private static void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result, string fileName) { var htmlHandler = (ViewerHtmlHandler)HttpContext.Current.Session["htmlHandler"]; var docInfo = htmlHandler.GetDocumentInfo(request.Path); var maxWidth = 0; var maxHeight = 0; foreach (var pageData in docInfo.Pages) { if (pageData.Height > maxHeight) { maxHeight = pageData.Height; maxWidth = pageData.Width; } } var fileData = new FileData { DateCreated = DateTime.Now, DateModified = docInfo.LastModificationDate, PageCount = docInfo.Pages.Count, Pages = docInfo.Pages, MaxWidth = maxWidth, MaxHeight = maxHeight }; var htmlOptions = new HtmlOptions { // IsResourcesEmbedded = Utils.IsImage(fileName), IsResourcesEmbedded = false, HtmlResourcePrefix = string.Format("/GetResourceForHtml.aspx?documentPath={0}", fileName) + "&pageNumber={page-number}&resourceName=", }; if (request.PreloadPagesCount.HasValue && request.PreloadPagesCount.Value > 0) { htmlOptions.PageNumber = 1; htmlOptions.CountPagesToRender = request.PreloadPagesCount.Value; } List <string> cssList; var htmlPages = GetHtmlPages(fileName, fileName, htmlOptions, out cssList); foreach (AttachmentBase attachment in docInfo.Attachments) { var attachmentPath = _tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name; var attachmentResourcePath = HttpUtility.UrlEncode(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name.Replace(".", "_")); var attachmentHtmlOptions = new HtmlOptions() { IsResourcesEmbedded = Utils.IsImage(fileName), HtmlResourcePrefix = string.Format("/GetResourceForHtml.aspx?documentPath={0}", HttpUtility.UrlEncode(attachmentPath)) + "&pageNumber={page-number}&resourceName=", }; List <PageHtml> pages = _htmlHandler.GetPages(attachment, attachmentHtmlOptions); var attachmentInfo = _htmlHandler.GetDocumentInfo(attachmentPath); fileData.PageCount += attachmentInfo.Pages.Count; fileData.Pages.AddRange(attachmentInfo.Pages); List <string> attachmentCSSList; var attachmentPages = GetHtmlPages(attachmentPath, attachmentResourcePath, attachmentHtmlOptions, out attachmentCSSList); cssList.AddRange(attachmentCSSList); htmlPages.AddRange(attachmentPages); } SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(docInfo, serializationOptions).Serialize(); result.documentDescription = documentInfoJson; result.docType = docInfo.DocumentType; result.fileType = docInfo.FileType; result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray(); result.pageCss = new[] { string.Join(" ", cssList) }; }
public static T Deserialize <T>(string jsonString, SerializationOptions options) { return((T)Deserialize(typeof(T), jsonString, CreateDefaultContext(options))); }
protected override void WriteXml(XmlWriter writer, string referenceMemberName, SerializationOptions options) { WriteXml(writer, false, options); }
protected abstract void WriteXml(XmlWriter writer, bool withChildren, SerializationOptions options);
public static void Serialize <T>(T objectToSerialize, Stream msgPackOutput, SerializationOptions options) { Serialize(objectToSerialize, msgPackOutput, CreateDefaultContext(options)); }
protected abstract void WriteXml(XmlWriter writer, string referenceMemberName, SerializationOptions options);
public static T Deserialize <T>(Stream msgPackInput, SerializationOptions options) { return(Deserialize <T>(msgPackInput, CreateDefaultContext(options))); }
public Stream GetXml(string queryFilter, QuerySettings querySettings, SerializationOptions options = null) { return(GetXml(true, queryFilter, querySettings, options)); }
private bool IsOptionSet(SerializationOptions option) { return (options & option) != 0; }
public static string ToYamlString( this object obj, SerializationOptions options = SerializationOptions.None ) { return MakeYamlString( obj, options ); }
protected abstract void WriteXml(XmlWriter writer, string queryFilter, QuerySettings querySettings, SerializationOptions options);
public BackwardsCompatibleConfiguration(SerializationOptions options, INamingConvention namingConvention, YamlAttributeOverrides overrides) { this.options = options; this.namingConvention = namingConvention ?? new NullNamingConvention(); this.overrides = overrides; Converters = new List<IYamlTypeConverter>(); Converters.Add(new GuidConverter(IsOptionSet(SerializationOptions.JsonCompatible))); typeResolver = IsOptionSet(SerializationOptions.DefaultToStaticType) ? (ITypeResolver)new StaticTypeResolver() : (ITypeResolver)new DynamicTypeResolver(); }
public Stream GetXml(bool withChildren, SerializationOptions options = null) { return(GetXml(withChildren, null, null, options)); }
public bool IsOptionSet(SerializationOptions option) { return (options & option) != 0; }
private Stream GetXml(bool withChildren, string queryFilter, QuerySettings querySettings, SerializationOptions options) { if (options == null) { options = SerializationOptions.Default; } var stream = new MemoryStream(); var writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true }); writer.WriteStartDocument(); //if a filter or query settings is present, we have to filter children if (!string.IsNullOrEmpty(queryFilter) || querySettings != null) { WriteXml(writer, queryFilter, querySettings, options); } else { WriteXml(writer, withChildren, options); } writer.Flush(); stream.Position = 0; return(stream); }
public Serializer(SerializationOptions options = SerializationOptions.None, INamingConvention namingConvention = null, YamlAttributeOverrides overrides = null) { backwardsCompatibleConfiguration = new BackwardsCompatibleConfiguration(options, namingConvention, overrides); }