Inheritance: System.Html.EventTarget
        public ExportTable(Stream Data)
        {
            FileReader Reader = new FileReader(Data, false);

            int StartLocation = Data.BinaryContains(new byte[] { (byte)'E', (byte)'N', (byte)'T', (byte)'P' });
            Reader.Seek(StartLocation);

            while (true)
            {
                string EndTest = ASCIIEncoding.ASCII.GetString(Reader.ReadBytes(4));

                if (!EndTest.Equals("EENT", StringComparison.InvariantCultureIgnoreCase))
                {
                    Reader.Seek(Reader.Position - 4);
                    uint TrackID = Reader.ReadUInt32();
                    uint Address = Reader.ReadUInt32();
                    //TrackID, Address
                    m_SubRoutines.Add(TrackID, Address);
                }
                else
                {
                    break;
                }
            }
        }
示例#2
0
文件: Program.cs 项目: ayoung/dotless
        private static IEnumerable<string> Compile(ILessEngine engine, string inputFilePath, string outputFilePath)
        {
            Console.Write("Compiling {0} -> {1} ", inputFilePath, outputFilePath);
            try
            {
                var source = new FileReader().GetFileContents(inputFilePath);
                var css = engine.TransformToCss(source, inputFilePath);

                File.WriteAllText(outputFilePath, css);
                Console.WriteLine("[Done]");

                return new[] { inputFilePath }.Concat(engine.GetImports());
            }
            catch(IOException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine("[FAILED]");
                Console.WriteLine("Compilation failed: {0}", ex.Message);
                Console.WriteLine(ex.StackTrace);
                return null;
            }
        }
示例#3
0
        public DGRP(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            m_Version = Reader.ReadUShort();

            switch(m_Version)
            {
                case 20000:
                    ImageCount = Reader.ReadUShort();
                    break;
                case 20001:
                    ImageCount = Reader.ReadUShort();
                    break;
                case 20003:
                    ImageCount = Reader.ReadUInt32();
                    break;
                case 20004:
                    ImageCount = Reader.ReadUInt32();
                    break;
            }

            for(int i = 0; i < ImageCount; i++)
            {
                Images.Add(new DGRPImg(Reader, m_Version));
            }

            Reader.Close();
            m_Data = null;
        }
示例#4
0
        public SPR(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Version1 = Reader.ReadUShort();
            Version2 = Reader.ReadUShort();

            if(Version1 == 0)
            {
                Version = Version2;
                Reader = new FileReader(new MemoryStream(Reader.ReadToEnd()), true);
            }
            else
                Version = Version1;

            uint SpriteCount = Reader.ReadUInt32();
            m_PaletteID = Reader.ReadUInt32();

            if (Version >= 502 && Version <= 505)
            {
                //TODO: Should this be stored?
                for (int i = 0; i < SpriteCount; i++)
                    m_OffsetTable.Add(Reader.ReadUInt32());
            }
            else
                m_OffsetTable.Add((uint)Reader.Position);

            Reader.Close();
            //m_Data = null; //DON'T DO THIS!
        }
示例#5
0
        public SPR2(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Version = Reader.ReadUInt32();
            uint SpriteCount = 0;

            if(Version == 1000)
            {
                SpriteCount = Reader.ReadUInt32();
                m_PaletteID = Reader.ReadUInt32();

                for (int i = 0; i < SpriteCount; i++)
                    m_OffsetTable.Add(Reader.ReadUInt32());
            }
            else
            {
                m_PaletteID = Reader.ReadUInt32();
                SpriteCount = Reader.ReadUInt32();

                m_OffsetTable.Add((uint)Reader.Position);
            }

            Reader.Close();
            //m_Data = null; //Don't do this here!
        }
示例#6
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                throw new FileNotFoundException("I need some sample input in the form of a path mate!  How can I work without some input from your side?");
            }

            if (!File.Exists(args[0]))
            {
                throw new FileLoadException("This file does not exist.  Wtf?");
            }

            var lineEnumerator = new FileReader(args[0]).GetEnumerator();

            var mineFields = GetMineFields(lineEnumerator);

            if (mineFields.Count == 0)
            {
                throw new Exception("I found no mine fields in your file, and that's probably due to invalid formatting from your side.  Double check you file next time please.");
            }
            for (var i = 0; i < mineFields.Count; i++)
            {
                Console.WriteLine(String.Format("Field #{0}", i + 1));
                Console.WriteLine(mineFields[i]);
            }

            if (Debugger.IsAttached) //Running from the IDE
            {
                Console.ReadKey();
            }
        }
