private void ChangeFormatterType(FormatterTypeOptions formatterType) { var config = SessionConfigurationManager.GetConfiguration().GetWritableCopy(); config.Formatter = formatterType; SessionConfigurationManager.SetConfiguration(config); }
public static ISessionDataFormatter GetFormatterFromType(FormatterTypeOptions formatterType, string customType) { switch (formatterType) { case FormatterTypeOptions.Binary: return(new BinaryFormatter()); case FormatterTypeOptions.BinaryCompressed: return(new BinaryCompressionFormatter()); case FormatterTypeOptions.BinaryLz4Compressed: return(new BinaryLz4CompressionFormatter()); case FormatterTypeOptions.ProtoBuf: return(new ProtoBufFormatter()); case FormatterTypeOptions.ProtoBufCompressed: return(new ProtoBufCompressionFormatter()); case FormatterTypeOptions.ProtoBufLz4Compressed: return(new ProtoBufLz4CompressionFormatter()); case FormatterTypeOptions.Json: return(new JsonFormatter()); case FormatterTypeOptions.JsonCompressed: return(new JsonCompressionFormatter()); case FormatterTypeOptions.JsonLz4Compressed: return(new JsonLz4CompressionFormatter()); case FormatterTypeOptions.Custom: default: if (string.IsNullOrWhiteSpace(customType)) { throw new SessionConfigurationException(SessionResources.Formatter_Missing); } var formatter = CustomFormatters.GetOrAdd(customType, s => { var provider = s.Construct(); var retVal = provider as ISessionDataFormatter; if (retVal == null) { throw new SessionConfigurationException( string.Format(SessionResources.Formatter_InvalidType, typeof(ISessionDataFormatter).FullName)); } return(retVal); }); return(formatter); } }
public WritableSessionSettings(string applicationKey, ProviderTypeOptions provider, string customProviderType, string connStringNameOrValue, int expirationTimeInSeconds, TimeSpan expiresIn, FormatterTypeOptions formatter, string customFormatterType, int?maxAsyncThreads) { ApplicationKey = applicationKey; Provider = provider; CustomProviderType = customProviderType; ConnStringNameOrValue = connStringNameOrValue; ExpirationTimeInSeconds = expirationTimeInSeconds; ExpiresIn = expiresIn; Formatter = formatter; CustomFormatterType = customFormatterType; MaxAsyncThreads = maxAsyncThreads; }