public IRWSectionFactory GetFactory(RWSectionHeader header, RWSection parent) { switch (header.Id) { case RWSections.RWStruct: switch (parent.Header.Id) { case RWSections.RWTextureDictionary: return new RWSectionFactory<TextureDictionaryStructureSection>(); case RWSections.RWTextureNative: return new RWSectionFactory<TextureNativeStructureSection>(); default: return null; } case RWSections.RWExtension: switch (parent.Header.Id) { default: return null; } case RWSections.RWTextureDictionary: return new RWSectionFactory<TextureDictionarySection>(); case RWSections.RWTextureNative: return new RWSectionFactory<TextureNativeSection>(); default: return null; } }
private IRWSectionFactory GetFactory(RWSectionHeader header, RWSection parent) { IRWSectionFactory factory = null; foreach (ISectionLoader loader in loaders) { factory = loader.GetFactory(header, parent); if (factory != null) return factory; } return (new RWSectionLoader() as ISectionLoader).GetFactory(header, parent); }
public IRWSectionFactory GetFactory(RWSectionHeader header, RWSection parent) { switch (header.Id) { case RWSections.RWNull: return new RWSectionFactory<NullSection>(); case RWSections.RWExtension: return new RWSectionFactory<ExtensionSection>(); case RWSections.RWStruct: return new RWSectionFactory<StructureSection>(); default: return new RWSectionFactory<UnknownSection>(); } }
private bool IsContainerSection(BinaryReader reader, RWSectionHeader header, RWSection parent) { reader.BaseStream.Seek(header.StartPos, SeekOrigin.Begin); if (header.Size > HeaderSize) { RWSectionHeader newHeader = new RWSectionHeader(); newHeader.LoadFromStream(reader); if ((newHeader.Version == header.Version) && (newHeader.Size < header.Size)) { reader.BaseStream.Seek(header.StartPos, SeekOrigin.Begin); return true; } } reader.BaseStream.Seek(header.StartPos + header.Size, SeekOrigin.Begin); return false; }
public IRWSectionFactory GetFactory(RWSectionHeader header, RWSection parent) { switch (header.Id) { case RWSections.RWExtension: switch (parent.Header.Id) { case RWSections.RWAtomic: return new RWSectionFactory<AtomicExtensionSection>(); case RWSections.RWClump: return new RWSectionFactory<ClumpExtensionSection>(); case RWSections.RWFrameList: return new RWSectionFactory<FrameListExtensionSection>(); case RWSections.RWGeometry: return new RWSectionFactory<GeometryExtensionSection>(); case RWSections.RWMaterial: return new RWSectionFactory<MaterialExtensionSection>(); case RWSections.RWTexture: return new RWSectionFactory<TextureExtensionSection>(); default: return null; } case RWSections.RWStruct: switch (parent.Header.Id) { case RWSections.RWAtomic: return new RWSectionFactory<AtomicStructureSection>(); case RWSections.RWClump: return new RWSectionFactory<ClumpStructureSection>(); case RWSections.RWFrameList: return new RWSectionFactory<FrameListStructureSection>(); case RWSections.RWGeometryList: return new RWSectionFactory<GeometryListStructureSection>(); case RWSections.RWGeometry: return new RWSectionFactory<GeometryStructureSection>(); case RWSections.RWMaterialList: return new RWSectionFactory<MaterialListStructureSection>(); case RWSections.RWMaterial: return new RWSectionFactory<MaterialStructureSection>(); case RWSections.RWTexture: return new RWSectionFactory<TextureStructureSection>(); default: return null; } case RWSections.RWAtomic: return new RWSectionFactory<AtomicSection>(); case RWSections.RWClump: return new RWSectionFactory<ClumpSection>(); case RWSections.RWFrameList: return new RWSectionFactory<FrameListSection>(); case RWSections.RWGeometryList: return new RWSectionFactory<GeometryListSection>(); case RWSections.RWGeometry: return new RWSectionFactory<GeometrySection>(); case RWSections.RWMaterialList: return new RWSectionFactory<MaterialListSection>(); case RWSections.RWMaterial: return new RWSectionFactory<MaterialSection>(); case RWSections.RWTexture: return new RWSectionFactory<TextureSection>(); case RWSections.RWFrame: return new RWSectionFactory<FrameSection>(); case RWSections.RWBinMeshPLG: return new RWSectionFactory<BinMeshPLGSection>(); case RWSections.RWMaterialEffectsPLG: return new RWSectionFactory<MaterialEffectsPLGSection>(); case RWSections.RWReflectionmaterial: return new RWSectionFactory<ReflectionMaterialSection>(); case RWSections.RWSpecularMaterial: return new RWSectionFactory<SpecularMaterialSection>(); case RWSections.RWUVAnimationPLG: return new RWSectionFactory<UVAnimationPLGSection>(); default: return null; } }
private RWSection LoadSection(BinaryReader reader, RWSection parentSection) { RWSectionHeader header = new RWSectionHeader(); header.LoadFromStream(reader); RWSection section = this.GetFactory(header, parentSection).GetSection(reader, header); if ((section is UnknownSection) && IsContainerSection(reader, header, parentSection)) section = (new RWSectionFactory<ContainerSection>() as IRWSectionFactory).GetSection(reader, header); return section; }
/// <summary> /// Получить заголовок корневой секции. /// </summary> /// <param name="reader">Reader потока.</param> /// <returns>Заголовок корневой секции.</returns> public static RWSectionHeader GetRootHeader(BinaryReader reader) { RWSectionHeader header = new RWSectionHeader(); header.Id = RWSections.RWRoot; header.StartPos = 0; header.Size = (int)reader.BaseStream.Length; return header; }