示例#7
0
        public FCNS(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadInt32(); //4 bytes always set to 0.
            int Version = Reader.ReadInt32();
            Reader.ReadInt32(); //'SNCF'

            uint Count = Reader.ReadUInt32();

            for(int i = 0; i < Count; i++)
            {
                if(Version == 1)
                {
                    FCNSConstant Constant = new FCNSConstant();
                    Constant.Name = Reader.ReadPaddedCString();
                    Constant.Value = Reader.ReadPaddedCString();
                    Reader.ReadPaddedCString(); //Description
                }
                else
                {
                    FCNSConstant Constant = new FCNSConstant();
                    Constant.Name = Reader.ReadString();
                    Constant.Value = Reader.ReadString();
                    Reader.ReadString(); //Description
                }
            }

            Reader.Close();
            m_Data = null;
        }
示例#8
0
        public FBMP(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), true);
            BitmapStream = new MemoryStream(Reader.ReadToEnd());

            Reader.Close();
        }
示例#9
0
 static void Main(string[] args)
 {
     var file = new FileReader();
     file.ReadToArray("numbers.txt");
     var inv = new Inversion();
     var sor = inv.CountInversion(file.GetArray());
     Int64 a = inv.inversionCount;
     Console.WriteLine(a);
 }
示例#10
0
        public HLS(Stream Data)
        {
            if (Data != null)
            {
                m_Reader = new FileReader(Data, false);
                m_Reader.Seek(0);
            }
            else
                return;

            uint Unknown = m_Reader.ReadUInt32();

            try
            {
                if (Unknown == 1) //First format
                {
                    if ((m_Reader.StreamLength - m_Reader.Position) > 4) //... because sometimes it will just end here D:
                    {
                        uint Count = m_Reader.ReadUInt32();

                        for (int i = 0; i < Count; i++)
                            SoundsAndHitlists.Add(m_Reader.ReadUInt32());
                    }
                }
                else
                {
                    string Str = m_Reader.ReadString((int)Unknown).Replace("\n", "");
                    string[] SplitByComma = Str.Split(',');

                    for(int i = 0; i < SplitByComma.Length; i++)
                    {
                        string[] SplitByDash = SplitByComma[i].Split('-');

                        if(SplitByDash.Length > 1)
                        {
                            uint Min = Convert.ToUInt32(SplitByDash[0]);
                            uint Max = Convert.ToUInt32(SplitByDash[1]);

                            for(uint j = Min; j <= Max; j++)
                                SoundsAndHitlists.Add(j);
                        }
                        else
                            SoundsAndHitlists.Add(Convert.ToUInt32(SplitByComma[i]));
                    }
                }
            }
            catch
            {
                m_Reader.Seek(4);
                for (int i = 0; i < Unknown; i++)
                    SoundsAndHitlists.Add(m_Reader.ReadUInt32());

                m_Reader.Close();
            }

            m_Reader.Close();
        }
示例#11
0
        public FWAV(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            TrackEventPair = Reader.ReadCString();

            Reader.Close();
            m_Data = null;
        }
示例#12
0
        /// <summary>
        /// Constructs a new instance of the HandGroup class.
        /// </summary>
        /// <param name="Data">A stream of data retrieved from a FAR3 archive.</param>
        public HandGroup(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version.

            Light = new HandSet(m_Reader);
            Medium = new HandSet(m_Reader);
            Dark = new HandSet(m_Reader);
        }
示例#13
0
        public BCON(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            byte NumConstants = Reader.ReadByte();
            Reader.ReadByte(); //Unknown.

            for (int i = 0; i < NumConstants; i++)
                Constants.Add(Reader.ReadInt16());
        }
示例#14
0
        public void should_be_able_to_read_file_from_disk()
        {
            var content = @"This is a temporary content!!!";
            var tempFile = Path.GetTempFileName();

            File.WriteAllText(tempFile, content);

            var result = new FileReader().Read(tempFile);

            Assert.AreEqual(content, result);
        }
