示例#1
0
        public void Load(CtfMetadataParser parser)
        {
            Dictionary <string, CtfMetadataType> typeAlias = new Dictionary <string, CtfMetadataType>();
            List <CtfStream> streams = new List <CtfStream>();

            foreach (CtfMetadataDeclaration entry in parser.Parse())
            {
                switch (entry.Definition)
                {
                case CtfDeclarationTypes.Clock:
                    CtfClock clock = new CtfClock(entry.Properties);
                    _clocks[clock.Name] = clock;
                    break;

                case CtfDeclarationTypes.Trace:
                    Trace = new CtfTrace(entry.Properties);
                    break;

                case CtfDeclarationTypes.Environment:
                    Environment = new CtfEnvironment(entry.Properties);
                    break;

                case CtfDeclarationTypes.TypeAlias:
                    typeAlias[entry.Name] = entry.Type;
                    break;

                case CtfDeclarationTypes.Struct:
                    typeAlias[entry.Name] = new CtfStruct(entry.Properties, entry.Fields);
                    break;

                case CtfDeclarationTypes.Stream:
                    CtfStream stream = new CtfStream(entry.Properties);
                    while (streams.Count <= stream.ID)
                    {
                        streams.Add(null);
                    }

                    streams[stream.ID] = stream;
                    break;

                case CtfDeclarationTypes.Event:
                    CtfEvent evt = new CtfEvent(entry.Properties);
                    streams[evt.Stream].AddEvent(evt);
                    break;

                default:
                    Debug.Fail("Unknown metadata entry type.");
                    break;
                }
            }

            Streams = streams.ToArray();
            ResolveReferences(typeAlias);
        }
示例#2
0
 public CtfMetadata(CtfMetadataParser parser)
 {
     Load(parser);
 }