示例#1
0
文件: TSS.cs 项目: talestra/tov
            public StringInfo(TSS Tss, int StringzOffset, SliceStream PointerStream)
            {
                this.PointerStream = PointerStream;

                if (this.PointerStream.Length != 4)
                {
                    throw (new InvalidOperationException("Invalid PointerStream. Length != 4"));
                }
                if (this.PointerValue != StringzOffset)
                {
                    throw (new InvalidOperationException("StringzOffset Doesn't Match PointerStream Data"));
                }

                this.StringzOffset = StringzOffset;
                this.StringzLength = Tss.CountStringz(StringzOffset);
                this.Text          = Tss.ReadStringz(StringzOffset);
            }
示例#2
0
文件: TSS.Nodes.cs 项目: talestra/tov
            private IEnumerable <dynamic> GetElements(bool AsInt)
            {
                var ArrayStream = SliceStream.CreateWithLength(TSS.TextStream, ArrayPointer, ArrayNumberOfBytes);
                {
                    switch (ValuesType)
                    {
                    case ValueType.String:
                        if (!AsInt)
                        {
                            for (int n = 0; n < ArrayNumberOfElements; n++)
                            {
                                yield return(TSS.ReadStringz((int)(uint)ArrayStream.ReadStruct <uint_be>()));
                            }
                        }
                        else
                        {
                            for (int n = 0; n < ArrayNumberOfElements; n++)
                            {
                                yield return((int)(uint)ArrayStream.ReadStruct <uint_be>());
                            }
                        }
                        break;

                    case ValueType.Integer32Signed:
                        for (int n = 0; n < ArrayNumberOfElements; n++)
                        {
                            yield return((int)(uint)ArrayStream.ReadStruct <uint_be>());
                        }
                        break;

                    case ValueType.Float32:
                        if (!AsInt)
                        {
                            for (int n = 0; n < ArrayNumberOfElements; n++)
                            {
                                yield return((float)ArrayStream.ReadStruct <float_be>());
                            }
                        }
                        else
                        {
                            for (int n = 0; n < ArrayNumberOfElements; n++)
                            {
                                yield return((int)(uint)ArrayStream.ReadStruct <uint_be>());
                            }
                        }
                        break;

                    default:
                    {
                        Console.Error.WriteLine("Unhandled " + ValuesType + "(" + ArrayPointer + "," + ArrayNumberOfBytes + ")[" + ArrayNumberOfElements + "]");
                        //if (ArrayNumberOfElements == 0)
                        //{
                        //	yield return "<TODO " + "Unhandled " + ValuesType + "(" + ArrayPointer + "," + ArrayNumberOfBytes + ")>";
                        //}
                        //else
                        {
                            yield return("<TODO " + "Unhandled " + ValuesType + ">");

                            for (int n = 0; n < ArrayNumberOfBytes; n++)
                            {
                                yield return("" + ArrayStream.ReadStruct <byte>());
                            }
                        }
                    }
                    break;
                        //throw (new Exception("Unhandled " + ValuesType));
                    }
                }
            }