示例#15
0
        public GLOB(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            ASCIIEncoding Enc = new ASCIIEncoding();
            byte[] Data = Reader.ReadToEnd();
            SemiGlobalIFF = Enc.GetString(Data);

            Reader.Close();
            m_Data = null;
        }
示例#16
0
        public Outfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Version = m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown

            LightAppearance = ReadBackwardsID();
            MediumAppearance = ReadBackwardsID();
            DarkAppearance = ReadBackwardsID();
            m_HandGroup = m_Reader.ReadUInt32();
            Region = (OutfitRegion)Endian.SwapUInt32(m_Reader.ReadUInt32());
        }
示例#17
0
        /// <summary>
        /// Add the contents of the file to the root BoostInfoTree.
        /// </summary>
        ///
        /// <param name="fileName">The path to the INFO file.</param>
        /// <returns>The new root BoostInfoTree.</returns>
        public BoostInfoTree read(String fileName)
        {
            TextReader stream = new FileReader(fileName);
            // Use "try/finally instead of "try-with-resources" or "using"
            // which are not supported before Java 7.
            try {
                read(stream, root_);
            } finally {
                stream.close();
            }

            return root_;
        }
示例#18
0
        public TRK(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            string DataStr = "";
            string[] Elements;

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase) && !MagicNumber.Equals("TKDT", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TrackData header - TRK.cs");

            if (MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase))
            {
                DataStr = Enc.GetString(m_Reader.ReadBytes((int)m_Reader.ReadUInt32()));
                Elements = DataStr.Split(',');
            }
            else
                Elements = Enc.GetString(m_Reader.ReadToEnd()).Split(',');

            m_Version = int.Parse(Elements[1], NumberStyles.Integer);
            TrackName = Elements[2];

            if (!Elements[3].Equals("", StringComparison.InvariantCultureIgnoreCase))
                SoundID = uint.Parse(Elements[3].Replace("0x", ""), NumberStyles.HexNumber);
            else
                SoundID = 0;

            if (Elements[5].Equals("\r\n", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (!Elements[5].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Argument = (HITTrackArguments)Enum.Parse(typeof(HITTrackArguments), Elements[5]);

            if (!Elements[7].Equals("", StringComparison.InvariantCultureIgnoreCase))
                ControlGroup = (HITControlGroup)Enum.Parse(typeof(HITControlGroup), Elements[7]);

            if (!Elements[(m_Version != 2) ? 11 : 12].Equals("", StringComparison.InvariantCultureIgnoreCase))
                DuckingPriority = int.Parse(Elements[(m_Version != 2) ? 11 : 12], NumberStyles.Integer);

            if (!Elements[(m_Version != 2) ? 12 : 13].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Looped = (int.Parse(Elements[(m_Version != 2) ? 12 : 13], NumberStyles.Integer) != 0) ? true : false;

            if (!Elements[(m_Version != 2) ? 13 : 14].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Volume = int.Parse(Elements[(m_Version != 2) ? 13 : 14], NumberStyles.Integer);

            m_Reader.Close();
        }
示例#19
0
        public Mesh(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            BoneCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BoneCount; i++)
                Bones.Add(m_Reader.ReadPascalString());

            FaceCount = m_Reader.ReadUInt32();

            for (int i = 0; i < FaceCount; i++)
                Faces.Add(new Vector3(m_Reader.ReadUInt32(), m_Reader.ReadUInt32(), m_Reader.ReadUInt32()));

            BindingCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BindingCount; i++)
                BoneBindings.Add(new BoneBinding(m_Reader));

            RealVertexCount = m_Reader.ReadUInt32();
            List<Vector2> TexVertices = new List<Vector2>();

            for (int i = 0; i < RealVertexCount; i++)
                TexVertices.Add(new Vector2(m_Reader.ReadFloat(), m_Reader.ReadFloat()));

            BlendVertexCount = m_Reader.ReadUInt32();

            for (int i = 0; i < BlendVertexCount; i++)
                BlendVertexProps.Add(new BlendVertexProperty(m_Reader));

            TotalVertexCount = m_Reader.ReadUInt32();
            TransformedVertices = new VertexPositionNormalTexture[TotalVertexCount];

            for (int i = 0; i < RealVertexCount; i++)
            {
                RealVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            for(int i = 0; i < BlendVertexCount; i++)
            {
                BlendedVertices.Add(new VertexPositionNormalTexture(new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()),
                    new Vector3(m_Reader.ReadFloat(), m_Reader.ReadFloat(), m_Reader.ReadFloat()), TexVertices[i]));
            }

            m_Reader.Close();
        }
示例#20
0
        public PALT(IFFChunk BaseChunk)
            : base(BaseChunk)
        {
            FileReader Reader = new FileReader(new MemoryStream(m_Data), false);

            Reader.ReadUInt32(); //Version

            m_Colors = new Color[Reader.ReadUInt32()];
            Reader.ReadBytes(8); //Reserved

            for (int i = 0; i < m_Colors.Length; i++)
                m_Colors[i] = new Color(new Vector3(Reader.ReadByte(), Reader.ReadByte(), Reader.ReadByte()));

            Reader.Close();
            m_Data = null;
        }
示例#21
0
        public Thumbnail(byte[] thumbnail,ThumbnailType type)
        {
            thumbType = type;
            Stream stream = new MemoryStream(thumbnail);
            FileReader reader = new FileReader(stream);
            reader.ReadBytes(4);//skip Tag 'THUM'

            width = (int)(reader.ReadUInt32());
            height = (int)(reader.ReadUInt32());

            byte[] readBytes = reader.ReadBytes(thumbnail.Length-12);
            pngBytes = new byte[readBytes.Length];
            readBytes.CopyTo(pngBytes, 0);

            stream.Close();
            reader.Close();
        }
示例#22
0
        public Collection(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            uint Count = m_Reader.ReadUInt32();
            uint FileID = 0, TypeID = 0;

            for(int i = 0; i < Count; i++)
            {
                m_Reader.ReadUInt32(); //Index

                FileID = m_Reader.ReadUInt32();
                TypeID = m_Reader.ReadUInt32();

                PurchasableOutfitIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
示例#23
0
        public Appearance(Stream Data)
        {
            FileReader Reader = new FileReader(Data, true);

            Reader.ReadUInt32(); //Version

            uint FileID = Reader.ReadUInt32(), TypeID = Reader.ReadUInt32();

            ThumbnailID = new UniqueFileID(TypeID, FileID);

            uint BindingCount = Reader.ReadUInt32();
            for (uint i = 0; i < BindingCount; i++)
            {
                FileID = Reader.ReadUInt32();
                TypeID = Reader.ReadUInt32();
                BindingIDs.Add(new UniqueFileID(TypeID, FileID));
            }
        }
示例#24
0
        private static void LoadDefault()
        {
            Parse(Environment.CurrentDirectory, "*.lang", SearchOption.AllDirectories);
            using (var fileReader = new FileReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Shared.Embed.Default.lang")))
            {
                _storage["DEFAULT"] = new Dictionary<string, string>();
                foreach (var eachLine in fileReader)
                {
                    var pos = eachLine.Value.IndexOf('\t');
                    if (pos < 0) continue;

                    var key = eachLine.Value.Substring(0, pos).Trim().ToUpperInvariant();
                    var val = eachLine.Value.Substring(pos + 1);
                    _storage["DEFAULT"][key] = val.Replace("\\t", "\t").Replace("\\r\\n", "\n").Replace("\\n", "\n");
                }
            }
            isLoadDefault = true;
        }
示例#25
0
        private static void LoadFile(string path)
        {
            using (var fileReader = new FileReader(path))
            {
                var lang = Path.GetFileNameWithoutExtension(path).ToUpperInvariant();
                _storage[lang] = new Dictionary<string, string>();
                foreach (var eachLine in fileReader)
                {
                    var pos = eachLine.Value.IndexOf('\t');
                    if (pos < 0) continue;

                    var key = eachLine.Value.Substring(0, pos).Trim().ToUpperInvariant();
                    var val = eachLine.Value.Substring(pos + 1);

                    _storage[lang][key] = val.Replace("\\t", "\t").Replace("\\r\\n", "\n").Replace("\\n", "\n");
                }
            }
        }
示例#26
0
        public EVT(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            ASCIIEncoding Enc = new ASCIIEncoding();

            string[] TrackEvents = Enc.GetString(m_Reader.ReadToEnd()).Split("\r\n".ToCharArray(),
                StringSplitOptions.RemoveEmptyEntries);

            foreach(string TrckEvent in TrackEvents)
            {
                string[] Elements = TrckEvent.Split(',');
                TrackEvent Event = new TrackEvent();
                Event.Name = Elements[0];
                Event.Event = Elements[1];
                Event.TrackID = (Elements[2].Equals("", StringComparison.InvariantCultureIgnoreCase)) ? 0 : uint.Parse(Elements[2].Replace("0x", ""), NumberStyles.HexNumber);
                Events.Add(Event);
            }

            m_Reader.Close();
        }
示例#27
0
        public Anim(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version

            ASCIIEncoding Enc = new ASCIIEncoding();
            Name = Enc.GetString(m_Reader.ReadBytes(m_Reader.ReadUShort()));
            Duration = m_Reader.ReadFloat();
            Distance = m_Reader.ReadFloat();
            IsMoving = (m_Reader.ReadByte() != 0) ? true : false;
            TranslationsCount = m_Reader.ReadUInt32();

            Translations = new float[TranslationsCount, 3];

            for(int i = 0; i < TranslationsCount; i++)
            {
                Translations[i, 0] = m_Reader.ReadFloat();
                Translations[i, 1] = m_Reader.ReadFloat();
                Translations[i, 2] = m_Reader.ReadFloat();
            }

            RotationsCount = m_Reader.ReadUInt32();

            Rotations = new float[RotationsCount, 4];

            for (int i = 0; i < RotationsCount; i++)
            {
                Rotations[i, 0] = m_Reader.ReadFloat();
                Rotations[i, 1] = m_Reader.ReadFloat();
                Rotations[i, 2] = m_Reader.ReadFloat();
                Rotations[i, 3] = m_Reader.ReadFloat();
            }

            MotionCount = m_Reader.ReadUInt32();

            for(int i = 0; i < MotionCount; i++)
                Motions.Add(new Motion(m_Reader));

            m_Reader.Close();
        }
        /// <summary>
        /// Constructs a new instance of the PurchasableOutfit class.
        /// </summary>
        /// <param name="Data">A Stream of data retrieved from a FAR3 archive.</param>
        public PurchasableOutfit(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            m_Reader.ReadUInt32(); //Unknown
            OutfitType = m_Reader.ReadUInt32();

            if(OutfitType != 0)
            {
                //A 4-byte unsigned integer specifying the type of data that follows; should be 0xA96F6D42 for cAssetKey
                m_Reader.ReadUInt32();
                uint FileID = m_Reader.ReadUInt32();
                uint TypeID = m_Reader.ReadUInt32();
                OutfitID = new UniqueFileID(TypeID, FileID);
            }

            m_Reader.ReadUInt32(); //Unknown.

            m_Reader.Close();
        }
示例#29
0
        public Skeleton(Stream Data)
        {
            m_Reader = new FileReader(Data, true);

            m_Reader.ReadUInt32(); //Version
            Name = m_Reader.ReadPascalString();
            BoneCount = m_Reader.ReadUShort();

            for(int i = 0; i < BoneCount; i++)
            {
                Bones.Add(new Bone(m_Reader, i));
            }

            /** Construct tree **/
            foreach (Bone bone in Bones)
                bone.Children = Bones.Where(x => x.ParentName == bone.Name).ToArray();

            RootBone = Bones.FirstOrDefault(x => x.ParentName == "NULL");

            m_Reader.Close();
        }
        public void FileReader_ReadFile_Enumerates_Each_Line()
        {
            var schema = new DelimitedSchema<Person>();
            schema.AddMapping(s => s.FirstName, 1);
            schema.AddMapping(s => s.LastName, 2);
            schema.AddMapping(s => s.Gender, 3);
            schema.AddMapping(s => s.DateOfBirth, 4);

            var mapper = new DelimitedSchemaObjectMapper<Person>(schema, "|");
            var persons = new List<Person>();

            var fr = new FileReader();
            fr.ReadFile("text.txt", line =>
            {
                if (line.StartsWith("P"))
                {
                    persons.Add(mapper.MapLine(line));
                }
            });

            Assert.AreEqual(3, persons.Count);
        }