public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object result; if (value is string) { string serialization = value as string; Configuration configuration = new Configuration(); if (!string.IsNullOrEmpty(serialization)) { using (StringReader stringReader = new StringReader((string)value)) { using (XmlTextReader reader = new XmlTextReader(stringReader)) { reader.Read(); SerializationServices.Deserialize(configuration.GetType(), reader, false); } } } result = configuration; } else { result = base.ConvertFrom(context, culture, value); } return(result); }
public static T ValidateAndGetAttachedRequest <T>(RpcGenericRequestInfo requestInfo, int majorVersion, int minorVersion) where T : class { if (requestInfo.CommandMajorVersion > majorVersion) { throw new ActiveManagerGenericRpcVersionNotSupportedException(requestInfo.ServerVersion, requestInfo.CommandId, requestInfo.CommandMajorVersion, requestInfo.CommandMinorVersion, ActiveManagerGenericRpcHelper.LocalServerVersion, majorVersion, minorVersion); } return(SerializationServices.Deserialize <T>(requestInfo.AttachedData)); }
public void ClientRethrowIfFailed(string databaseName, string serverName, RpcErrorExceptionInfo errorInfo) { Exception ex = null; string text = HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SanitizeServerName(serverName); if (errorInfo.IsFailed()) { if (errorInfo.ReconstitutedException != null) { ex = this.ConstructClientExceptionFromServerException(text, errorInfo.ReconstitutedException); } else { if (errorInfo.SerializedException != null && errorInfo.SerializedException.Length > 0) { try { errorInfo.ReconstitutedException = SerializationServices.Deserialize <Exception>(errorInfo.SerializedException); ex = this.ConstructClientExceptionFromServerException(text, errorInfo.ReconstitutedException); goto IL_109; } catch (SerializationException innerException) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage, innerException); ((TBaseException)((object)ex)).OriginatingServer = text; goto IL_109; } catch (TargetInvocationException innerException2) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage, innerException2); ((TBaseException)((object)ex)).OriginatingServer = text; goto IL_109; } } if (!string.IsNullOrEmpty(errorInfo.ErrorMessage)) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage); ((TBaseException)((object)ex)).OriginatingServer = text; } else { ex = this.GetGenericOperationFailedWithEcException(errorInfo.ErrorCode); ((TBaseException)((object)ex)).OriginatingServer = text; } } IL_109: IHaRpcServerBaseException ex2 = ex as IHaRpcServerBaseException; if (ex2 != null && string.IsNullOrEmpty(ex2.DatabaseName) && !string.IsNullOrEmpty(databaseName)) { ((IHaRpcServerBaseExceptionInternal)ex).DatabaseName = databaseName; } } if (ex != null) { throw ex; } }
public static T RunRpcAndGetReply <T>(RpcGenericRequestInfo requestInfo, string serverName, int timeoutInMSec) where T : class { RpcGenericReplyInfo replyInfo = null; AmRpcClientHelper.RunRpcOperation(AmRpcOperationHint.GenericRpc, serverName, new int?(timeoutInMSec), delegate(AmRpcClient rpcClient, string rpcServerName) { ExTraceGlobals.ActiveMonitoringRpcTracer.TraceDebug <string>(0L, "GenericRequest(): Now making GenericRequest RPC to server {0}.", serverName); return(rpcClient.GenericRequest(requestInfo, out replyInfo)); }); return(SerializationServices.Deserialize <T>(replyInfo.AttachedData)); }
// Token: 0x06001142 RID: 4418 RVA: 0x000466F8 File Offset: 0x000448F8 public EseDatabasePatchState ReadHeader() { this.AssertReadOperationValid(); EseDatabasePatchState eseDatabasePatchState = null; this.SeekToStart(); byte[] array = new byte[32768L]; this.ReadFromFile(array, array.Length); int num = 0; int num2 = BitConverter.ToInt32(array, num); num += 4; if (num2 > array.Length - 4 || num2 <= 0) { EseDatabasePatchFileIO.Tracer.TraceError <int, int>((long)this.GetHashCode(), "ReadHeader(): Serialized header state in bytes ({0}) is invalid. Must be >=0 and < pre-allocated fixed byte size of {1} bytes.", num2, array.Length); throw new PagePatchInvalidFileException(this.m_fileStream.Name); } byte[] array2 = new byte[num2]; Array.Copy(array, num, array2, 0, num2); Exception ex = null; try { eseDatabasePatchState = SerializationServices.Deserialize <EseDatabasePatchState>(array2); } catch (SerializationException ex2) { ex = ex2; } catch (TargetInvocationException ex3) { ex = ex3; } catch (DecoderFallbackException ex4) { ex = ex4; } if (ex != null) { EseDatabasePatchFileIO.Tracer.TraceError <Exception>((long)this.GetHashCode(), "ReadHeader deserialize failed: {0}", ex); throw new PagePatchInvalidFileException(this.m_fileStream.Name, ex); } this.m_header = eseDatabasePatchState; return(eseDatabasePatchState); }
public override PersonalizationState LoadPersonalizationState(WebPartManager webPartManager, bool ignoreCurrentUser) { if (null == webPartManager) { throw new ArgumentNullException("webPartManager is null"); } DictionaryPersonalizationState state = new DictionaryPersonalizationState(webPartManager); string suid = this.GetScreenUniqueIdentifier(); Cache cache = HttpRuntime.Cache; lock (SyncRoot) { Dictionary <string, PersonalizationDictionary> cachedstates = cache[suid] as Dictionary <string, PersonalizationDictionary>; if ((this.IsEnabled && !state.ReadOnly) || null == cachedstates) { string storage = PersonalizationStorage.Instance.Read(XmlPersonalizationProvider.StorageKey, XmlPersonalizationProvider.StorageTemplate); if (!string.IsNullOrEmpty(storage)) { using (XmlTextReader reader = new XmlTextReader(new StringReader(storage))) { reader.MoveToContent(); if (reader.MoveToAttribute("readOnly")) { bool isReadOnly = false; bool.TryParse(reader.Value, out isReadOnly); state.ReadOnly = isReadOnly; reader.MoveToElement(); } if (reader.ReadToDescendant("part")) { int partDepth = reader.Depth; do { reader.MoveToElement(); reader.MoveToAttribute("id"); string id = reader.Value; PersonalizationDictionary dictionary = new PersonalizationDictionary(); reader.MoveToContent(); if (reader.ReadToDescendant("property")) { int propertyDepth = reader.Depth; do { reader.MoveToElement(); reader.MoveToAttribute("name"); string name = reader.Value; reader.MoveToAttribute("sensitive"); bool sensitive = bool.Parse(reader.Value); reader.MoveToAttribute("scope"); PersonalizationScope scope = (PersonalizationScope)int.Parse(reader.Value); object value = null; reader.MoveToContent(); if (reader.ReadToDescendant("value")) { reader.MoveToAttribute("type"); if (reader.HasValue) { Type type = Type.GetType(reader.Value); if (type == null && name == "Configuration") { type = Type.GetType("LWAS.Infrastructure.Configuration.Configuration, LWAS"); } reader.MoveToContent(); value = SerializationServices.Deserialize(type, reader); } } dictionary.Add(name, new PersonalizationEntry(value, scope, sensitive)); reader.MoveToElement(); while (propertyDepth < reader.Depth && reader.Read()) { } }while (reader.ReadToNextSibling("property")); } state.States.Add(id, dictionary); reader.MoveToElement(); while (partDepth < reader.Depth && reader.Read()) { } }while (reader.ReadToNextSibling("part")); } } } string fileToMonitor = PersonalizationStorage.Instance.BuildPath(StorageKey); if (!PersonalizationStorage.Instance.Agent.HasKey(fileToMonitor)) { fileToMonitor = PersonalizationStorage.Instance.BuildPath(StorageTemplate); } cache.Insert(suid, state.States, new CacheDependency(HttpContext.Current.Server.MapPath(fileToMonitor))); } else { state.States = cachedstates; } } return(state); }