Пример #1
0
        // custom deserializer with no dependency on the Serializer subsystem
        // order of fields is important for backwards compat and must be the same as the order in Serialize, don't change!
        // This method is static because the entry type differentiator is not the first field, and we need to read several
        // fields before we can decide what type to create. This is for legacy reasons, since the early versions of the
        // catalog file only contained one type of entry (stream metadata).
        internal static Metadata Deserialize(BufferReader metadataBuffer)
        {
            var name               = metadataBuffer.ReadString();
            var id                 = metadataBuffer.ReadInt32();
            var typeName           = metadataBuffer.ReadString();
            var version            = metadataBuffer.ReadInt32();
            var serializerTypeName = metadataBuffer.ReadString();
            var serializerVersion  = metadataBuffer.ReadInt32();
            var customFlags        = metadataBuffer.ReadUInt16();
            var kind               = (MetadataKind)metadataBuffer.ReadUInt16();

            if (kind == MetadataKind.StreamMetadata)
            {
                var result = new PsiStreamMetadata(name, id, typeName, version, serializerTypeName, serializerVersion, customFlags);
                result.Deserialize(metadataBuffer);
                return(result);
            }
            else if (kind == MetadataKind.TypeSchema)
            {
                var result = new TypeSchema(name, id, typeName, version, serializerTypeName, serializerVersion);
                result.Deserialize(metadataBuffer);
                return(result);
            }
            else
            {
                // kind == MetadataKind.RuntimeInfo
                var result = new RuntimeInfo(name, id, typeName, version, serializerTypeName, serializerVersion);
                return(result);
            }
        }
Пример #2
0
        /// <summary>
        /// Returns the metadata associated with the specified stream, if the stream is persisted to a store.
        /// </summary>
        /// <param name="pipeline">The current pipeline</param>
        /// <param name="streamName">The name of the stream to retrieve metadata about</param>
        /// <param name="metadata">Upon return, this parameter contains the metadata associated with the stream, or null if the stream is not persisted</param>
        /// <returns>True if the stream is persisted to a store, false otherwise</returns>
        public static bool TryGetMetadata(Pipeline pipeline, string streamName, out PsiStreamMetadata metadata)
        {
            if (string.IsNullOrEmpty(streamName))
            {
                metadata = null;
                return(false);
            }

            return(pipeline.ConfigurationStore.TryGet(StreamMetadataNamespace, streamName, out metadata));
        }
Пример #3
0
 /// <summary>
 /// Update supplemental stream metadata from another stream metadata.
 /// </summary>
 /// <param name="other">Other stream metadata from which to copy supplemental metadata.</param>
 /// <returns>Updated stream metadata.</returns>
 internal PsiStreamMetadata UpdateSupplementalMetadataFrom(PsiStreamMetadata other)
 {
     this.SupplementalMetadataTypeName = other.SupplementalMetadataTypeName;
     this.supplementalMetadataBytes    = other.supplementalMetadataBytes;
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Returns the metadata associated with the specified stream, if the stream is persisted to a store.
 /// </summary>
 /// <typeparam name="T">The type of stream messages</typeparam>
 /// <param name="source">The stream to retrieve metadata about</param>
 /// <param name="metadata">Upon return, this parameter contains the metadata associated with the stream, or null if the stream is not persisted</param>
 /// <returns>True if the stream is persisted to a store, false otherwise</returns>
 public static bool TryGetMetadata <T>(IProducer <T> source, out PsiStreamMetadata metadata)
 {
     return(Store.TryGetMetadata(source.Out.Pipeline, source.Out.Name, out metadata));
 }