private static byte[] SerializeData(IDictionary data) { byte[] buffer = null; if ((data == null) || (data.Count == 0)) { return(buffer); } ArrayList list = new ArrayList(); foreach (DictionaryEntry entry in data) { PersonalizationInfo info = (PersonalizationInfo)entry.Value; if (((info._properties != null) && (info._properties.Count != 0)) || ((info._customProperties != null) && (info._customProperties.Count != 0))) { list.Add(info); } } if (list.Count == 0) { return(buffer); } ArrayList list2 = new ArrayList(); list2.Add(2); list2.Add(list.Count); foreach (PersonalizationInfo info2 in list) { if (info2._isStatic) { list2.Add(info2._controlType); if (info2._controlVPath != null) { list2.Add(info2._controlVPath.AppRelativeVirtualPathString); } } list2.Add(info2._controlID); int count = 0; if (info2._properties != null) { count = info2._properties.Count; } list2.Add(count); if (count != 0) { foreach (DictionaryEntry entry2 in info2._properties) { list2.Add(new IndexedString((string)entry2.Key)); list2.Add(entry2.Value); } } int num2 = 0; if (info2._customProperties != null) { num2 = info2._customProperties.Count; } list2.Add(num2); if (num2 != 0) { foreach (DictionaryEntry entry3 in info2._customProperties) { list2.Add(new IndexedString((string)entry3.Key)); PersonalizationEntry entry4 = (PersonalizationEntry)entry3.Value; list2.Add(entry4.Value); list2.Add(entry4.Scope == System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared); list2.Add(entry4.IsSensitive); } } } if (list2.Count == 0) { return(buffer); } ObjectStateFormatter formatter = new ObjectStateFormatter(null, false); MemoryStream outputStream = new MemoryStream(0x400); object[] stateGraph = list2.ToArray(); if ((!HttpRuntime.DisableProcessRequestInApplicationTrust && (HttpRuntime.NamedPermissionSet != null)) && HttpRuntime.ProcessRequestInApplicationTrust) { HttpRuntime.NamedPermissionSet.PermitOnly(); } formatter.SerializeWithAssert(outputStream, stateGraph); return(outputStream.ToArray()); }