Exemplo n.º 1
0
        private void SerializeCollection(FileNamePairCollection aFilesToSave, string aProposedFileName, SymbolCollection aCollection)
        {
            SymbolCollectionList list = new SymbolCollectionList();

            list.Add(aCollection);
            SerializeCollection(aFilesToSave, aProposedFileName, list);
        }
Exemplo n.º 2
0
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            // This gives us explicit activations
            SymbolCollectionList list = iRelocator.CollectionList;

            foreach (SymbolCollection col in list)
            {
                yield return(col);
            }

            // Next we need fixed collections
            IEnumerable <SymbolCollection> fixedCols = iRelocator.SourceManager.GetFixedCollectionEnumerator();

            foreach (SymbolCollection col in fixedCols)
            {
                if (col.IsFixed)
                {
                    yield return(col);
                }
            }
        }
Exemplo n.º 3
0
        public override bool SerializeTaggedCollections(FileNamePairCollection aFilesToSave)
        {
            int initialFileCount = aFilesToSave.Count;

            // Will contain tagged fixed collections
            SymbolCollectionList symColFixed = new SymbolCollectionList();

            // Will contain dynamically relocated collections
            SymbolCollectionList symColDynamicRelocations = new SymbolCollectionList();

            // Find tagged collections
            string           fixedSymbolCollectionFileName = string.Empty;
            SymSourceManager sourceManager = iQueryAPI.SourceManager;

            foreach (SymSource source in sourceManager)
            {
                int count = source.Count;
                for (int i = 0; i < count; i++)
                {
                    SymbolCollection col = source[i];
                    if (col.Tagged)
                    {
                        if (col.IsFixed)
                        {
                            symColFixed.Add(col);

                            // Save the ROM symbol file name (if present)
                            if (string.IsNullOrEmpty(fixedSymbolCollectionFileName))
                            {
                                fixedSymbolCollectionFileName = source.FileName;
                            }
                        }
                        else
                        {
                            symColDynamicRelocations.Add(col);
                        }
                    }
                }
            }

            // Now save them to needed files. We create one file for all the fixed
            // collections and then individual files for all the dynamically relocated
            // collections.
            //
            // In all cases, we create temporary files which are to be deleted by
            // the client.
            if (symColFixed.Count > 0)
            {
                SerializeCollection(aFilesToSave, Path.GetFileNameWithoutExtension(fixedSymbolCollectionFileName) + ".symbol", symColFixed);
            }
            if (symColDynamicRelocations.Count > 0)
            {
                foreach (SymbolCollection col in symColDynamicRelocations)
                {
                    // For the dynamically relocated collections, we must generate a file name based
                    // upon the collection details.
                    string fileName = Path.GetFileNameWithoutExtension(col.FileName.EitherFullNameButDevicePreferred) + ".symbol";
                    SerializeCollection(aFilesToSave, fileName, col);
                }
            }

            return(aFilesToSave.Count != initialFileCount);
        }
Exemplo n.º 4
0
        private void SerializeCollection(FileNamePairCollection aFilesToSave, string aProposedFileName, SymbolCollectionList aList)
        {
            string tempFileName = Path.GetTempFileName();
            //
            FileNamePair fileNamePair = new FileNamePair(tempFileName);

            fileNamePair.Destination = string.Format("/Symbols/{0}", Path.GetFileName(aProposedFileName));
            fileNamePair.DeleteFile  = true;

            // Make sure the collections are sorted in order
            aList.SortByCollectionAddress();

            using (FileStream stream = new FileStream(tempFileName, FileMode.Create))
            {
                aList.Serialize(stream);
            }
            //
            aFilesToSave.Add(fileNamePair);
        }