Exemplo n.º 1
0
        public string Serialize(PartialSettings partialSettings)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (XmlDictionaryWriter writer = System.Xml.XmlDictionaryWriter.CreateBinaryWriter(ms))
                {
                    try
                    {
                        _serialiser.WriteObject(writer, partialSettings);
                    }
                    catch (Exception e)
                    {
                        throw;
                    }
                    writer.Flush();
                    return(Convert.ToBase64String(ms.ToArray()));
                }

                //try
                //{
                //    _serialiser.WriteObject(ms, partialSettings);
                //}
                //catch (Exception e)
                //{
                //    throw;
                //}
                //return Convert.ToBase64String(ms.ToArray());
            }
        }
        private static string GetSerialisedPartialSettings(string partialViewName, object model, ViewDataDictionary viewData)
        {
            var partialSettings = new PartialSettings
            {
                PartialViewName = partialViewName,
                Model           = model,
                ModelTypeName   = viewData.Model.GetType().FullName
            };

            return(PartialSerializer.Serialize(partialSettings));
        }
Exemplo n.º 3
0
 public string Serialize(PartialSettings partialSettings)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         try
         {
             formatter.Serialize(ms, partialSettings);
         }
         catch (Exception e)
         {
             throw;
         }
         return(Convert.ToBase64String(ms.ToArray()));
     }
 }