Example #1
0
        public override void SavePersonalizationState(PersonalizationState state)
        {
            if (this.IsEnabled)
            {
                DictionaryPersonalizationState dictionaryState = state as DictionaryPersonalizationState;
                if (null == dictionaryState)
                {
                    throw new ArgumentException("state is not a DictionaryPersonalizationState");
                }

                if (!dictionaryState.ReadOnly)
                {
                    StringBuilder personalizationBuilder = new StringBuilder();
                    using (StringWriter stringWriter = new StringWriter(personalizationBuilder))
                    {
                        using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
                        {
                            writer.Formatting = Formatting.Indented;
                            writer.WriteStartDocument();
                            writer.WriteStartElement("personalization");
                            writer.WriteAttributeString("version", ReflectionServices.Version());
                            foreach (string id in dictionaryState.States.Keys)
                            {
                                if (dictionaryState.IsPartPresent(id))
                                {
                                    writer.WriteStartElement("part");
                                    writer.WriteAttributeString("id", id);
                                    foreach (string propertyName in dictionaryState.States[id].Keys)
                                    {
                                        writer.WriteStartElement("property");
                                        writer.WriteAttributeString("name", propertyName);
                                        writer.WriteStartAttribute("sensitive");
                                        writer.WriteValue(dictionaryState.States[id][propertyName].IsSensitive);
                                        writer.WriteEndAttribute();
                                        writer.WriteStartAttribute("scope");
                                        writer.WriteValue((int)dictionaryState.States[id][propertyName].Scope);
                                        writer.WriteEndAttribute();
                                        object value = dictionaryState.States[id][propertyName].Value;
                                        if (null != value)
                                        {
                                            writer.WriteStartElement("value");
                                            writer.WriteStartAttribute("type");
                                            writer.WriteValue(SerializationServices.ShortAssemblyQualifiedName(value.GetType().AssemblyQualifiedName));
                                            writer.WriteEndAttribute();
                                            SerializationServices.Serialize(value, writer);
                                            writer.WriteEndElement();
                                        }
                                        writer.WriteEndElement();
                                    }
                                    writer.WriteEndElement();
                                }
                            }
                            writer.WriteEndElement();
                            writer.WriteEndDocument();
                        }
                    }
                    PersonalizationStorage.Instance.Write(XmlPersonalizationProvider.StorageKey, personalizationBuilder.ToString());
                }
            }
        }
Example #2
0
 protected void Dump()
 {
     if (!_isDisabled && this.Records.Count > 0)
     {
         StringBuilder dump = new StringBuilder();
         using (XmlWriter writer = XmlWriter.Create(dump, new XmlWriterSettings
         {
             Indent = true
         }))
         {
             SerializationServices.Serialize(this, writer);
         }
         string timestamp = DateTime.Now.ToString("yyyyMMddHHmmssff");
         this.Entries[timestamp] = dump.ToString();
     }
 }
Example #3
0
        private static void TrySerializeException(Exception ex, RpcErrorExceptionInfo errorInfo)
        {
            Exception ex2 = null;

            try
            {
                errorInfo.SerializedException = SerializationServices.Serialize(ex);
            }
            catch (SerializationException ex3)
            {
                ex2 = ex3;
            }
            catch (TargetInvocationException ex4)
            {
                ex2 = ex4;
            }
            if (ex2 != null)
            {
                ExTraceGlobals.ReplayServiceRpcTracer.TraceError <Type, Exception>(0L, "ConvertExceptionToErrorExceptionInfo: Failed to serialize Exception of type '{0}'. Serialization Exception: {1}", ex.GetType(), ex2);
                errorInfo.ErrorMessage = ex.ToString();
            }
        }
Example #4
0
        // Token: 0x06001143 RID: 4419 RVA: 0x00046808 File Offset: 0x00044A08
        public void WriteHeader()
        {
            this.AssertWriteOperationValid();
            if (this.m_header.NumPagesToPatch > 3276800)
            {
                throw new PagePatchTooManyPagesToPatchException(this.m_header.NumPagesToPatch, 3276800);
            }
            byte[] array  = new byte[32768L];
            byte[] array2 = SerializationServices.Serialize(this.m_header);
            DiagCore.RetailAssert(array2.Length <= array.Length - 4, "Serialized header state in bytes ({0}) is greater than pre-allocated fixed byte size of {1} bytes.", new object[]
            {
                array2.Length,
                array.Length
            });
            int num = 0;

            Array.Copy(BitConverter.GetBytes(array2.Length), 0, array, num, 4);
            num += 4;
            Array.Copy(array2, 0, array, num, array2.Length);
            this.SeekToStart();
            this.m_fileStream.Write(array, 0, array.Length);
            this.m_fileStream.Flush(true);
        }
Example #5
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            Configuration configuration = value as Configuration;
            object        result;

            if (null != configuration)
            {
                if (destinationType == typeof(string))
                {
                    StringBuilder serializationBuilder = new StringBuilder();
                    using (StringWriter stringWriter = new StringWriter(serializationBuilder))
                    {
                        using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
                        {
                            SerializationServices.Serialize(configuration, writer);
                        }
                        result = serializationBuilder.ToString();
                        return(result);
                    }
                }
            }
            result = base.ConvertTo(context, culture, value, destinationType);
            return(result);
        }
 public static RpcGenericRequestInfo PrepareClientRequest(object attachedRequest, int commandId, int majorVersion, int minorVersion)
 {
     byte[] attachedData = SerializationServices.Serialize(attachedRequest);
     return(new RpcGenericRequestInfo(ActiveManagerGenericRpcHelper.LocalServerVersion, commandId, majorVersion, minorVersion, attachedData));
 }
 public static RpcGenericReplyInfo PrepareServerReply(RpcGenericRequestInfo request, object attachedReply, int majorVersion, int minorVersion)
 {
     byte[] attachedData = SerializationServices.Serialize(attachedReply);
     return(new RpcGenericReplyInfo(ActiveManagerGenericRpcHelper.LocalServerVersion, request.CommandId, majorVersion, minorVersion, attachedData));
 }