public virtual void Add(string key, PersonalizationEntry value) { key = StringUtil.CheckAndTrimString(key, "key"); if (value == null) { throw new ArgumentNullException("value"); } _dictionary.Add(key, value); }
public virtual void Add(string key, PersonalizationEntry value) { key = StringUtil.CheckAndTrimString(key, "key"); if (value == null) { throw new ArgumentNullException("value"); } this._dictionary.Add(key, value); }
private void LoadDynamicWebParts(PersonalizationEntry entry) { if (entry != null) { object[] objArray = (object[]) entry.Value; if (objArray != null) { bool isShared = entry.Scope == PersonalizationScope.Shared; for (int i = 0; i < objArray.Length; i += 4) { string id = (string) objArray[i]; string typeName = (string) objArray[i + 1]; string path = (string) objArray[i + 2]; string genericWebPartID = (string) objArray[i + 3]; this.LoadDynamicWebPart(id, typeName, path, genericWebPartID, isShared); } } } }
private void LoadDynamicConnections(PersonalizationEntry entry) { if (entry != null) { object[] objArray = (object[]) entry.Value; if (objArray != null) { for (int i = 0; i < objArray.Length; i += 7) { string str = (string) objArray[i]; string str2 = (string) objArray[i + 1]; string str3 = (string) objArray[i + 2]; string str4 = (string) objArray[i + 3]; string str5 = (string) objArray[i + 4]; WebPartConnection connection = new WebPartConnection { ID = str, ConsumerID = str2, ConsumerConnectionPointID = str3, ProviderID = str4, ProviderConnectionPointID = str5 }; this.Internals.SetIsShared(connection, entry.Scope == PersonalizationScope.Shared); this.Internals.SetIsStatic(connection, false); Type type = objArray[i + 5] as Type; if (type != null) { if (!type.IsSubclassOf(typeof(WebPartTransformer))) { throw new InvalidOperationException(System.Web.SR.GetString("WebPartTransformerAttribute_NotTransformer", new object[] { type.Name })); } object savedState = objArray[i + 6]; WebPartTransformer transformer = (WebPartTransformer) this.Internals.CreateObjectFromType(type); this.Internals.LoadConfigurationState(transformer, savedState); this.Internals.SetTransformer(connection, transformer); } this.DynamicConnections.Add(connection); } } } }
private void LoadDeletedConnectionState(PersonalizationEntry entry) { if (entry != null) { string[] strArray = (string[]) entry.Value; if (strArray != null) { for (int i = 0; i < strArray.Length; i++) { string b = strArray[i]; WebPartConnection connection = null; foreach (WebPartConnection connection2 in this.StaticConnections) { if (string.Equals(connection2.ID, b, StringComparison.OrdinalIgnoreCase)) { connection = connection2; break; } } if (connection == null) { foreach (WebPartConnection connection3 in this.DynamicConnections) { if (string.Equals(connection3.ID, b, StringComparison.OrdinalIgnoreCase)) { connection = connection3; break; } } } if (connection != null) { this.Internals.DeleteConnection(connection); } else { this._hasDataChanged = true; } } } } }
/// <devdoc> /// Deserializes personalization data packed as a blob of binary data /// into a dictionary with personalization IDs mapped to /// PersonalizationInfo objects. /// </devdoc> private static IDictionary DeserializeData(byte[] data) { IDictionary deserializedData = null; if ((data != null) && (data.Length > 0)) { Exception deserializationException = null; int version = -1; object[] items = null; int offset = 0; // Deserialize the data try { ObjectStateFormatter formatter = new ObjectStateFormatter(null /* Page(used to determine encryption mode) */, false /*throwOnErrorDeserializing*/); if (!HttpRuntime.DisableProcessRequestInApplicationTrust) { // This is more of a consistency and defense-in-depth fix. Currently we believe // only user code or code with restricted permissions will be running on the stack. // However, to mirror the fix for Session State, and also to hedge against future // scenarios where our current assumptions may change, we should restrict the running // thread to only the permission set currently defined for the app domain. // VSWhidbey 427533 if (HttpRuntime.NamedPermissionSet != null && HttpRuntime.ProcessRequestInApplicationTrust) { HttpRuntime.NamedPermissionSet.PermitOnly(); } } items = (object[])formatter.DeserializeWithAssert(new MemoryStream(data)); if (items != null && items.Length != 0) { version = (int)items[offset++]; } } catch (Exception e) { deserializationException = e; } if (version == (int)PersonalizationVersions.WhidbeyBeta2 || version == (int)PersonalizationVersions.WhidbeyRTM) { try { // Build up the dictionary of PersonalizationInfo objects int infoListCount = (int)items[offset++]; if (infoListCount > 0) { deserializedData = new HybridDictionary(infoListCount, /* caseInsensitive */ false); } for (int i = 0; i < infoListCount; i++) { string controlID; bool isStatic; Type controlType = null; VirtualPath controlVPath = null; // If this is a dynamic WebPart or control, the Type is not saved in personalization, // so the first item is the controlID. If this is a static WebPart or control, the // first item is the control Type. object item = items[offset++]; if (item is string) { controlID = (string)item; isStatic = false; } else { controlType = (Type)item; if (controlType == typeof(UserControl)) { controlVPath = VirtualPath.CreateNonRelativeAllowNull((string)items[offset++]); } controlID = (string)items[offset++]; isStatic = true; } IDictionary properties = null; int propertyCount = (int)items[offset++]; if (propertyCount > 0) { properties = new HybridDictionary(propertyCount, /* caseInsensitive */ false); for (int j = 0; j < propertyCount; j++) { string propertyName = ((IndexedString)items[offset++]).Value; object propertyValue = items[offset++]; properties[propertyName] = propertyValue; } } PersonalizationDictionary customProperties = null; int customPropertyCount = (int)items[offset++]; if (customPropertyCount > 0) { customProperties = new PersonalizationDictionary(customPropertyCount); for (int j = 0; j < customPropertyCount; j++) { string propertyName = ((IndexedString)items[offset++]).Value; object propertyValue = items[offset++]; PersonalizationScope propertyScope = (bool)items[offset++] ? PersonalizationScope.Shared : PersonalizationScope.User; bool isSensitive = false; if (version == (int)PersonalizationVersions.WhidbeyRTM) { isSensitive = (bool)items[offset++]; } customProperties[propertyName] = new PersonalizationEntry(propertyValue, propertyScope, isSensitive); } } PersonalizationInfo info = new PersonalizationInfo(); info._controlID = controlID; info._controlType = controlType; info._controlVPath = controlVPath; info._isStatic = isStatic; info._properties = properties; info._customProperties = customProperties; deserializedData[controlID] = info; } } catch (Exception e) { deserializationException = e; } } // Check that there was no deserialization error, and that // the data conforms to our known version if ((deserializationException != null) || (version != (int)PersonalizationVersions.WhidbeyBeta2 && version != (int)PersonalizationVersions.WhidbeyRTM)) { throw new ArgumentException(SR.GetString(SR.BlobPersonalizationState_DeserializeError), "data", deserializationException); } } if (deserializedData == null) { deserializedData = new HybridDictionary(/* caseInsensitive */ false); } return deserializedData; }
protected virtual void SaveCustomPersonalizationState(PersonalizationDictionary state) { PersonalizationScope scope = Personalization.Scope; int webPartsCount = Controls.Count; if (webPartsCount > 0) { object[] webPartState = new object[webPartsCount * 4]; for (int i=0; i < webPartsCount; i++) { WebPart webPart = (WebPart)Controls[i]; webPartState[4*i] = webPart.ID; webPartState[4*i + 1] = Internals.GetZoneID(webPart); webPartState[4*i + 2] = webPart.ZoneIndex; webPartState[4*i + 3] = webPart.IsClosed; } if (scope == PersonalizationScope.Shared) { state["WebPartStateShared"] = new PersonalizationEntry(webPartState, PersonalizationScope.Shared); } else { state["WebPartStateUser"] = new PersonalizationEntry(webPartState, PersonalizationScope.User); } } // Select only the dynamic WebParts that should be saved for this mode ArrayList dynamicWebParts = new ArrayList(); foreach (WebPart webPart in Controls) { if (!webPart.IsStatic && ((scope == PersonalizationScope.User && !webPart.IsShared) || (scope == PersonalizationScope.Shared && webPart.IsShared))) { dynamicWebParts.Add(webPart); } } int dynamicWebPartsCount = dynamicWebParts.Count; if (dynamicWebPartsCount > 0) { // Use a 1-dimensional array for smallest storage space object[] dynamicWebPartState = new object[dynamicWebPartsCount * 4]; for (int i = 0; i < dynamicWebPartsCount; i++) { WebPart webPart = (WebPart)dynamicWebParts[i]; string id; string typeName; string path = null; string genericWebPartID = null; ProxyWebPart proxyWebPart = webPart as ProxyWebPart; if (proxyWebPart != null) { id = proxyWebPart.OriginalID; typeName = proxyWebPart.OriginalTypeName; path = proxyWebPart.OriginalPath; genericWebPartID = proxyWebPart.GenericWebPartID; } else { GenericWebPart genericWebPart = webPart as GenericWebPart; if (genericWebPart != null) { Control childControl = genericWebPart.ChildControl; UserControl userControl = childControl as UserControl; id = childControl.ID; if (userControl != null) { typeName = WebPartUtil.SerializeType(typeof(UserControl)); path = userControl.AppRelativeVirtualPath; } else { typeName = WebPartUtil.SerializeType(childControl.GetType()); } genericWebPartID = genericWebPart.ID; } else { id = webPart.ID; typeName = WebPartUtil.SerializeType(webPart.GetType()); } } dynamicWebPartState[4*i] = id; dynamicWebPartState[4*i + 1] = typeName; if (!String.IsNullOrEmpty(path)) { dynamicWebPartState[4*i + 2] = path; } if (!String.IsNullOrEmpty(genericWebPartID)) { dynamicWebPartState[4*i + 3] = genericWebPartID; } } if (scope == PersonalizationScope.Shared) { state["DynamicWebPartsShared"] = new PersonalizationEntry(dynamicWebPartState, PersonalizationScope.Shared); } else { state["DynamicWebPartsUser"] = new PersonalizationEntry(dynamicWebPartState, PersonalizationScope.User); } } // Save deleted connections // ArrayList deletedConnections = new ArrayList(); // PERF: Use the StaticConnections and DynamicConnections collections separately, instead // of using the Connections property which is created on every call. foreach (WebPartConnection connection in StaticConnections) { if (Internals.ConnectionDeleted(connection)) { deletedConnections.Add(connection); } } foreach (WebPartConnection connection in DynamicConnections) { if (Internals.ConnectionDeleted(connection)) { deletedConnections.Add(connection); } } int deletedConnectionsCount = deletedConnections.Count; if (deletedConnections.Count > 0) { string[] deletedConnectionsState = new string[deletedConnectionsCount]; for (int i=0; i < deletedConnectionsCount; i++) { WebPartConnection deletedConnection = (WebPartConnection)deletedConnections[i]; // Only shared connections can be deleted Debug.Assert(deletedConnection.IsShared); // In shared scope, only static connections should be deleted // In user scope, static and dynamic connections can be deleted Debug.Assert(deletedConnection.IsStatic || scope == PersonalizationScope.User); deletedConnectionsState[i] = deletedConnection.ID; } if (scope == PersonalizationScope.Shared) { state["DeletedConnectionsShared"] = new PersonalizationEntry(deletedConnectionsState, PersonalizationScope.Shared); } else { state["DeletedConnectionsUser"] = new PersonalizationEntry(deletedConnectionsState, PersonalizationScope.User); } } // Select only the dynamic Connections that should be saved for this mode ArrayList dynamicConnections = new ArrayList(); foreach (WebPartConnection connection in DynamicConnections) { if (((scope == PersonalizationScope.User) && (!connection.IsShared)) || ((scope == PersonalizationScope.Shared) && (connection.IsShared))) { dynamicConnections.Add(connection); } } int dynamicConnectionsCount = dynamicConnections.Count; if (dynamicConnectionsCount > 0) { // Use a 1-dimensional array for smallest storage space object[] dynamicConnectionState = new object[dynamicConnectionsCount * 7]; for (int i = 0; i < dynamicConnectionsCount; i++) { WebPartConnection connection = (WebPartConnection)dynamicConnections[i]; WebPartTransformer transformer = connection.Transformer; // We should never be saving a deleted dynamic connection. If the User has deleted a // a shared connection, the connection will be saved in the Shared data, not here. Debug.Assert(!Internals.ConnectionDeleted(connection)); dynamicConnectionState[7*i] = connection.ID; dynamicConnectionState[7*i + 1] = connection.ConsumerID; dynamicConnectionState[7*i + 2] = connection.ConsumerConnectionPointID; dynamicConnectionState[7*i + 3] = connection.ProviderID; dynamicConnectionState[7*i + 4] = connection.ProviderConnectionPointID; if (transformer != null) { dynamicConnectionState[7*i + 5] = transformer.GetType(); dynamicConnectionState[7*i + 6] = Internals.SaveConfigurationState(transformer); } } if (scope == PersonalizationScope.Shared) { state["DynamicConnectionsShared"] = new PersonalizationEntry(dynamicConnectionState, PersonalizationScope.Shared); } else { state["DynamicConnectionsUser"] = new PersonalizationEntry(dynamicConnectionState, PersonalizationScope.User); } } }
public virtual new void Add(string key, PersonalizationEntry value) { }
private void LoadDeletedConnectionState(PersonalizationEntry entry) { if (entry != null) { string[] deletedConnections = (string[])entry.Value; if (deletedConnections != null) { for (int i=0; i < deletedConnections.Length; i++) { string idToDelete = deletedConnections[i]; WebPartConnection connectionToDelete = null; foreach (WebPartConnection connection in StaticConnections) { if (String.Equals(connection.ID, idToDelete, StringComparison.OrdinalIgnoreCase)) { connectionToDelete = connection; break; } } if (connectionToDelete == null) { foreach (WebPartConnection connection in DynamicConnections) { if (String.Equals(connection.ID, idToDelete, StringComparison.OrdinalIgnoreCase)) { connectionToDelete = connection; break; } } } if (connectionToDelete != null) { // Only shared connections can be deleted Debug.Assert(connectionToDelete.IsShared); // In shared scope, only static connections should be deleted // In user scope, static and dynamic connections can be deleted Debug.Assert(connectionToDelete.IsStatic || entry.Scope == PersonalizationScope.User); Internals.DeleteConnection(connectionToDelete); } else { // Some of the personalization data is invalid, so we should mark ourselves // as dirty so the data will be re-saved, and the invalid data will be removed. _hasDataChanged = true; } } } } }
private void LoadDynamicWebParts(PersonalizationEntry entry) { if (entry != null) { object[] dynamicWebPartState = (object[])entry.Value; if (dynamicWebPartState != null) { Debug.Assert(dynamicWebPartState.Length % 4 == 0); bool isShared = (entry.Scope == PersonalizationScope.Shared); // for (int i = 0; i < dynamicWebPartState.Length; i += 4) { string id = (string)dynamicWebPartState[i]; string typeName = (string)dynamicWebPartState[i + 1]; string path = (string)dynamicWebPartState[i + 2]; string genericWebPartID = (string)dynamicWebPartState[i + 3]; LoadDynamicWebPart(id, typeName, path, genericWebPartID, isShared); } } } }
private void LoadDynamicConnections(PersonalizationEntry entry) { if (entry != null) { object[] dynamicConnectionState = (object[])entry.Value; if (dynamicConnectionState != null) { Debug.Assert(dynamicConnectionState.Length % 7 == 0); for (int i = 0; i < dynamicConnectionState.Length; i += 7) { string ID = (string)dynamicConnectionState[i]; string consumerID = (string)dynamicConnectionState[i + 1]; string consumerConnectionPointID = (string)dynamicConnectionState[i + 2]; string providerID = (string)dynamicConnectionState[i + 3]; string providerConnectionPointID = (string)dynamicConnectionState[i + 4]; // Add a new connection to the collection WebPartConnection connection = new WebPartConnection(); connection.ID = ID; connection.ConsumerID = consumerID; connection.ConsumerConnectionPointID = consumerConnectionPointID; connection.ProviderID = providerID; connection.ProviderConnectionPointID = providerConnectionPointID; Internals.SetIsShared(connection, (entry.Scope == PersonalizationScope.Shared)); Internals.SetIsStatic(connection, false); Type type = dynamicConnectionState[i + 5] as Type; if (type != null) { // SECURITY: Only instantiate type if it is a subclass of WebPartTransformer if (type.IsSubclassOf(typeof(WebPartTransformer))) { object configuration = dynamicConnectionState[i + 6]; WebPartTransformer transformer = (WebPartTransformer)Internals.CreateObjectFromType(type); Internals.LoadConfigurationState(transformer, configuration); Internals.SetTransformer(connection, transformer); } else { throw new InvalidOperationException(SR.GetString(SR.WebPartTransformerAttribute_NotTransformer, type.Name)); } } DynamicConnections.Add(connection); } } } }
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()); }
private static IDictionary DeserializeData(byte[] data) { IDictionary dictionary = null; if ((data != null) && (data.Length > 0)) { Exception innerException = null; int num = -1; object[] objArray = null; int num2 = 0; try { ObjectStateFormatter formatter = new ObjectStateFormatter(null, false); if ((!HttpRuntime.DisableProcessRequestInApplicationTrust && (HttpRuntime.NamedPermissionSet != null)) && HttpRuntime.ProcessRequestInApplicationTrust) { HttpRuntime.NamedPermissionSet.PermitOnly(); } objArray = (object[])formatter.DeserializeWithAssert(new MemoryStream(data)); if ((objArray != null) && (objArray.Length != 0)) { num = (int)objArray[num2++]; } } catch (Exception exception2) { innerException = exception2; } switch (num) { case 1: case 2: try { int initialSize = (int)objArray[num2++]; if (initialSize > 0) { dictionary = new HybridDictionary(initialSize, false); } for (int i = 0; i < initialSize; i++) { string str; bool flag; Type type = null; VirtualPath path = null; object obj2 = objArray[num2++]; if (obj2 is string) { str = (string)obj2; flag = false; } else { type = (Type)obj2; if (type == typeof(UserControl)) { path = VirtualPath.CreateNonRelativeAllowNull((string)objArray[num2++]); } str = (string)objArray[num2++]; flag = true; } IDictionary dictionary2 = null; int num5 = (int)objArray[num2++]; if (num5 > 0) { dictionary2 = new HybridDictionary(num5, false); for (int j = 0; j < num5; j++) { string str2 = ((IndexedString)objArray[num2++]).Value; object obj3 = objArray[num2++]; dictionary2[str2] = obj3; } } PersonalizationDictionary dictionary3 = null; int num7 = (int)objArray[num2++]; if (num7 > 0) { dictionary3 = new PersonalizationDictionary(num7); for (int k = 0; k < num7; k++) { string str3 = ((IndexedString)objArray[num2++]).Value; object obj4 = objArray[num2++]; System.Web.UI.WebControls.WebParts.PersonalizationScope scope = ((bool)objArray[num2++]) ? System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared : System.Web.UI.WebControls.WebParts.PersonalizationScope.User; bool isSensitive = false; if (num == 2) { isSensitive = (bool)objArray[num2++]; } dictionary3[str3] = new PersonalizationEntry(obj4, scope, isSensitive); } } PersonalizationInfo info = new PersonalizationInfo { _controlID = str, _controlType = type, _controlVPath = path, _isStatic = flag, _properties = dictionary2, _customProperties = dictionary3 }; dictionary[str] = info; } } catch (Exception exception3) { innerException = exception3; } break; } if ((innerException != null) || ((num != 1) && (num != 2))) { throw new ArgumentException(System.Web.SR.GetString("BlobPersonalizationState_DeserializeError"), "data", innerException); } } if (dictionary == null) { dictionary = new HybridDictionary(false); } return(dictionary); }
private void LoadWebPartState(PersonalizationEntry entry) { if (entry != null) { object[] objArray = (object[]) entry.Value; if (objArray != null) { for (int i = 0; i < objArray.Length; i += 4) { string id = (string) objArray[i]; string zoneID = (string) objArray[i + 1]; int zoneIndex = (int) objArray[i + 2]; bool isClosed = (bool) objArray[i + 3]; WebPart webPart = (WebPart) this.FindControl(id); if (webPart != null) { this.Internals.SetZoneID(webPart, zoneID); this.Internals.SetZoneIndex(webPart, zoneIndex); this.Internals.SetIsClosed(webPart, isClosed); } else { this._hasDataChanged = true; } } } } }
/// <devdoc> /// Sets the ZoneID, ZoneIndex, and IsClosed properties on the WebParts. The state /// was loaded from personalization. /// </devdoc> private void LoadWebPartState(PersonalizationEntry entry) { if (entry != null) { object[] webPartState = (object[])entry.Value; if (webPartState != null) { Debug.Assert(webPartState.Length % 4 == 0); for (int i=0; i < webPartState.Length; i += 4) { string id = (string)webPartState[i]; string zoneID = (string)webPartState[i + 1]; int zoneIndex = (int)webPartState[i + 2]; bool isClosed = (bool)webPartState[i + 3]; WebPart part = (WebPart)FindControl(id); if (part != null) { Internals.SetZoneID(part, zoneID); Internals.SetZoneIndex(part, zoneIndex); // Internals.SetIsClosed(part, isClosed); } else { // Some of the personalization data is invalid, so we should mark ourselves // as dirty so the data will be re-saved, and the invalid data will be removed. _hasDataChanged = true; } } } } }
protected virtual void SaveCustomPersonalizationState(PersonalizationDictionary state) { PersonalizationScope scope = this.Personalization.Scope; int count = this.Controls.Count; if (count > 0) { object[] objArray = new object[count * 4]; for (int i = 0; i < count; i++) { WebPart webPart = (WebPart) this.Controls[i]; objArray[4 * i] = webPart.ID; objArray[(4 * i) + 1] = this.Internals.GetZoneID(webPart); objArray[(4 * i) + 2] = webPart.ZoneIndex; objArray[(4 * i) + 3] = webPart.IsClosed; } if (scope == PersonalizationScope.Shared) { state["WebPartStateShared"] = new PersonalizationEntry(objArray, PersonalizationScope.Shared); } else { state["WebPartStateUser"] = new PersonalizationEntry(objArray, PersonalizationScope.User); } } ArrayList list = new ArrayList(); foreach (WebPart part2 in this.Controls) { if (!part2.IsStatic && (((scope == PersonalizationScope.User) && !part2.IsShared) || ((scope == PersonalizationScope.Shared) && part2.IsShared))) { list.Add(part2); } } int num3 = list.Count; if (num3 > 0) { object[] objArray2 = new object[num3 * 4]; for (int j = 0; j < num3; j++) { string originalID; string originalTypeName; WebPart part3 = (WebPart) list[j]; string originalPath = null; string genericWebPartID = null; ProxyWebPart part4 = part3 as ProxyWebPart; if (part4 != null) { originalID = part4.OriginalID; originalTypeName = part4.OriginalTypeName; originalPath = part4.OriginalPath; genericWebPartID = part4.GenericWebPartID; } else { GenericWebPart part5 = part3 as GenericWebPart; if (part5 != null) { Control childControl = part5.ChildControl; UserControl control2 = childControl as UserControl; originalID = childControl.ID; if (control2 != null) { originalTypeName = WebPartUtil.SerializeType(typeof(UserControl)); originalPath = control2.AppRelativeVirtualPath; } else { originalTypeName = WebPartUtil.SerializeType(childControl.GetType()); } genericWebPartID = part5.ID; } else { originalID = part3.ID; originalTypeName = WebPartUtil.SerializeType(part3.GetType()); } } objArray2[4 * j] = originalID; objArray2[(4 * j) + 1] = originalTypeName; if (!string.IsNullOrEmpty(originalPath)) { objArray2[(4 * j) + 2] = originalPath; } if (!string.IsNullOrEmpty(genericWebPartID)) { objArray2[(4 * j) + 3] = genericWebPartID; } } if (scope == PersonalizationScope.Shared) { state["DynamicWebPartsShared"] = new PersonalizationEntry(objArray2, PersonalizationScope.Shared); } else { state["DynamicWebPartsUser"] = new PersonalizationEntry(objArray2, PersonalizationScope.User); } } ArrayList list2 = new ArrayList(); foreach (WebPartConnection connection in this.StaticConnections) { if (this.Internals.ConnectionDeleted(connection)) { list2.Add(connection); } } foreach (WebPartConnection connection2 in this.DynamicConnections) { if (this.Internals.ConnectionDeleted(connection2)) { list2.Add(connection2); } } int num5 = list2.Count; if (list2.Count > 0) { string[] strArray = new string[num5]; for (int k = 0; k < num5; k++) { WebPartConnection connection3 = (WebPartConnection) list2[k]; strArray[k] = connection3.ID; } if (scope == PersonalizationScope.Shared) { state["DeletedConnectionsShared"] = new PersonalizationEntry(strArray, PersonalizationScope.Shared); } else { state["DeletedConnectionsUser"] = new PersonalizationEntry(strArray, PersonalizationScope.User); } } ArrayList list3 = new ArrayList(); foreach (WebPartConnection connection4 in this.DynamicConnections) { if (((scope == PersonalizationScope.User) && !connection4.IsShared) || ((scope == PersonalizationScope.Shared) && connection4.IsShared)) { list3.Add(connection4); } } int num7 = list3.Count; if (num7 > 0) { object[] objArray3 = new object[num7 * 7]; for (int m = 0; m < num7; m++) { WebPartConnection connection5 = (WebPartConnection) list3[m]; WebPartTransformer transformer = connection5.Transformer; objArray3[7 * m] = connection5.ID; objArray3[(7 * m) + 1] = connection5.ConsumerID; objArray3[(7 * m) + 2] = connection5.ConsumerConnectionPointID; objArray3[(7 * m) + 3] = connection5.ProviderID; objArray3[(7 * m) + 4] = connection5.ProviderConnectionPointID; if (transformer != null) { objArray3[(7 * m) + 5] = transformer.GetType(); objArray3[(7 * m) + 6] = this.Internals.SaveConfigurationState(transformer); } } if (scope == PersonalizationScope.Shared) { state["DynamicConnectionsShared"] = new PersonalizationEntry(objArray3, PersonalizationScope.Shared); } else { state["DynamicConnectionsUser"] = new PersonalizationEntry(objArray3, PersonalizationScope.User); } } }
public void FillPersonalizationDictionary(Control control, ICollection propertyInfos, PersonalizationDictionary personalizations) { foreach (PropertyInfo propertyInfo in propertyInfos) { PersonalizableAttribute attribute = (PersonalizableAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(PersonalizableAttribute)); PersonalizationEntry entry = new PersonalizationEntry(ReflectionServices.ExtractValue(control, propertyInfo.Name), attribute.Scope, attribute.IsSensitive); if (!personalizations.Contains(propertyInfo.Name)) personalizations.Add(propertyInfo.Name, entry); else personalizations[propertyInfo.Name] = entry; } }