// Add new catalog entry to proper scope // Risky: caller may not know where it went; maybe merge Global & Persistent? internal void AddEntry(string name, DataType datatype, EntryKinds kind, EntryFlags flags = EntryFlags.None, TypedValue value = null) { var scope = (flags.HasFlag(EntryFlags.Persistent)) ? _catalog.PersistentVars : this; var entry = new CatalogEntry { Name = name, DataType = datatype, Kind = kind, Flags = flags, Scope = scope, Value = value, }; scope.Add(entry); // update catalog if (flags.HasFlag(EntryFlags.Persistent) && _catalog.SaveFlag) { Logger.Assert(entry.Kind == EntryKinds.Type || entry.Value == null, entry); if (entry.Kind == EntryKinds.Type) { _catalog.StoreEntry(entry); } } }
protected override bool CreateChildren(bool diffOldChildren = false) { try { if (_mergedDescriptor.PropertyType.IsValueType || EntryFlags.HasFlag(Flags.Immutable)) { return(base.CreateChildren(diffOldChildren)); } ChildCollection.Clear(); var mergedProperties = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties( _mergedDescriptor.GetValues(_objects), this, _propertySort, OwnerTab); Debug.WriteLineIf( CompModSwitches.DebugGridView.TraceVerbose && mergedProperties is null, "PropertyGridView: MergedProps returned null!"); if (mergedProperties is not null) { ChildCollection.AddRange(mergedProperties); } bool expandable = Children.Count > 0; if (!expandable) { SetFlag(Flags.ExpandableFailed, true); } return(expandable); } catch (Exception e) { Debug.Fail(e.Message); return(false); } }
private void ReadEntry(UInt32 currentBlock, UInt32 offset, String currentPath) { m_br.BaseStream.Seek((currentBlock * m_rootHeader.blockSize) + offset, SeekOrigin.Begin); // Check creation of directory. if (Directory.Exists(currentPath) == false) { Directory.CreateDirectory(currentPath); } int entrycount = 0; bool lastEntry = false; while (lastEntry == false) { // Entry. //Console.Write(Environment.NewLine); //Console.WriteLine("Entry: "); EntryHeader eh = new EntryHeader(); // Flags. eh.flags = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Convert flags. EntryFlags entryFlags = EntryFlags.None; if ((eh.flags & 0x80000000) == 0x80000000) { entryFlags |= EntryFlags.LastEntryInDir; } if ((eh.flags & 0x40000000) == 0x40000000) { entryFlags |= EntryFlags.LastEntryInBlock; } if ((eh.flags & 0x07) == 0x07) { entryFlags |= EntryFlags.Directory; } else if ((eh.flags & 0x06) == 0x06) { entryFlags |= EntryFlags.SpecialFile; } else if ((eh.flags & 0x02) == 0x02) { entryFlags |= EntryFlags.File; } if (entryFlags.HasFlag(EntryFlags.LastEntryInDir) == true) { lastEntry = true; } // Identifier. eh.id = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Type. eh.type = m_br.ReadBytes(m_entryTypeSize); //Console.Write("Type: "); //for (int i = 0; i < m_entryTypeSize; i++) // Console.Write((Char)eh.type[i]); //Console.Write(Environment.NewLine); // Block size. eh.blockSize = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // failsafe: Read error, return immediately. if (eh.blockSize != m_rootHeader.blockSize) { break; } entrycount++; // Length of the entry in bytes. eh.byteCount = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Length of the entry in blocks. eh.blockCount = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); //Console.WriteLine("BlockCount: " + eh.blockCount); // Burst. eh.burst = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Gap. eh.gap = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Filename. eh.filename = m_br.ReadBytes(m_filenameSize); //Console.Write("Filename: "); //for (int i = 0; i < m_filenameSize; i++) // Console.Write((Char)eh.filename[i]); //Console.Write(Environment.NewLine); // Number of avatars. eh.avatarsCount = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); // Offset to the avatars, from the beginning of the disk, in blocks. eh.avatars = new UInt32[eh.avatarsCount + 1]; //Console.Write("Locations of the avatars: "); for (int i = 0; i < eh.avatarsCount + 1; i++) { eh.avatars[i] = Util.ArrayToUint32(m_br.ReadBytes(sizeof(UInt32))); //Console.Write(eh.avatars[i] + " "); } //Console.Write(Environment.NewLine); // Add entry header to the list. m_entryHeaderList.Add(eh); //-- if (m_blocks.ContainsKey(currentBlock) == false) { m_blocks[currentBlock] = new BlockInfo(); } BlockInfo block = m_blocks[currentBlock]; if (block.entryHeaders == null) { block.entryHeaders = new List <EntryHeader>(); } block.entryHeaders.Add(eh); m_blocks[currentBlock] = block; //-- //if (entryFlags.HasFlag(EntryFlags.SpecialFile) == true) //{ // Console.Write("Special File: "); // for (int i = 0; i < m_filenameSize; i++) // Console.Write((Char)eh.filename[i]); // Console.Write(Environment.NewLine); //} // Create directory. if (entryFlags.HasFlag(EntryFlags.Directory) == true) { // Store the current position. long currentPosition = m_br.BaseStream.Position; // For the filename we need to convert from Byte ASCII to Unicode string and trim the padding ('\0'). Byte[] bytes = Encoding.Convert(Encoding.ASCII, Encoding.Unicode, eh.filename); String unicode = Encoding.Unicode.GetString(bytes).Trim('\0'); String dirPath = currentPath + m_separator + unicode; ReadDirectory(eh.avatars[0], 0, dirPath); // Return to previous position. m_br.BaseStream.Seek(currentPosition, SeekOrigin.Begin); } else // Write file. { // [CRIS] special case: Disc label is the header of the FileSystem referenced as a file. Do not create this file. if (Encoding.ASCII.GetString(eh.filename).Contains("Disc label") == false && Encoding.ASCII.GetString(eh.type).Equals("*lbl") == false) { // Store the current position. long currentPosition = m_br.BaseStream.Position; // For the filename we need to convert from Byte ASCII to Unicode string and trim the padding ('\0'). Byte[] bytes = Encoding.Convert(Encoding.ASCII, Encoding.Unicode, eh.filename); String unicode = Encoding.Unicode.GetString(bytes).Trim('\0'); String filePath = currentPath + m_separator + unicode; //Console.WriteLine("Writing '" + unicode + "'..."); ReadFile(eh.avatars[0], filePath, eh.byteCount); // Return to previous position. m_br.BaseStream.Seek(currentPosition, SeekOrigin.Begin); } } } }
internal override object GetValueOwnerInternal() => _mergedDescriptor.PropertyType.IsValueType || EntryFlags.HasFlag(Flags.Immutable) ? base.GetValueOwnerInternal() : _mergedDescriptor.GetValues(_objects);