/// <summary> /// 元数据转换成第三方数据 /// </summary> /// <param name="metadataObject">元数据集合</param> /// <param name="id">属性对应key</param> /// <param name="data">属性对应byte数组</param> /// <param name="offsetStart">属性在数组中的偏移值</param> /// <param name="length">属性在byte数组中的长度</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public unsafe void DataProcessor(MetadataContainer metadataObject, byte id, byte[] data, int offsetStart, uint length) { if (metadataObject == null) { throw new ArgumentNullException("metadataObject"); } if (length == 0) { metadataObject.SetAttribute(id, new Int64ArrayValueStored(new long[0])); return; } long[] array = new long[length / Size.Int64]; if (array.Length <= 10) { fixed(byte *pByte = (&data[offsetStart])) { long *pData = (long *)pByte; for (int j = 0; j < array.Length; j++) { array[j] = *pData++; } } } else fixed(byte *pArr = &data[offsetStart]) Marshal.Copy(new IntPtr(pArr), array, 0, array.Length); metadataObject.SetAttribute(id, new Int64ArrayValueStored(array)); }
public void TestLinq2Xml() { const string Text = @"<Metadata xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <Meta xsi:type=""Readonly"" /> <Meta xsi:type=""Garbage"" /> </Metadata>"; // Get the "names" of all implementors of MetadataBase var types = AppDomain.CurrentDomain.GetAssemblies().ToList() .SelectMany(s => s.GetTypes()) .Where(p => typeof(MetadataBase).IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface) .Where(t => t.GetCustomAttributes(typeof(XmlTypeAttribute), false).Any()) .Select(t => t.GetCustomAttributes(typeof(XmlTypeAttribute), false) .Cast<XmlTypeAttribute>().First().TypeName); // Create a parser var parser = new XmlSerializer(typeof(MetadataBase)); // Create metadatacontainer to fill var metas = new MetadataContainer(); // Fill it with matching from from the XML metas.AddRange((from t in XDocument.Parse(Text).Descendants("Meta") where types.Contains(t.Attribute(XName.Get("type", "http://www.w3.org/2001/XMLSchema-instance")).Value) select (MetadataBase)parser.Deserialize(t.CreateReader())).ToList()); // Should be one guy present Assert.AreEqual(metas.Count, 1); }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "NortwindEntity"; container.DefaultNamespace = "_02.PleaseNorhtwindWork"; container.NameGenerator.RemoveCamelCase = false; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "Model"; container.DefaultNamespace = "NBAStatistics.Data.MySQL.Models"; container.NameGenerator.SourceStrategy = NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "FluentModel"; container.DefaultNamespace = "Model"; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "VRArcadeDataAccessModel"; container.DefaultNamespace = "VRGameSelectorServerDB"; container.DefaultMapping.NullForeignKey = true; OnSetContainerSettings(container); }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "EntitiesModel"; container.DefaultNamespace = "Package1"; container.NameGenerator.RemoveLeadingUnderscores = false; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "FluentModel"; container.DefaultNamespace = "MySQL"; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
public AudioTranscodingTarget GetMatchingAudioTranscoding(MetadataContainer info, int edition, out AudioMatch matchedSource) { matchedSource = null; if (info == null) { throw new ArgumentException("Parameter cannot be empty", nameof(info)); } if (!info.HasEdition(edition)) { throw new ArgumentException("Parameter is invalid", nameof(edition)); } int matchedAudioStream = info.Audio[edition].First().StreamIndex; foreach (AudioTranscodingTarget tDef in AudioTargets) { foreach (AudioInfo src in tDef.Sources) { if (src.Matches(info, edition, matchedAudioStream)) { matchedSource = new AudioMatch(); matchedSource.MatchedAudioStream = matchedAudioStream; matchedSource.MatchedAudioSource = src; return(tDef); } } } return(null); }
/// <summary> /// 元数据转换成第三方数据 /// </summary> /// <param name="metadataObject">元数据集合</param> /// <param name="id">属性对应key</param> /// <param name="data">属性对应byte数组</param> /// <param name="offsetStart">属性在数组中的偏移值</param> /// <param name="length">属性在byte数组中的长度</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public unsafe void DataProcessor(MetadataContainer metadataObject, byte id, byte[] data, int offsetStart, uint length) { if (metadataObject == null) { throw new ArgumentNullException("metadataObject"); } if (length == 0) { metadataObject.SetAttribute(id, new UInt16ArrayValueStored(new ushort[0])); return; } ushort[] array = new ushort[length / Size.UInt16]; if (array.Length <= 10) { fixed(byte *pByte = (&data[offsetStart])) { ushort *pData = (ushort *)pByte; for (int j = 0; j < array.Length; j++) { array[j] = *pData++; } } } else fixed(byte *pArr = &data[offsetStart]) { fixed(ushort *point = &array[0]) { Buffer.MemoryCopy((void *)new IntPtr(pArr), (void *)new IntPtr((byte *)point), length, length); //Native.Win32API.memcpy(new IntPtr((byte*)point), new IntPtr(pArr), length); } } metadataObject.SetAttribute(id, new UInt16ArrayValueStored(array)); }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "Connection"; container.DefaultNamespace = "ApplicationLib.Entities"; container.NameGenerator.SourceStrategy = NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
public void OnTypeCreation(MetadataContainer metadataContainer) { metadataContainer.Entity <Foo>().Projection(x => x.Id2).IsKey(); metadataContainer.Add(new FooMetadata()); metadataContainer.Entity <Bar>().Projection(x => x.FooSet).Association().WithName("MyAssociation"). WithThisKey(x => x.Id2, x => x.Id).WithOtherKey(x => x.Id2, x => x.Id); }
public static AttributeList FromXliffMetadata(MetadataContainer metadata) { if (metadata != null && metadata.HasGroups) { MetaGroup defaultGroup = null; foreach (var group in metadata.Groups) { if (group.Id == "XliffLib") { defaultGroup = group; break; } } if (defaultGroup != null) { var attributes = new AttributeList(); foreach (Meta item in defaultGroup.Containers.OfType <Meta>()) { attributes.Add(item.Type, item.NonTranslatableText); } return(attributes); } } return(null); }
public VideoTranscodingTarget GetMatchingVideoTranscoding(MetadataContainer info, int edition, int matchedAudioStream, out VideoMatch matchedSource) { matchedSource = null; if (info == null) { throw new ArgumentException("Parameter cannot be empty", nameof(info)); } if (!info.HasEdition(edition)) { throw new ArgumentException("Parameter is invalid", nameof(edition)); } foreach (VideoTranscodingTarget tDef in VideoTargets) { foreach (VideoInfo src in tDef.Sources) { if (src.Matches(info, edition, matchedAudioStream, VideoSettings.H264LevelCheckMethod)) { matchedSource = new VideoMatch(); matchedSource.MatchedAudioStream = matchedAudioStream; matchedSource.MatchedVideoSource = src; return(tDef); } } } return(null); }
/// <summary> /// 根据指定编号异步获取Ticker对象的操作 /// </summary> /// <param name="coinType">币种编号</param> /// <param name="platformType">平台编号</param> /// <returns>返回执行结果</returns> public async Task <IExecuteResult> GetTickerAsync(CoinTypes coinType, PlatformTypes platformType) { MetadataMessageTransaction transaction = SystemWorker.Instance.CreateMetadataTransaction("CoinAPI"); MetadataContainer reqMsg = new MetadataContainer(); reqMsg.SetAttribute(0x00, new MessageIdentityValueStored(new MessageIdentity { ProtocolId = 1, ServiceId = 0, DetailsId = 0 })); reqMsg.SetAttribute(0x0F, new ByteValueStored((byte)coinType)); reqMsg.SetAttribute(0x10, new ByteValueStored((byte)platformType)); TaskCompletionSource <IExecuteResult> completionSource = new TaskCompletionSource <IExecuteResult>(); Task <IExecuteResult> task = completionSource.Task; transaction.ResponseArrived += delegate(object sender, LightSingleArgEventArgs <MetadataContainer> e) { MetadataContainer rspMsg = e.Target; completionSource.SetResult((!rspMsg.IsAttibuteExsits(0x0A)) ? (rspMsg.GetAttribute(0x0F).GetValue <ResourceBlock>() == null ? ExecuteResult.Succeed(null) : ExecuteResult.Succeed(ConverterFactory.GetTickerConverter().ConvertToDomainObject(rspMsg.GetAttribute(0x0F).GetValue <ResourceBlock>()))) : ExecuteResult.Fail(rspMsg.GetAttribute(0x0A).GetValue <byte>(), rspMsg.GetAttribute(0x0B).GetValue <string>())); }; transaction.Timeout += delegate { completionSource.SetResult(ExecuteResult.Fail(SystemErrors.Timeout, string.Format("[Async Handle] Transaction: {0} execute timeout!", transaction.Identity))); }; transaction.Failed += delegate { completionSource.SetResult(ExecuteResult.Fail(SystemErrors.Unknown, string.Format("[Async Handle] Transaction: {0} execute failed!", transaction.Identity))); }; transaction.SendRequest(reqMsg); return(await task); }
/// <summary> /// 元数据转换成第三方数据 /// </summary> /// <param name="metadataObject">元数据集合</param> /// <param name="id">属性对应key</param> /// <param name="data">属性对应byte数组</param> /// <param name="offsetStart">属性在数组中的偏移值</param> /// <param name="length">属性在byte数组中的长度</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public unsafe void DataProcessor(MetadataContainer metadataObject, byte id, byte[] data, int offsetStart, uint length) { if (metadataObject == null) { throw new ArgumentNullException("metadataObject"); } if (length == 0) { metadataObject.SetAttribute(id, new IPEndPointArrayValueStored(new IPEndPoint[0])); return; } IPEndPoint[] array = new IPEndPoint[length / Size.IPEndPoint]; int innerOffset = 0; fixed(byte *pByte = &data[offsetStart]) { for (int i = 0; i < array.Length; i++) { array[i] = new IPEndPoint(new IPAddress(BitConverter.GetBytes(*(int *)(pByte + innerOffset))), *(int *)(pByte + innerOffset + 4)); innerOffset += (int)Size.IPEndPoint; } } metadataObject.SetAttribute(id, new IPEndPointArrayValueStored(array)); }
internal void HandleBusiness(Tuple <KAENetworkResource, ApplicationLevel> tag, MetadataMessageTransaction transaction, MessageIdentity reqMsgIdentity, object reqMsg, TransactionIdentity transactionIdentity) { MetadataKAEProcessor processor; //Targeted MessageIdentity CANNOT be support. if (!_processors.TryGetValue(reqMsgIdentity, out processor)) { _handleErrorSituation(transaction, KAEErrorCodes.NotSupportedMessageIdentity, "#We'd not supported current business protocol yet!"); return; } MetadataContainer rsp = processor.Process(transaction.Request); if (!transaction.NeedResponse) { return; } if (rsp == null) { _handleErrorSituation(transaction, KAEErrorCodes.UnhandledExceptionOccured, string.Empty); } else { _handleSucceedSituation(transaction, rsp); } }
public Task <MetadataContainer> ParseMediaStreamAsync(IEnumerable <IResourceAccessor> mediaResources) { var info = new MetadataContainer(); info.AddEdition(0); return(Task.FromResult(info)); }
public void WriteMetadataV2() { //Configuration var targetImage = GetTargetImage("img.png"); var copyImg = Path.Combine(targetImage.Directory.FullName, $@"tempImage_{Guid.NewGuid()}.png"); var fileCopy = new FileInfo(copyImg); const string text = "valeur à écrire"; try { //Test // créer un container vide: IMetadataContainer <UnitTestMetadata> container = new MetadataContainer <UnitTestMetadata> { { UnitTestMetadata.Metadata4, text } }; container.SaveNewFile(fileCopy, new Bitmap(10, 10)); // relis le fichier et vérifie que les données sont présente var result = fileCopy.ToMetadataContainer <UnitTestMetadata>(); //Verify Assert.AreEqual(1, result.Count); Assert.IsTrue(result.TryGetValue(UnitTestMetadata.Metadata4, out var val)); Assert.AreEqual(text, val); } finally { fileCopy.DeleteIfExist(); } }
private List <string> LoadMetadata(MetadataType type) { var loadingOptions = new MetadataLoadingOptions { LoadDefaultDatabaseOnly = type != MetadataType.Database, LoadSystemObjects = true }; var container = new MetadataContainer(TemporaryMetadataContainer.SQLContext) { LoadingOptions = loadingOptions }; var list = new MetadataList(container); list.Load(type, false); //list.Load(MetadataType.Database, false); //if (type == MetadataType.Schema) //{ // var defaultDb = list.Databases.FirstOrDefault(x => x.Default); // if (defaultDb != null) // { // defaultDb.Items.Load(type, false); // list = defaultDb.Items; // } //} return(list.Select(x => x.Name).ToList()); }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "VehicleVendorMySqlDbContext"; container.DefaultNamespace = "VehicleVendor.DataAceessData"; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
/// <summary> /// 元数据转换成第三方数据 /// </summary> /// <param name="metadataObject">元数据集合</param> /// <param name="id">属性对应key</param> /// <param name="data">属性对应byte数组</param> /// <param name="offsetStart">属性在数组中的偏移值</param> /// <param name="length">属性在byte数组中的长度</param> /// <exception cref="ArgumentNullException">参数不能为空</exception> public void DataProcessor(MetadataContainer metadataObject, byte id, byte[] data, int offsetStart, uint length) { if (metadataObject == null) { throw new ArgumentNullException("metadataObject"); } uint arrayLength = BitConverter.ToUInt32(data, offsetStart); ResourceBlock[] resourceBlocks = new ResourceBlock[arrayLength]; offsetStart += 4; for (int j = 0; j < arrayLength; j++) { uint resouceBlockLength = BitConverter.ToUInt32(data, offsetStart); if (resouceBlockLength == 0) { resourceBlocks[j] = null; offsetStart += 4; } else { resourceBlocks[j] = MetadataObjectEngine.GetObject(data, (uint)offsetStart, resouceBlockLength); offsetStart += (int)resouceBlockLength; } } metadataObject.SetAttribute(id, new ResourceBlockArrayStored(resourceBlocks)); }
static DataContext() { MetadataContainer = new DataMetadataSource().GetModel(); BackendConfiguration = new BackendConfiguration(); var connectionStringName = SiteSettings.Instance.ConnectionStringName; if (!string.IsNullOrEmpty(connectionStringName)) { ConnectionStringName = connectionStringName; } //#if DEBUG // Debug data access by logging queries //BackendConfiguration.Logging.LogEvents = LoggingLevel.Normal; //BackendConfiguration.Logging.StackTrace = true; //BackendConfiguration.Logging.EventStoreCapacity = 10000; //BackendConfiguration.Logging.MetricStoreCapacity = 3600; //BackendConfiguration.Logging.MetricStoreSnapshotInterval = 1000; //BackendConfiguration.Logging.Downloader.EventBinary = true; //BackendConfiguration.Logging.Downloader.MetricBinary = true; //BackendConfiguration.Logging.Downloader.Filename = "C:\\Temp\\DataAccess"; //BackendConfiguration.Logging.Downloader.MaxFileSizeKB = 1000; //BackendConfiguration.Logging.Downloader.NumberOfBackups = 3; //BackendConfiguration.Logging.Downloader.EventPollSeconds = 1; //BackendConfiguration.Logging.Downloader.MetricPollSeconds = 1; //#else BackendConfiguration.Logging.LogEvents = LoggingLevel.Errors; //#endif }
/// <summary> /// 发送一个响应消息 /// </summary> /// <param name="message">响应消息</param> /// <exception cref="System.ArgumentNullException">参数不能为空</exception> public override void SendResponse(MetadataContainer message) { if (message == null) { throw new ArgumentNullException("message"); } _response = message; }
/// <summary> /// 设置一个应答消息 /// </summary> /// <param name="response">应答消息</param> /// <exception cref="System.ArgumentNullException">参数不能为空</exception> public override void SetResponse(MetadataContainer response) { if (response == null) { throw new ArgumentNullException("response"); } _response = response; }
private IEnumerable <string> GetKeys <T>(MetadataContainer container) where T : class { var typeDescr = container.GetTypeDescriptor(typeof(T)); var properties = typeDescr.GetProperties().OfType <PropertyDescriptor>(); var result = properties.Where(p => p.Attributes[typeof(KeyAttribute)] != null).Select(x => x.Name).ToList(); return(result); }
protected override void SetContainerSettings(MetadataContainer container) { container.NameGenerator.RemoveCamelCase = false; container.NameGenerator.ResolveReservedWords = false; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "YouthConferenceModels"; container.DefaultNamespace = "YouthConference.Models"; container.NameGenerator.RemoveLeadingUnderscores = false; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
public BasicClonerTests() { _cache = FakeBasicDatabase.CreateDatabaseSchema(); _queryHelper = FakeBasicDatabase.CreateData(); _queryDispatcher = FakeBasicDatabase.CreateServer(_queryHelper); _executionPlanBuilder = new ExecutionPlanBuilder(null, _queryDispatcher, (IQueryDispatcher d, Settings s, ref MetadataContainer m) => m = _cache, null); }
public void MetadataDefaultValue_MetadataContainer() { MetadataContainer container; container = new MetadataContainer(); Assert.AreEqual(0, container.Groups.Count, "Groups count is incorrect."); Assert.AreEqual(false, container.HasGroups, "HasGroups is incorrect."); Assert.IsNull(container.Id, "Id is incorrect."); }
protected override MetadataContainer CreateModel() { MetadataContainer container = base.CreateModel(); container.NameGenerator.RemoveCamelCase = false; container.NameGenerator.ResolveReservedWords = false; container.NameGenerator.SourceStrategy = NamingSourceStrategy.Property; return(container); }
public bool Matches(MetadataContainer info, int edition) { bool bPass = true; bPass &= (ImageContainerType == ImageContainer.Unknown || ImageContainerType == info.Metadata[edition].ImageContainerType); bPass &= (PixelFormatType == PixelFormat.Unknown || PixelFormatType == info.Image[edition].PixelFormatType); return(bPass); }
private MetadataContainer GetSucceedResponseMessage(ResourceBlock data) { MetadataContainer rspMsg = new MetadataContainer(); rspMsg.SetAttribute(0x00, new MessageIdentityValueStored(new MessageIdentity { ProtocolId = 1, ServiceId = 0, DetailsId = 1 })); rspMsg.SetAttribute(0x0F, new ResourceBlockStored(data)); return(rspMsg); }
public bool Matches(MetadataContainer info, int edition, int audioStreamIndex) { bool bPass = true; bPass &= (AudioContainerType == AudioContainer.Unknown || AudioContainerType == info.Metadata[edition].AudioContainerType); bPass &= (Bitrate == 0 || Bitrate >= info.Audio[edition].First(s => s.StreamIndex == audioStreamIndex).Bitrate); bPass &= (Frequency == 0 || Frequency >= info.Audio[edition].First(s => s.StreamIndex == audioStreamIndex).Frequency); return(bPass); }
static DataContext() { MetadataContainer = new DataMetadataSource().GetModel(); BackendConfiguration = new BackendConfiguration(); #if DEBUG // Debug data access by logging queries BackendConfiguration.Logging.LogEvents = LoggingLevel.Normal; BackendConfiguration.Logging.StackTrace = true; BackendConfiguration.Logging.EventStoreCapacity = 10000; BackendConfiguration.Logging.MetricStoreCapacity = 3600; BackendConfiguration.Logging.MetricStoreSnapshotInterval = 1000; BackendConfiguration.Logging.Downloader.EventBinary = true; BackendConfiguration.Logging.Downloader.MetricBinary = true; BackendConfiguration.Logging.Downloader.Filename = "C:\\Temp\\DataAccess"; BackendConfiguration.Logging.Downloader.MaxFileSizeKB = 1000; BackendConfiguration.Logging.Downloader.NumberOfBackups = 3; BackendConfiguration.Logging.Downloader.EventPollSeconds = 1; BackendConfiguration.Logging.Downloader.MetricPollSeconds = 1; #else BackendConfiguration.Logging.LogEvents = LoggingLevel.Errors; #endif }
public void OnTypeCreation(MetadataContainer metadataContainer) { metadataContainer.Entity<Dog>().Projection(x => x.Trainers).M2M( x => x.DogTrainers, x => x.DogTrainers, x => x.Dogs); }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "EntitiesModel"; container.DefaultNamespace = "JobScheduler"; container.NameGenerator.RemoveLeadingUnderscores = false; container.NameGenerator.SourceStrategy = Property; container.NameGenerator.RemoveCamelCase = false; }
protected override void SetContainerSettings(MetadataContainer container) { container.NameGenerator.RemoveCamelCase = false; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; }
protected override void SetContainerSettings(MetadataContainer container) { container.Name = "VehicleVendorMySqlDbContext"; container.DefaultNamespace = "VehicleVendor.DataAceessData"; container.NameGenerator.SourceStrategy = Telerik.OpenAccess.Metadata.NamingSourceStrategy.Property; container.NameGenerator.RemoveCamelCase = false; }
public void TestInitialize() { this._element = new MetadataContainer(); this._provider = this._element; }
public void DeserializeFromXml_RegressionTestForEmptyMetadataElement() { MetadataContainer container = new MetadataContainer(); container.Metadata = new PropertySet(); container.FollowingElement = 1; XmlSerializer serializer = new XmlSerializer(typeof(MetadataContainer)); StringWriter output = new StringWriter(); serializer.Serialize(output, container); MetadataContainer result = (MetadataContainer)serializer.Deserialize(new StringReader(output.ToString())); Assert.Count(0, result.Metadata); Assert.AreEqual(1, result.FollowingElement); }
public virtual void BuildFrameIndex() { if (Reader == null) { return; } HighestVideoFrameNumber = 0; TotalVideoFrameCount = 0; Dictionary<uint, frameXrefEntry> vidfXrefList = new Dictionary<uint, frameXrefEntry>(); Dictionary<uint, frameXrefEntry> audfXrefList = new Dictionary<uint, frameXrefEntry>(); MetadataContainer metadataContainer = new MetadataContainer(); uint highestFrameNumber = 0; for (int blockIndexPos = 0; blockIndexPos < BlockIndex.Length; blockIndexPos++) { var block = BlockIndex[blockIndexPos]; Reader[block.fileNumber].BaseStream.Position = block.position; /* 16 bytes are enough for size, type and timestamp, but we try to read all blocks up to 1k */ byte[] buf = new byte[1024]; /* read MLV block header */ if (Reader[block.fileNumber].Read(buf, 0, 16) != 16) { break; } uint size = BitConverter.ToUInt32(buf, 4); string type = Encoding.UTF8.GetString(buf, 0, 4); UInt64 timestamp = BitConverter.ToUInt64(buf, 8); /* read that block, up to 256 byte */ Reader[block.fileNumber].BaseStream.Position = block.position; /* read MLV block header */ int readSize = (int)Math.Min(size, 256); if (Reader[block.fileNumber].Read(buf, 0, readSize) != readSize) { break; } object blockData = MLVTypes.ToStruct(buf); switch (type) { case "NULL": continue; case "VIDF": { MLVTypes.mlv_vidf_hdr_t header = (MLVTypes.mlv_vidf_hdr_t)blockData; if (!vidfXrefList.ContainsKey(header.frameNumber)) { frameXrefEntry entry = new frameXrefEntry(); entry.blockIndexPos = blockIndexPos; entry.metadata = metadataContainer.Metadata; entry.timestamp = timestamp; vidfXrefList.Add(header.frameNumber, entry); } else { FrameRedundantErrors++; } highestFrameNumber = Math.Max(highestFrameNumber, header.frameNumber); } break; case "AUDF": { MLVTypes.mlv_audf_hdr_t header = (MLVTypes.mlv_audf_hdr_t)blockData; if (!audfXrefList.ContainsKey(header.frameNumber)) { frameXrefEntry entry = new frameXrefEntry(); entry.blockIndexPos = blockIndexPos; entry.metadata = metadataContainer.Metadata; entry.timestamp = timestamp; audfXrefList.Add(header.frameNumber, entry); } else { FrameRedundantErrors++; } } break; default: metadataContainer.Update(type, blockData); break; } } /* count the number of missing video frames */ uint curFrame = 0; foreach (var elem in vidfXrefList.OrderBy(elem => elem.Key)) { if (elem.Key != curFrame) { curFrame = elem.Key; FrameMissingErrors++; } curFrame++; } VidfXrefList = vidfXrefList; AudfXrefList = audfXrefList; TotalVideoFrameCount = (uint)vidfXrefList.Count; HighestVideoFrameNumber = highestFrameNumber; }