Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnnotationStoreReader"/> class.
        /// </summary>
        /// <param name="name">The name of the application that generated the persisted files, or the root name of the files</param>
        /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store</param>
        public AnnotationStoreReader(string name, string path)
            : base(name, path, AnnotationStoreCommon.DefaultExtension)
        {
            // load definition
            string metadataPath = System.IO.Path.Combine(this.Path, AnnotationStoreCommon.GetDefinitionFileName(this.Name) + this.Extension);

            using (var file = File.OpenText(metadataPath))
                using (var reader = new JsonTextReader(file))
                {
                    this.definition = this.Serializer.Deserialize <AnnotatedEventDefinition>(reader);
                }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnnotationStoreReader"/> class.
        /// </summary>
        /// <param name="name">The name of the application that generated the persisted files, or the root name of the files</param>
        /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store</param>
        public AnnotationStoreReader(string name, string path)
            : base(name, path, AnnotationStoreCommon.DataSchema, AnnotationStoreCommon.DefaultExtension, AnnotationStoreCommon.PreloadSchemas)
        {
            // load definition
            string metadataPath = System.IO.Path.Combine(this.Path, AnnotationStoreCommon.GetDefinitionFileName(this.Name) + this.Extension);

            using (var file = File.OpenText(metadataPath))
                using (var reader = new JsonTextReader(file))
                    using (var validatingReader = new JSchemaValidatingReader(reader))
                    {
                        validatingReader.Schema = JSchema.Parse(AnnotationStoreCommon.DefinitionSchema, this.Resolver);
                        validatingReader.ValidationEventHandler += (s, e) => throw new InvalidDataException(e.Message);
                        this.definition = this.Serializer.Deserialize <AnnotatedEventDefinition>(validatingReader);
                    }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationSimpleWriter"/> class.
 /// </summary>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 public AnnotationSimpleWriter(AnnotatedEventDefinition definition)
     : base(AnnotationStoreCommon.DataSchema, AnnotationStoreCommon.DefaultExtension, AnnotationStoreCommon.PreloadSchemas)
 {
     this.definition = definition;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationSimpleWriter"/> class.
 /// </summary>
 /// <param name="name">The name of the application that generated the persisted files, or the root name of the files.</param>
 /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store.</param>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 /// <param name="createSubdirectory">If true, a numbered subdirectory is created for this store.</param>
 public AnnotationSimpleWriter(string name, string path, AnnotatedEventDefinition definition, bool createSubdirectory = true)
     : base(name, path, AnnotationStoreCommon.DataSchema, createSubdirectory, AnnotationStoreCommon.DefaultExtension, AnnotationStoreCommon.PreloadSchemas)
 {
     this.definition = definition;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationExporter"/> class.
 /// </summary>
 /// <param name="pipeline">The pipeline that owns this instance.</param>
 /// <param name="name">The name of the application that generated the persisted files, or the root name of the files.</param>
 /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store.</param>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 /// <param name="createSubdirectory">If true, a numbered sub-directory is created for this store.</param>
 internal AnnotationExporter(Pipeline pipeline, string name, string path, AnnotatedEventDefinition definition, bool createSubdirectory = true)
     : base(pipeline, name, new AnnotationStoreWriter(name, path, definition, createSubdirectory))
 {
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new annotation partition given the specified parameters.
        /// </summary>
        /// <param name="session">The session that this partition belongs to.</param>
        /// <param name="storeName">The store name of this partition.</param>
        /// <param name="storePath">The store path of this partition.</param>
        /// <param name="definition">The annotated event definition to use when creating new annotated events in this partition.</param>
        /// <param name="name">The partition name.</param>
        /// <returns>The newly created annotation partition.</returns>
        public static AnnotationPartition Create(Session session, string storeName, string storePath, AnnotatedEventDefinition definition, string name = null)
        {
            using (var writer = new AnnotationSimpleWriter(definition))
            {
                writer.CreateStore(storeName, storePath);
                writer.CreateStream(new JsonStreamMetadata(definition.Name, 0, typeof(AnnotatedEvent).AssemblyQualifiedName, storeName, storePath), new List <Message <AnnotatedEvent> >());
                writer.WriteAll(ReplayDescriptor.ReplayAll);
            }

            return(new AnnotationPartition(session, storeName, storePath, name));
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationStoreWriter"/> class.
 /// </summary>
 /// <param name="name">The name of the application that generated the persisted files, or the root name of the files.</param>
 /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store.</param>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 /// <param name="createSubdirectory">If true, a numbered subdirectory is created for this store.</param>
 public AnnotationStoreWriter(string name, string path, AnnotatedEventDefinition definition, bool createSubdirectory = true)
     : base(name, path, createSubdirectory, AnnotationStoreCommon.DefaultExtension)
 {
     this.definition = definition;
     this.WriteDefinition();
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationSimpleWriter"/> class.
 /// </summary>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 public AnnotationSimpleWriter(AnnotatedEventDefinition definition)
     : base(AnnotationStoreCommon.DefaultExtension)
 {
     this.definition = definition;
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotationSimpleWriter"/> class.
 /// </summary>
 /// <param name="name">The name of the application that generated the persisted files, or the root name of the files.</param>
 /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store.</param>
 /// <param name="definition">The annotated event definition used to create and validate annotated events for this store.</param>
 /// <param name="createSubdirectory">If true, a numbered subdirectory is created for this store.</param>
 public AnnotationSimpleWriter(string name, string path, AnnotatedEventDefinition definition, bool createSubdirectory = true)
     : this(definition)
 {
     this.Writer = new AnnotationStoreWriter(name, path, definition, createSubdirectory);
 }