public DiagnosticsModuleBuilder(IRootPathProvider rootPathProvider, IModelBinderLocator modelBinderLocator, INancyEnvironment diagnosticsEnvironment, INancyEnvironment environment) { this.rootPathProvider = rootPathProvider; this.serializerFactory = new DiagnosticsSerializerFactory(diagnosticsEnvironment); this.modelBinderLocator = modelBinderLocator; this.environment = environment; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultResponseFormatter"/> class. /// </summary> /// <param name="rootPathProvider">The <see cref="IRootPathProvider"/> that should be used by the instance.</param> /// <param name="context">The <see cref="NancyContext"/> that should be used by the instance.</param> /// <param name="serializerFactory">An <see cref="ISerializerFactory" /> instance"/>.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> public DefaultResponseFormatter(IRootPathProvider rootPathProvider, NancyContext context, ISerializerFactory serializerFactory, INancyEnvironment environment) { this.rootPathProvider = rootPathProvider; this.context = context; this.serializerFactory = serializerFactory; this.environment = environment; }
public DefaultResponseFormatterFactoryFixture() { this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("RootPath"); this.serializerFactory = A.Fake<ISerializerFactory>(); A.CallTo(() => this.serializerFactory.GetSerializer(A<MediaRange>._)); this.factory = new DefaultResponseFormatterFactory(this.rootPathProvider, this.serializerFactory); }
/// <summary>Initializes a new instance of the <see cref="ServiceClientAuthorized"/> class.</summary> /// <param name="baseUri">The base uri.</param> /// <param name="apiKey">The api key.</param> /// <param name="successSerializerFactory">The success serializer factory.</param> /// <param name="errorSerializerFactory">The error serializer factory.</param> /// <param name="gzipInflator">The gzip inflator.</param> /// <exception cref="ArgumentException">Thrown when one of the arguments is null.</exception> public ServiceClientAuthorized(Uri baseUri, string apiKey, ISerializerFactory successSerializerFactory, ISerializerFactory errorSerializerFactory, IConverter<Stream, Stream> gzipInflator) : base(baseUri, successSerializerFactory, errorSerializerFactory, gzipInflator) { if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentException("The provided api key has to be valid", "apiKey"); } this.apiKey = apiKey; }
public static SerializerDescriptor CreateFromFactoryInstance(ISerializerFactory factoryInstance) { Contract.Ensures(!string.IsNullOrEmpty(factoryInstance.GetType().FullName)); Contract.Ensures(Contract.Result<System.Windows.Documents.Serialization.SerializerDescriptor>() != null); Contract.Ensures(factoryInstance.GetType().Assembly != null); Contract.Ensures(factoryInstance.GetType().Assembly.FullName != null); Contract.Ensures(factoryInstance.GetType().Assembly.GetName() != null); Contract.Ensures(factoryInstance.GetType().Assembly.Location != null); return default(SerializerDescriptor); }
public DefaultResponseFormatterFactoryFixture() { this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns("RootPath"); this.serializerFactory = A.Fake<ISerializerFactory>(); this.environment = A.Fake<INancyEnvironment>(); this.factory = new DefaultResponseFormatterFactory(this.rootPathProvider, this.serializerFactory, this.environment); }
protected void SerializeValue(ISerializerFactory sf, ICalendarProperty prop, Type valueType, object v, StringBuilder result) { // Get a serializer to serialize the property's value. // If we can't serialize the property's value, the next step is worthless anyway. IStringSerializer valueSerializer = sf.Build(valueType, SerializationContext) as IStringSerializer; if (valueSerializer != null) { // Iterate through each value to be serialized, // and give it a property (with parameters). // FIXME: this isn't always the way this is accomplished. // Multiple values can often be serialized within the // same property. How should we fix this? // NOTE: // We Serialize the property's value first, as during // serialization it may modify our parameters. // FIXME: the "parameter modification" operation should // be separated from serialization. Perhaps something // like PreSerialize(), etc. string value = valueSerializer.SerializeToString(v); // Get the list of parameters we'll be serializing ICalendarParameterCollection parameterList = prop.Parameters; if (v is ICalendarDataType) parameterList = ((ICalendarDataType)v).Parameters; StringBuilder sb = new StringBuilder(prop.Name); if (parameterList.Any()) { // Get a serializer for parameters IStringSerializer parameterSerializer = sf.Build(typeof(ICalendarParameter), SerializationContext) as IStringSerializer; if (parameterSerializer != null) { // Serialize each parameter List<string> parameters = new List<string>(); foreach (ICalendarParameter param in parameterList) { parameters.Add(parameterSerializer.SerializeToString(param)); } // Separate parameters with semicolons sb.Append(";"); sb.Append(string.Join(";", parameters.ToArray())); } } sb.Append(":"); sb.Append(value); result.Append(TextUtil.WrapLines(sb.ToString())); } }
/// <summary> /// Creates a SerializerDescriptor. The interface must be defined in the calling assembly /// The WinFX version, and assembly name, and version are initialized by reflecting on the calling assembly /// </summary> /// <remarks> /// Create a SerializerDescriptor from a ISerializerFactory instance /// /// This method currently requires full trust to run. /// </remarks> ///<SecurityNote> /// The DemandPlugInSerializerPermissions() ensures that this method only works in full trust. /// Full trust is required, so that partial trust applications do not load or use potentially /// unsafe serializer plug ins ///</SecurityNote> public static SerializerDescriptor CreateFromFactoryInstance( ISerializerFactory factoryInstance ) { SecurityHelper.DemandPlugInSerializerPermissions(); if (factoryInstance == null) { throw new ArgumentNullException("factoryInstance"); } if (factoryInstance.DisplayName == null) { throw new ArgumentException(SR.Get(SRID.SerializerProviderDisplayNameNull)); } if (factoryInstance.ManufacturerName == null) { throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerNameNull)); } if (factoryInstance.ManufacturerWebsite == null) { throw new ArgumentException(SR.Get(SRID.SerializerProviderManufacturerWebsiteNull)); } if (factoryInstance.DefaultFileExtension == null) { throw new ArgumentException(SR.Get(SRID.SerializerProviderDefaultFileExtensionNull)); } SerializerDescriptor sd = new SerializerDescriptor(); sd._displayName = factoryInstance.DisplayName; sd._manufacturerName = factoryInstance.ManufacturerName; sd._manufacturerWebsite = factoryInstance.ManufacturerWebsite; sd._defaultFileExtension = factoryInstance.DefaultFileExtension; // When this is called with an instantiated factory object, it must be loadable sd._isLoadable = true; Type factoryType = factoryInstance.GetType(); sd._assemblyName = factoryType.Assembly.FullName; sd._assemblyPath = factoryType.Assembly.Location; sd._assemblyVersion = factoryType.Assembly.GetName().Version; sd._factoryInterfaceName = factoryType.FullName; sd._winFXVersion = typeof(System.Windows.Controls.Button).Assembly.GetName().Version; return sd; }
protected CacheServiceBase(CacheServiceType cacheServiceType, ISerializerFactory serializerFactory) { Type = cacheServiceType; this.serializerFactory = serializerFactory; }
public static void RunDeserializationPerformanceTest(int numberOfRuns, TestType testType, int testSize, ISerializerFactory serializerFactory) { var obj = GetSerializationObject(testType, testSize); var serializer = serializerFactory.GetSerializer(); serializer.Init(obj); using (var stream = new MemoryStream()) { serializer.Serialize(obj, stream); stream.Position = 0; foreach (var iteration in Benchmark.Iterations) { using (iteration.StartMeasurement()) { for (int i = 0; i < numberOfRuns; i++) { serializer.Deserialize(stream); stream.Position = 0; } } } } }
public SerializationPipeAction(ISerializerFactory serializerFactory) { _serializerFactory = serializerFactory; }
public DiagnosticsModuleBuilder(IRootPathProvider rootPathProvider, IModelBinderLocator modelBinderLocator) { this.rootPathProvider = rootPathProvider; this.serializerFactory = new DiagnosticsSerializerFactory(); this.modelBinderLocator = modelBinderLocator; }
#pragma warning restore CS0618 // Type or member is obsolete public ConnectionSettings(IConnectionPool connectionPool, IConnection connection, ISerializerFactory serializerFactory) : base(connectionPool, connection, serializerFactory, s => serializerFactory.Create(s)) { }
public SerializerFactory() { m_DataTypeSerializerFactory = new DataTypeSerializerFactory(); }
public DelayedVerificationConsumer(IModelFactory modelFactory, ISerializerFactory serializerFactory, ExchangeConfig exchangeConfig, Func <string> queueNameFactory) : this(modelFactory, serializerFactory, exchangeConfig, queueNameFactory, true) { }
/// <summary> /// Serialize a container set instance /// </summary> private static async Task SerializeAsync(ContainerSet set, string fileName, string directoryFullPath, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { if (set == null) { return; } var fullPath = Path.Combine(directoryFullPath, fileName); var fi = new FileInfo(fullPath); if (!Directory.Exists(fi.Directory.FullName)) { Directory.CreateDirectory(fi.Directory.FullName); } if (serializerFactory == default) { serializerFactory = SerializersCollection.JsonSerializer; } var serializer = serializerFactory.GetSerializer <ContainerSet>(); using var f = new FileStream(fullPath, FileMode.CreateNew, FileAccess.ReadWrite); byte[] serializedBytes = null; if (orchestrator != null) { var interceptorArgs = new SerializingSetArgs(orchestrator.GetContext(), set, serializerFactory, fileName, directoryFullPath); await orchestrator.InterceptAsync(interceptorArgs, default); serializedBytes = interceptorArgs.Result; } if (serializedBytes == null) { serializedBytes = await serializer.SerializeAsync(set); } f.Write(serializedBytes, 0, serializedBytes.Length); //await f.FlushAsync(); }
/// <summary> /// Loads the batch file and import the rows in a SyncSet instance /// </summary> public async Task LoadBatchAsync(SyncSet sanitizedSchema, string directoryFullPath, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { if (this.Data != null) { return; } if (string.IsNullOrEmpty(this.FileName)) { return; } // Clone the schema to get a unique instance var set = sanitizedSchema.Clone(); // Get a Batch part, and deserialise the file into a the BatchPartInfo Set property var data = await DeserializeAsync(this.FileName, directoryFullPath, serializerFactory, orchestrator); // Import data in a typed Set set.ImportContainerSet(data, true); this.Data = set; }
private Store(NoSQLContext context, Options options, ISerializerFactory serializerFactory, ITypeVersioner versioner) : base(context, options, serializerFactory, versioner) { this._context = context; }
protected RestQueryProviderContracts(IRestClient client, ISerializerFactory serializerFactory, IMemberNameResolver memberNameResolver, IEnumerable <IValueWriter> valueWriters, IExpressionProcessor expressionProcessor, Type sourceType) : base(client, serializerFactory, expressionProcessor, memberNameResolver, valueWriters, sourceType) { }
/// <summary> /// Initializes a new instance of the <see cref="For{T}"/> class. /// </summary> /// <param name="configurationSerializerRepresentation">The configuration serializer representation.</param> /// <param name="configurationSerializerFactory">The configuration serializer factory.</param> /// <param name="keyOverride">The optional specified key to use; DEFAULT is null and will build a key from the supplied <typeparamref name="T"/>.</param> public For(SerializerRepresentation configurationSerializerRepresentation, ISerializerFactory configurationSerializerFactory, string keyOverride = null) { this.Key = keyOverride ?? BuildKey(); var configSetting = GetSerializedSetting(this.Key); var serializer = configurationSerializerFactory.BuildSerializer(configurationSerializerRepresentation); if (!string.IsNullOrWhiteSpace(configSetting)) { this.Value = serializer.Deserialize <T>(configSetting); } else { throw new FileNotFoundException(FormattableString.Invariant($"Could not find config for: {typeof(T).AssemblyQualifiedName}.")); } }
/// <summary> /// Sets the serialization logic to be used when reading configuration data (from files or otherwise). /// </summary> /// <param name="configurationSerializerRepresentation">The serializer representation.</param> /// <param name="configurationSerializerFactory">Optional serializer factory; DEFAULT is JSON.</param> public static void SetSerialization(SerializerRepresentation configurationSerializerRepresentation, ISerializerFactory configurationSerializerFactory = null) { lock (SyncUpdateSettings) { Config.serializerRepresentation = configurationSerializerRepresentation; Config.serializerFactory = configurationSerializerFactory ?? new JsonSerializerFactory(); } }
/// <summary> /// Gets the specified configuration. /// </summary> /// <typeparam name="T">Type of configuration item.</typeparam> /// <param name="configurationSerializerRepresentation">Optional; configuration serializer representation; DEFAULT is JSON.</param> /// <param name="configurationSerializerFactory">Optional; configuration serializer factory; DEFAULT is JSON.</param> /// <returns>T.</returns> public static T Get <T>(SerializerRepresentation configurationSerializerRepresentation = null, ISerializerFactory configurationSerializerFactory = null) { return((T)ResolvedSettings.GetOrAdd( typeof(T), t => new For <T>( configurationSerializerRepresentation ?? serializerRepresentation, configurationSerializerFactory ?? serializerFactory).Value)); }
/// <summary> /// Gets a settings object of the specified type. /// </summary> /// <param name="type">Type to fetch.</param> /// <param name="configurationSerializerRepresentation">Optional; configuration serializer representation; DEFAULT is JSON.</param> /// <param name="configurationSerializerFactory">Optional; configuration serializer factory; DEFAULT is JSON.</param> /// <returns>Deserialized configuration.</returns> public static object Get(Type type, SerializerRepresentation configurationSerializerRepresentation = null, ISerializerFactory configurationSerializerFactory = null) { return(ResolvedSettings.GetOrAdd(type, t => { dynamic settingsFor = typeof(For <>).MakeGenericType(type).Construct(configurationSerializerRepresentation ?? serializerRepresentation, configurationSerializerFactory ?? serializerFactory, null); return settingsFor.Value; })); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultResponseFormatter"/> class. /// </summary> /// <param name="rootPathProvider">The <see cref="IRootPathProvider"/> that should be used by the instance.</param> /// <param name="context">The <see cref="NancyContext"/> that should be used by the instance.</param> /// <param name="serializerFactory">An <see cref="ISerializerFactory" /> instance"/>.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> public DefaultResponseFormatter(IRootPathProvider rootPathProvider, NancyContext context, ISerializerFactory serializerFactory, INancyEnvironment environment) { this.rootPathProvider = rootPathProvider; this.context = context; this.serializerFactory = serializerFactory; this.environment = environment; }
private async Task <ContainerSet> DeserializeAsync(string fileName, string directoryFullPath, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException(fileName); } if (string.IsNullOrEmpty(directoryFullPath)) { throw new ArgumentNullException(directoryFullPath); } var fullPath = Path.Combine(directoryFullPath, fileName); if (!File.Exists(fullPath)) { throw new MissingFileException(fullPath); } // backward compatibility if (serializerFactory == default) { serializerFactory = SerializersCollection.JsonSerializer; } // backward compatibility if (this.SerializedType == default) { this.SerializedType = typeof(ContainerSet); } Debug.WriteLine($"Deserialize file {fileName}"); using var fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read); ContainerSet set = null; if (orchestrator != null) { var interceptorArgs = new DeserializingSetArgs(orchestrator.GetContext(), fs, serializerFactory, fileName, directoryFullPath); await orchestrator.InterceptAsync(interceptorArgs, default); set = interceptorArgs.Result; } if (set == null) { if (this.SerializedType == typeof(ContainerSet)) { var serializer = serializerFactory.GetSerializer <ContainerSet>(); set = await serializer.DeserializeAsync(fs); } else { var serializer = serializerFactory.GetSerializer <ContainerSetBoilerPlate>(); var jobject = await serializer.DeserializeAsync(fs); set = jobject.Changes; } } return(set); }
public FileBasedFabricSerializerFactoryAdvisor(ISerializerFactory[] factories) { _factory = factories?.FirstOrDefault(); }
/// <summary> /// Create a new BPI, and serialize the changeset if not in memory /// </summary> internal static async Task <BatchPartInfo> CreateBatchPartInfoAsync(int batchIndex, SyncSet set, string fileName, string directoryFullPath, bool isLastBatch, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { BatchPartInfo bpi = null; // Create a batch part // The batch part creation process will serialize the changesSet to the disk // Serialize the file ! await SerializeAsync(set.GetContainerSet(), fileName, directoryFullPath, serializerFactory, orchestrator); bpi = new BatchPartInfo { FileName = fileName }; bpi.Index = batchIndex; bpi.IsLastBatch = isLastBatch; // Even if the set is empty (serialized on disk), we should retain the tables names if (set != null) { bpi.Tables = set.Tables.Select(t => new BatchPartTableInfo(t.TableName, t.SchemaName, t.Rows.Count)).ToArray(); bpi.RowsCount = set.Tables.Sum(t => t.Rows.Count); } return(bpi); }
public static void RunDeserializationPerformanceTest(int numberOfRuns, TestType testType, int testSize, ISerializerFactory serializerFactory) { var obj = GetSerializationObject(testType, testSize); var serializer = serializerFactory.GetSerializer(); serializer.Init(obj); using (var stream = new MemoryStream()) { serializer.Serialize(obj, stream); stream.Position = 0; foreach (var iteration in Benchmark.Iterations) { using (iteration.StartMeasurement()) { for (int i = 0; i < numberOfRuns; i++) { serializer.Deserialize(stream); stream.Position = 0; } } } } }
public FileBasedFabricSerializerFactoryAdvisor(IEnumerable <ISerializerFactory> factories) { _factory = factories?.FirstOrDefault(); }
public WikidataClient(HttpClient httpClient, ISerializerFactory serializerFactory) : base(httpClient, serializerFactory) { }
/// <summary>Initializes a new instance of the <see cref="ServiceClientAuthorized"/> class.</summary> /// <param name="baseUri">The base uri.</param> /// <param name="apiKey">The api key.</param> /// <param name="successSerializerFactory">The success serializer factory.</param> /// <param name="errorSerializerFactory">The error serializer factory.</param> /// <param name="gzipInflator">The gzip inflator.</param> /// <exception cref="ArgumentException">Thrown when one of the arguments is null.</exception> public ServiceClientAuthorized(Uri baseUri, string apiKey, ISerializerFactory successSerializerFactory, ISerializerFactory errorSerializerFactory, IConverter <Stream, Stream> gzipInflator) : base(baseUri, successSerializerFactory, errorSerializerFactory, gzipInflator) { if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentException("The provided api key has to be valid", "apiKey"); } this.apiKey = apiKey; }
public ICalendarComponent component( ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o ) //throws RecognitionException, TokenStreamException { ICalendarComponent c = null;; IToken n = null; IToken m = null; match(BEGIN); match(COLON); { switch (LA(1)) { case IANA_TOKEN: { n = LT(1); match(IANA_TOKEN); c = cf.Build(n.getText().ToLower(), true); break; } case X_NAME: { m = LT(1); match(X_NAME); c = cf.Build(m.getText().ToLower(), true); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } ISerializationProcessor <ICalendarComponent> processor = ctx.GetService(typeof(ISerializationProcessor <ICalendarComponent>)) as ISerializationProcessor <ICalendarComponent>; // Do some pre-processing on the component if (processor != null) { processor.PreDeserialization(c); } SerializationUtil.OnDeserializing(c); // Push the component onto the serialization context stack ctx.Push(c); if (o != null) { // Add the component as a child immediately, in case // embedded components need to access this component, // or the iCalendar itself. o.AddChild(c); } c.Line = n.getLine(); c.Column = n.getColumn(); { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop16_breakloop; } } _loop16_breakloop :; } // ( ... )* { // ( ... )* for (;;) { switch (LA(1)) { case IANA_TOKEN: case X_NAME: { property(ctx, c); break; } case BEGIN: { component(ctx, sf, cf, c); break; } default: { goto _loop18_breakloop; } } } _loop18_breakloop :; } // ( ... )* match(END); match(COLON); match(IANA_TOKEN); { // ( ... )* for (;;) { if ((LA(1) == CRLF)) { match(CRLF); } else { goto _loop20_breakloop; } } _loop20_breakloop :; } // ( ... )* // Do some final processing on the component if (processor != null) { processor.PostDeserialization(c); } // Notify that the component has been loaded c.OnLoaded(); SerializationUtil.OnDeserialized(c); // Pop the component off the serialization context stack ctx.Pop(); return(c); }
public DelayedVerificationConsumer(IModelFactory modelFactory, ISerializerFactory serializerFactory, ExchangeConfig exchangeConfig) : this(modelFactory, serializerFactory, exchangeConfig, () => Guid.NewGuid().ToString(), true) { }
public async IAsyncEnumerable <SyncTable> GetTableAsync(string tableName, string schemaName, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { if (this.SanitizedSchema == null) { throw new NullReferenceException("Batch info schema should not be null"); } var tableInfo = new BatchPartTableInfo(tableName, schemaName); if (InMemory) { this.SerializerFactoryKey = null; if (this.InMemoryData != null && this.InMemoryData.HasTables) { yield return(this.InMemoryData.Tables[tableName, schemaName]); } } else { this.SerializerFactoryKey = serializerFactory.Key; var bpiTables = BatchPartsInfo.Where(bpi => bpi.RowsCount > 0 && bpi.Tables.Any(t => t.EqualsByName(tableInfo))).OrderBy(t => t.Index); if (bpiTables != null) { foreach (var batchPartinInfo in bpiTables) { // load only if not already loaded in memory if (batchPartinInfo.Data == null) { await batchPartinInfo.LoadBatchAsync(this.SanitizedSchema, GetDirectoryFullPath(), serializerFactory, orchestrator).ConfigureAwait(false); } // Get the table from the batchPartInfo // generate a tmp SyncTable for var batchTable = batchPartinInfo.Data.Tables.FirstOrDefault(bt => bt.EqualsByName(new SyncTable(tableName, schemaName))); if (batchTable != null) { yield return(batchTable); // We may need this same BatchPartInfo for another table, // but we dispose it anyway, because memory can be quickly a bottleneck // if batchpartinfos are resident in memory batchPartinInfo.Data.Dispose(); batchPartinInfo.Data = null; } } } } }
internal ConsumedMessageBuilder(ISerializerFactory serializerFactory, IMessageTypeResolver resolver) { _serializerFactory = serializerFactory; _resolver = resolver; }
/// <summary> /// Add changes to batch info. /// </summary> public async Task AddChangesAsync(SyncSet changes, int batchIndex = 0, bool isLastBatch = true, ISerializerFactory serializerFactory = default, BaseOrchestrator orchestrator = null) { if (this.InMemory) { this.SerializerFactoryKey = null; this.InMemoryData = changes; } else { this.SerializerFactoryKey = serializerFactory.Key; var bpId = GenerateNewFileName(batchIndex.ToString()); var bpi = await BatchPartInfo.CreateBatchPartInfoAsync(batchIndex, changes, bpId, GetDirectoryFullPath(), isLastBatch, serializerFactory, orchestrator).ConfigureAwait(false); // add the batchpartinfo tp the current batchinfo this.BatchPartsInfo.Add(bpi); } }
public ICalendarComponent component( ISerializationContext ctx, ISerializerFactory sf, ICalendarComponentFactory cf, ICalendarObject o ) //throws RecognitionException, TokenStreamException { ICalendarComponent c = null;; IToken n = null; IToken m = null; match(BEGIN); match(COLON); { switch ( LA(1) ) { case IANA_TOKEN: { n = LT(1); match(IANA_TOKEN); c = cf.Build(n.getText().ToLower(), true); break; } case X_NAME: { m = LT(1); match(X_NAME); c = cf.Build(m.getText().ToLower(), true); break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } ISerializationProcessor<ICalendarComponent> processor = ctx.GetService(typeof(ISerializationProcessor<ICalendarComponent>)) as ISerializationProcessor<ICalendarComponent>; // Do some pre-processing on the component if (processor != null) processor.PreDeserialization(c); SerializationUtil.OnDeserializing(c); // Push the component onto the serialization context stack ctx.Push(c); if (o != null) { // Add the component as a child immediately, in case // embedded components need to access this component, // or the iCalendar itself. o.AddChild(c); } c.Line = n.getLine(); c.Column = n.getColumn(); { // ( ... )* for (;;) { if ((LA(1)==CRLF)) { match(CRLF); } else { goto _loop16_breakloop; } } _loop16_breakloop: ; } // ( ... )* { // ( ... )* for (;;) { switch ( LA(1) ) { case IANA_TOKEN: case X_NAME: { property(ctx, c); break; } case BEGIN: { component(ctx, sf, cf, c); break; } default: { goto _loop18_breakloop; } } } _loop18_breakloop: ; } // ( ... )* match(END); match(COLON); match(IANA_TOKEN); { // ( ... )* for (;;) { if ((LA(1)==CRLF)) { match(CRLF); } else { goto _loop20_breakloop; } } _loop20_breakloop: ; } // ( ... )* // Do some final processing on the component if (processor != null) processor.PostDeserialization(c); // Notify that the component has been loaded c.OnLoaded(); SerializationUtil.OnDeserialized(c); // Pop the component off the serialization context stack ctx.Pop(); return c; }
private IQueryable <TResult> InnerCreateQueryable <TResult>(IRestClient client, ISerializerFactory serializerFactory, IMemberNameResolver memberNameResolver, IEnumerable <IValueWriter> valueWriters, Expression expression, Type sourceType) { Contract.Requires(client != null); Contract.Requires(serializerFactory != null); Contract.Requires(expression != null); Contract.Requires(memberNameResolver != null); Contract.Requires(valueWriters != null); return(new RestGetQueryable <TResult>(client, serializerFactory, memberNameResolver, valueWriters, sourceType, expression)); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultResponseFormatter"/> class. /// </summary> /// <param name="rootPathProvider">The <see cref="IRootPathProvider"/> that should be used by the instance.</param> /// <param name="context">The <see cref="NancyContext"/> that should be used by the instance.</param> /// <param name="serializerFactory"></param> public DefaultResponseFormatter(IRootPathProvider rootPathProvider, NancyContext context, ISerializerFactory serializerFactory) { this.rootPathProvider = rootPathProvider; this.context = context; this.serializerFactory = serializerFactory; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultResponseFormatter"/> class, with the /// provided <see cref="IRootPathProvider"/>. /// </summary> /// <param name="rootPathProvider"></param> public DefaultResponseFormatterFactory(IRootPathProvider rootPathProvider, ISerializerFactory serializerFactory) { this.rootPathProvider = rootPathProvider; this.serializerFactory = serializerFactory; }
public SerializerFactory() { m_DataTypeSerializerFactory = new DataTypeSerializerFactory(); }
public SerializerWriter CreateSerializerWriter(SerializerDescriptor serializerDescriptor, Stream stream) { SecurityHelper.DemandPlugInSerializerPermissions(); SerializerWriter serializerWriter = null; if (serializerDescriptor == null) { throw new ArgumentNullException("serializerDescriptor"); } string serializerKey = serializerDescriptor.DisplayName + "/" + serializerDescriptor.AssemblyName + "/" + serializerDescriptor.AssemblyVersion + "/" + serializerDescriptor.WinFXVersion; if (!serializerDescriptor.IsLoadable) { throw new ArgumentException(SR.Get(SRID.SerializerProviderWrongVersion), serializerKey); } if (stream == null) { throw new ArgumentNullException("stream"); } bool found = false; foreach (SerializerDescriptor sd in InstalledSerializers) { if (sd.Equals(serializerDescriptor)) { found = true; break; } } if (!found) { throw new ArgumentException(SR.Get(SRID.SerializerProviderUnknownSerializer), serializerKey); } try { ISerializerFactory factory = serializerDescriptor.CreateSerializerFactory(); serializerWriter = factory.CreateSerializerWriter(stream); } catch (FileNotFoundException) { throw new ArgumentException(SR.Get(SRID.SerializerProviderCannotLoad), serializerDescriptor.DisplayName); } catch (FileLoadException) { throw new ArgumentException(SR.Get(SRID.SerializerProviderCannotLoad), serializerDescriptor.DisplayName); } catch (BadImageFormatException) { throw new ArgumentException(SR.Get(SRID.SerializerProviderCannotLoad), serializerDescriptor.DisplayName); } catch (MissingMethodException) { throw new ArgumentException(SR.Get(SRID.SerializerProviderCannotLoad), serializerDescriptor.DisplayName); } return(serializerWriter); }
public NoSqlRepository(NoSQLContext context, Options options, ISerializerFactory serializerFactory, ITypeVersioner versioner) { _store = new NoSqlRepository(context, options, serializerFactory, versioner); }
public WikipediaClient(HttpClient httpClient, ISerializerFactory serializerFactory, IWikidataClient wikidata) : base(httpClient, serializerFactory) { _wikidata = wikidata; }
public FileStorage(string path, ISerializerFactory serializerFactory) { _path = path; _serializerFactory = serializerFactory; }
public WorkspaceSerializationPersistor(INetfoxSettings netfoxSettings, IFileSystem fileSystem, ISerializerFactory serializerFactory) { this._netfoxSettings = netfoxSettings ?? throw new ArgumentNullException(nameof(netfoxSettings)); this._fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); this._serializerFactory = serializerFactory ?? throw new ArgumentNullException(nameof(serializerFactory)); }
public FileStorageFactory(ISerializerFactory serializerFactory) { _serializerFactory = serializerFactory; }
private void Initialize() { if (_initialized) { return; } _initialized = true; // Ensure VERSION and PRODUCTID are both set, // as they are required by RFC5545. if (string.IsNullOrEmpty(_ical.Version)) _ical.Version = CalendarVersions.v2_0; if (string.IsNullOrEmpty(_ical.ProductID)) _ical.ProductID = CalendarProductIDs.Default; _writer.Write(TextUtil.WrapLines("BEGIN:" + _ical.Name.ToUpper())); // Get a serializer factory _serializerFactory = GetService<ISerializerFactory>(); // Sort the calendar properties in alphabetical order before // serializing them! var properties = new List<ICalendarProperty>(_ical.Properties); properties.Sort(PropertySorter); foreach (ICalendarProperty property in properties) { WriteObject(property); } foreach (ICalendarObject child in _ical.Children) { WriteObject(child); } }