public STUD(Stream input, bool initalizeAll = true, STUDManager manager = null, bool leaveOpen = false, bool suppress = false) { if (manager == null) { this.manager = STUDManager.Instance; manager = this.manager; } else { this.manager = manager; } if (input == null) { return; } this.suppress = suppress; studstream = input; using (BinaryReader reader = new BinaryReader(input, Encoding.Default, leaveOpen)) { start = input.Position; header = reader.Read <STUDHeader>(); if (header.magic != STUD_MAGIC) { records = new STUDInstanceRecord[0]; instances = new ISTUDInstance[0]; return; } input.Position = start + (long)header.instanceTableOffset; STUDArrayInfo ptr = reader.Read <STUDArrayInfo>(); records = new STUDInstanceRecord[ptr.count]; instances = new ISTUDInstance[ptr.count]; for (ulong i = 0; i < ptr.count; ++i) { records[i] = reader.Read <STUDInstanceRecord>(); } end = input.Position; if (initalizeAll) { InitializeAll(input, suppress); } } }
public static STUDManager NewInstance() { STUDManager manager = new STUDManager(); Assembly asm = typeof(ISTUDInstance).Assembly; Type t = typeof(ISTUDInstance); List <Type> types = asm.GetTypes().Where(type => type != t && t.IsAssignableFrom(type)).ToList(); foreach (Type type in types) { if (type.IsInterface) { continue; } if (type.IsEquivalentTo(typeof(STUDummy))) { continue; } manager.AddInstance(type); } return(manager); }