ReadString() public method

public ReadString ( ) : string
return string
        void LoadV1(BinaryReader binread)
        {
            var strread = new StringReader(binread.ReadString());
            var xmlread = XmlReader.Create(strread);
            var xmlserializer = new XmlSerializer(engineStartParams.type);
            engineStartParams.Load(xmlserializer.Deserialize(xmlread));
            strread.Close ();
            xmlread.Close ();

            int count = binread.ReadInt32();
            for(int i=0;i<count;i++)
            {
                var enabled = binread.ReadBoolean();
                var typestr = binread.ReadString();
                var type = Type.GetType (typestr);
                if(type == null)
                {
                    binread.ReadString(); // can't find type, so just read and throw away
                    continue;
                }
                var xmlserializer2 = new XmlSerializer(type);
                strread = new StringReader(binread.ReadString());
                xmlread = XmlReader.Create(strread);
                customGameStartParams[type].Load(xmlserializer2.Deserialize(xmlread));
                strread.Close ();
                xmlread.Close ();
                customGameStartParams[type].enabled = enabled;
            }
            binread.Close();
            xmlread.Close();
        }
 /*
 Achtung! Hier fehlt noch jegliches Error-Handling
 Es wird nicht einmal geprüft ob die Datei mit VADB anfängt!
 */
 public VDB_Table[] ImportTables(string filename)
 {
     BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));
     string formatID = reader.ReadString();
     int formatVersion = reader.ReadInt32();
     int tableCount = reader.ReadInt32();
     VDB_Table[] tables = new VDB_Table[tableCount];
     for (int i = 0; i < tableCount; i++) {
         string tableName = reader.ReadString();
         int columnCount = reader.ReadInt32();
         string[] columns = new string[columnCount];
         for (int j = 0; j < columnCount; j++) {
             columns[j] = reader.ReadString();
         }
         int rowCount = reader.ReadInt32();
         tables[i] = new VDB_Table(tableName, rowCount, columns);
     }
     string valueArea = reader.ReadString();
     string[] values = valueArea.Split(VDB_DatabaseExporter.valuesSeperator);
     for (int i = 0; i < values.Length - 1; i++) {
         string[] posval = values[i].Split(VDB_DatabaseExporter.positionValueSeperator);
         string[] pos = posval[0].Split(VDB_DatabaseExporter.positionSeperator);
         int table = Int32.Parse(pos[0]);
         int row = Int32.Parse(pos[1]);
         int column = Int32.Parse(pos[2]);
         tables[table].GetRowAt(row).values[column] = VDB_Value.FromBase64(posval[1]);
     }
     reader.Close();
     return tables;
 }
        public void SetDataFrom(BinaryReader reader)
        {
            var tests = new List<LiveTestStatus>();
            CurrentAssembly = reader.ReadString();
            CurrentTest = reader.ReadString();
            TotalNumberOfTests = reader.ReadInt32();
            TestsCompleted = reader.ReadInt32();
            var count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var test = new LiveTestStatus("", null);
                test.SetDataFrom(reader);
                tests.Add(test);
            }
            _failedTest = tests.ToArray();

            tests = new List<LiveTestStatus>();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var test = new LiveTestStatus("", null);
                test.SetDataFrom(reader);
                tests.Add(test);
            }
            _failedButNowPassing = tests.ToArray();
        }
Example #4
0
 public void readDataFrom(BinaryReader r)
 {
     this.Manufacturer = r.ReadString();
     this.Model = r.ReadString();
     this.PhoneNumber = r.ReadString();
     this.HasCord = r.ReadBoolean();
 }
Example #5
0
            public static void Load()
            {
                var local = GetData("UFSJ.S.uscx");
                try
                {
                    using (var i = new BinaryReader(File.OpenRead(local)))
                    {
                        if (i.ReadChar() == 'U')
                        {
                            OnTopMost = i.ReadBoolean(); //OnTopMost
                            SilentProgress = i.ReadBoolean(); //SilentProgress
                            ShowSummary = i.ReadBoolean(); //ShowSummary
                            AssociateExt = i.ReadBoolean(); //AssociateExt
                            StartHide = i.ReadBoolean(); //StartHide
                            ShellMenus = i.ReadBoolean(); //ShellMenus
                            SettingMode = i.ReadInt16(); //SettingMode
                            Theme = i.ReadString(); //ColorScheme
                            Language = i.ReadString(); //Language
                            Formats = i.ReadString(); //Formats
                            Position = new Point(i.ReadInt32(), i.ReadInt32());
                        }
                    }
                }
                catch (Exception)
                {
                    SaveDefault();
                    Load();
                }

            }
Example #6
0
 public static void ReadFromFile(IndexUnit indexPage, BinaryReader reader)
 {
     long initPos = reader.Seek(100L + (indexPage.UnitID * 0x1000L));
     if (reader.ReadByte() != 2)
     {
         throw new FileDBException("PageID {0} is not a Index Page", new object[] { indexPage.UnitID });
     }
     indexPage.NextUnitID = reader.ReadUInt32();
     indexPage.NodeIndex = reader.ReadByte();
     reader.Seek(initPos + 0x2eL);
     for (int i = 0; i <= indexPage.NodeIndex; i++)
     {
         IndexNode node = indexPage.Nodes[i];
         node.ID = reader.ReadGuid();
         node.IsDeleted = reader.ReadBoolean();
         node.Right.Index = reader.ReadByte();
         node.Right.PageID = reader.ReadUInt32();
         node.Left.Index = reader.ReadByte();
         node.Left.PageID = reader.ReadUInt32();
         node.DataPageID = reader.ReadUInt32();
         node.FileName = reader.ReadString(0x29);
         node.FileExtension = reader.ReadString(5);
         node.FileLength = reader.ReadUInt32();
     }
 }
        public virtual AntiForgeryData Deserialize(string serializedToken)
        {
            if (String.IsNullOrEmpty(serializedToken))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "serializedToken");
            }

            try
            {
                using (MemoryStream stream = new MemoryStream(Decoder(serializedToken)))
                {
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        return new AntiForgeryData
                        {
                            Salt = reader.ReadString(),
                            Value = reader.ReadString(),
                            CreationDate = new DateTime(reader.ReadInt64()),
                            Username = reader.ReadString()
                        };
                    }
                }
            }
            catch
            {
                throw new HttpAntiForgeryException(WebPageResources.AntiForgeryToken_ValidationFailed);
            }
        }
 public static TestResultData ReadFrom(BinaryReader reader)
 {
     var displayName = reader.ReadString();
     var state = (TestState)reader.ReadInt32();
     var output = reader.ReadString();
     return new TestResultData(displayName, state, output);
 }
Example #9
0
 internal Shader(GraphicsDevice device, BinaryReader reader)
 {
   this.GraphicsDevice = device;
   this.Stage = reader.ReadBoolean() ? ShaderStage.Vertex : ShaderStage.Pixel;
   int count = (int) reader.ReadUInt16();
   byte[] bytes = reader.ReadBytes(count);
   int length1 = (int) reader.ReadByte();
   this.Samplers = new SamplerInfo[length1];
   for (int index = 0; index < length1; ++index)
   {
     this.Samplers[index].type = (SamplerType) reader.ReadByte();
     this.Samplers[index].index = (int) reader.ReadByte();
     this.Samplers[index].name = reader.ReadString();
     this.Samplers[index].parameter = (int) reader.ReadByte();
   }
   int length2 = (int) reader.ReadByte();
   this.CBuffers = new int[length2];
   for (int index = 0; index < length2; ++index)
     this.CBuffers[index] = (int) reader.ReadByte();
   this._glslCode = Encoding.ASCII.GetString(bytes);
   this.HashKey = Hash.ComputeHash(bytes);
   int length3 = (int) reader.ReadByte();
   this._attributes = new Shader.Attribute[length3];
   for (int index = 0; index < length3; ++index)
   {
     this._attributes[index].name = reader.ReadString();
     this._attributes[index].usage = (VertexElementUsage) reader.ReadByte();
     this._attributes[index].index = (int) reader.ReadByte();
     this._attributes[index].format = reader.ReadInt16();
   }
 }
Example #10
0
        public static Auction Deserialize(Stream dataStream)
        {
            var reader = new BinaryReader(dataStream);
            var auction = new Auction();
            auction.Id = reader.ReadInt64();
            auction.ItemId = reader.ReadInt64();
            auction.PlacedBy = reader.ReadString();
            auction.Realm = reader.ReadString();
            auction.CurrentBid = reader.ReadInt64();
            auction.Buyout = reader.ReadInt64();
            auction.Quantity = reader.ReadInt32();
            auction.Random = reader.ReadInt64();
            auction.Seed = reader.ReadInt64();
            auction.GenerationContext = reader.ReadInt32();
            auction.PetSpeciesId = reader.ReadInt32();
            auction.PetBreedId = reader.ReadInt32();
            auction.PetLevel = reader.ReadInt32();
            auction.PetQualityId = reader.ReadInt32();

            if (auction.PetSpeciesId == -1) auction.PetSpeciesId = null;
            if (auction.PetBreedId == -1) auction.PetBreedId = null;
            if (auction.PetLevel == -1) auction.PetLevel = null;
            if (auction.PetQualityId == -1) auction.PetQualityId = null;

            return auction;
        }
        public IEnumerable<Book> LoadBooks()
        {
            List<Book> books = new List<Book>();
            try
            {
                using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read))
                {
                    using (BinaryReader bw = new BinaryReader(fs))
                    {
                        long position = bw.BaseStream.Position;
                        while (position < bw.BaseStream.Length)
                        {
                            Book book = new Book(bw.ReadString(), bw.ReadString(), bw.ReadString(), bw.ReadInt32(), bw.ReadInt32(), bw.ReadInt32());
                            books.Add(book);
                            position = bw.BaseStream.Position;
                        }
                    }
                }
            }
            catch (Exception e)
            {                
                books.Clear();
                books.TrimExcess();
                throw new IOException("Error while loading books from file.", e);                
            }

            return books;
        }
Example #12
0
        static void Main(string[] args)
        {
            int serverPort = 7000;
            IPAddress serverIPAddress = IPAddress.Loopback;  // il localhost

            var tcpClient = new TcpClient();
            // la connessione UDP va definita usando esplicitamente la classe socket

            tcpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), serverPort));
            using (Stream stream = tcpClient.GetStream())
            using (BinaryReader reader = new BinaryReader(stream))
            using (BinaryWriter writer = new BinaryWriter(stream)) {
                string domanda = reader.ReadString();
                Console.WriteLine(domanda);

                string risposta = Console.ReadLine();
                int rispostaInt;

                if (Int32.TryParse(risposta, out rispostaInt)){
                  writer.Write(rispostaInt);
                }
                string risultato = reader.ReadString();

                Console.WriteLine("La tua risposta e' {0}", risultato);
            }
        }
		private AuthenticationCookie(byte[] data)
		{
			using (var memoryStream = new MemoryStream(data))
			{
				using (var binaryReader = new BinaryReader(memoryStream))
				{
					_cookieType = binaryReader.ReadInt16();
					_id = new Guid(binaryReader.ReadBytes(16));
					_persistent = binaryReader.ReadBoolean();
					_issueDate = DateTime.FromBinary(binaryReader.ReadInt64());
					_name = binaryReader.ReadString();
					var rolesLength = binaryReader.ReadInt16();
					_roles = new string[rolesLength];
					for (int i = 0; i < _roles.Length; i++)
					{
						_roles[i] = binaryReader.ReadString();
					}
					var tagLength = binaryReader.ReadInt16();
					if (tagLength == 0)
					{
						_tag = null;
					}
					else
					{
						_tag = binaryReader.ReadBytes(tagLength);
					}
				}
			}
		}
 public void TestWrite()
 {
     PostingListEncoder decoder = new PostingListEncoder();
     SpimiBlockWriter writer = new SpimiBlockWriter();
     writer.AddPosting("bTerm", DocA);
     writer.AddPosting("aTerm", DocA);
     writer.AddPosting("aTerm", DocB);
     string filePath = writer.FlushToFile();
     using (FileStream file = File.Open(filePath, FileMode.Open))
     {
         BinaryReader reader = new BinaryReader(file);
         Assert.AreEqual(2, reader.ReadInt32());
         Assert.AreEqual("aTerm", reader.ReadString());
         IList<Posting> postings = new List<Posting>();
         postings.Add(new Posting(DocA, 1));
         postings.Add(new Posting(DocB, 1));
         IList<Posting> readPostings = decoder.read(reader);
         for (int i = 0; i < postings.Count; i++ )
         {
             readPostings[i].Equals(postings[i]);
         }
         Assert.AreEqual("bTerm", reader.ReadString());
         readPostings = decoder.read(reader);
         Assert.AreEqual(new Posting(DocA, 1), readPostings[0]);
     }
 }
Example #15
0
 internal static void ReadCustomData(Player player, BinaryReader reader)
 {
     int count = reader.ReadUInt16();
     for (int k = 0; k < count; k++)
     {
         string modName = reader.ReadString();
         string name = reader.ReadString();
         byte[] data = reader.ReadBytes(reader.ReadUInt16());
         Mod mod = ModLoader.GetMod(modName);
         ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
         if (modPlayer != null)
         {
             using (MemoryStream stream = new MemoryStream(data))
             {
                 using (BinaryReader customReader = new BinaryReader(stream))
                 {
                     modPlayer.LoadCustomData(customReader);
                 }
             }
             if (modName == "ModLoader" && name == "MysteryPlayer")
             {
                 ((MysteryPlayer)modPlayer).RestoreData(player);
             }
         }
         else
         {
             ModPlayer mystery = player.GetModPlayer(ModLoader.GetMod("ModLoader"), "MysteryPlayer");
             ((MysteryPlayer)mystery).AddData(modName, name, data);
         }
     }
 }
Example #16
0
        public static void ReadFromFile(IndexPage indexPage, BinaryReader reader)
        {
            // Seek the stream to the fist byte on page
            long initPos = reader.Seek(Header.HEADER_SIZE + ((long)indexPage.PageID * BasePage.PAGE_SIZE));

            if (reader.ReadByte() != (byte)PageType.Index)
                throw new FileDBException("PageID {0} is not a Index Page", indexPage.PageID);

            indexPage.NextPageID = reader.ReadUInt32();
            indexPage.NodeIndex = reader.ReadByte();

            // Seek the stream to end of header data page
            reader.Seek(initPos + IndexPage.HEADER_SIZE);

            for (int i = 0; i <= indexPage.NodeIndex; i++)
            {
                var node = indexPage.Nodes[i];

                node.ID = reader.ReadGuid();

                node.IsDeleted = reader.ReadBoolean();

                node.Right.Index = reader.ReadByte();
                node.Right.PageID = reader.ReadUInt32();
                node.Left.Index = reader.ReadByte();
                node.Left.PageID = reader.ReadUInt32();

                node.DataPageID = reader.ReadUInt32();

                node.FileName = reader.ReadString(IndexNode.FILENAME_SIZE);
                node.FileExtension = reader.ReadString(IndexNode.FILE_EXTENSION_SIZE);
                node.FileLength = reader.ReadUInt32();
            }
        }
        /* The serialized format of the anti-XSRF token is as follows:
         * Version: 1 byte integer
         * SecurityToken: 16 byte binary blob
         * IsSessionToken: 1 byte Boolean
         * [if IsSessionToken = true]
         *   +- IsClaimsBased: 1 byte Boolean
         *   |  [if IsClaimsBased = true]
         *   |    `- ClaimUid: 32 byte binary blob
         *   |  [if IsClaimsBased = false]
         *   |    `- Username: UTF-8 string with 7-bit integer length prefix
         *   `- AdditionalData: UTF-8 string with 7-bit integer length prefix
         */
        private static AntiForgeryToken DeserializeImpl(BinaryReader reader)
        {
            // we can only consume tokens of the same serialized version that we generate
            byte embeddedVersion = reader.ReadByte();
            if (embeddedVersion != TokenVersion) {
                return null;
            }

            AntiForgeryToken deserializedToken = new AntiForgeryToken();
            byte[] securityTokenBytes = reader.ReadBytes(AntiForgeryToken.SecurityTokenBitLength / 8);
            deserializedToken.SecurityToken = new BinaryBlob(AntiForgeryToken.SecurityTokenBitLength, securityTokenBytes);
            deserializedToken.IsSessionToken = reader.ReadBoolean();

            if (!deserializedToken.IsSessionToken) {
                bool isClaimsBased = reader.ReadBoolean();
                if (isClaimsBased) {
                    byte[] claimUidBytes = reader.ReadBytes(AntiForgeryToken.ClaimUidBitLength / 8);
                    deserializedToken.ClaimUid = new BinaryBlob(AntiForgeryToken.ClaimUidBitLength, claimUidBytes);
                } else {
                    deserializedToken.Username = reader.ReadString();
                }

                deserializedToken.AdditionalData = reader.ReadString();
            }

            // if there's still unconsumed data in the stream, fail
            if (reader.BaseStream.ReadByte() != -1) {
                return null;
            }

            // success
            return deserializedToken;
        }
Example #18
0
        public static List<Customer> GetCustomers()
        {
            // if the directory doesn't exist, create it
            if (!Directory.Exists(dir))
                Directory.CreateDirectory(dir);

            // create the array list for customers
            List<Customer> customers = new List<Customer>();

            // create the object for the input stream for a binary file
            BinaryReader binaryIn =
                new BinaryReader(
                new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read));

            // read the data from the file and store it in the List<>
            while (binaryIn.PeekChar() != -1)
            {
                Customer c = new Customer();
                c.FirstName = binaryIn.ReadString();
                c.LastName = binaryIn.ReadString();
                c.Email = binaryIn.ReadString();
                customers.Add(c);
            }

            binaryIn.Close();

            return customers;
        }
Example #19
0
        public MapInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();
            FileName = reader.ReadString();
            Title = reader.ReadString();
            MiniMap = reader.ReadUInt16();
            Light = (LightSetting) reader.ReadByte();
            if (Envir.LoadVersion >= 3) BigMap = reader.ReadUInt16();
            if (Envir.LoadVersion >= 10) reader.ReadByte();

            int count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                SafeZones.Add(new SafeZoneInfo(reader) { Info = this });

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Respawns.Add(new RespawnInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                NPCs.Add(new NPCInfo(reader));

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
                Movements.Add(new MovementInfo(reader));
        }
Example #20
0
		public override object Read(BinaryReader reader)
		{
			reader.ReadByte();
			int id = reader.ReadInt32();
			InstrumentType type = (InstrumentType)reader.ReadByte();
			string symbol = reader.ReadString();
			string description = reader.ReadString();
			byte currencyId = reader.ReadByte();
			string exchange = reader.ReadString();
			Instrument instrument = new Instrument(id, type, symbol, description, currencyId, exchange);
			instrument.tickSize = reader.ReadDouble();
			instrument.maturity = new DateTime(reader.ReadInt64());
			instrument.factor = reader.ReadDouble();
			instrument.strike = reader.ReadDouble();
			instrument.putcall = (PutCall)reader.ReadByte();
			instrument.margin = reader.ReadDouble();
			int num = reader.ReadInt32();
			for (int i = 0; i < num; i++)
			{
				AltId altId = new AltId();
				altId.providerId = reader.ReadByte();
				altId.symbol = reader.ReadString();
				altId.exchange = reader.ReadString();
				instrument.altId.Add(altId);
			}
			return instrument;
		}
Example #21
0
 internal override bool Auth(NetworkStream stream)
 {
     var reader = new BinaryReader(stream);
     var writer = new BinaryWriter(stream);
     try
     {
         int ver = reader.ReadByte();
         if(ver != 0x05)
         {
             throw new Exception();
         }
         string login = reader.ReadString();
         string password = reader.ReadString();
         bool result = _callback(login, password);
         if(result)
         {
             writer.Write(new byte[] { 0x05, 0x00 });
             return true;
         }
         writer.Write(new byte[] { 0x05, 0xFF });
     }
     catch(IOException)
     {}
     catch
     {
         writer.Write(new byte[] { 0x05, 0xFF });
     }
     return false;
 }
 public void SetDataFrom(BinaryReader reader)
 {
     CorrelationId = new Guid(reader.ReadString());
     Item = reader.ReadString();
     Test = new Chain();
     Test.ReadDataFrom(reader);
 }
		private static AntiForgeryToken DeserializeImpl(BinaryReader reader)
		{
			byte b = reader.ReadByte();
			if (b != 1)
			{
				return null;
			}
			AntiForgeryToken antiForgeryToken = new AntiForgeryToken();
			byte[] data = reader.ReadBytes(16);
			antiForgeryToken.SecurityToken = new BinaryBlob(128, data);
			antiForgeryToken.IsSessionToken = reader.ReadBoolean();
			if (!antiForgeryToken.IsSessionToken)
			{
				bool flag = reader.ReadBoolean();
				if (flag)
				{
					byte[] data2 = reader.ReadBytes(32);
					antiForgeryToken.ClaimUid = new BinaryBlob(256, data2);
				}
				else
				{
					antiForgeryToken.Username = reader.ReadString();
				}
				antiForgeryToken.AdditionalData = reader.ReadString();
			}
			if (reader.BaseStream.ReadByte() != -1)
			{
				return null;
			}
			return antiForgeryToken;
		}
Example #24
0
		public static List<Product> GetProducts()
		{
			// if the directory doesn't exist, create it
			if (!Directory.Exists(dir))
				Directory.CreateDirectory(dir);

			// create the object for the input stream for a binary file
			BinaryReader binaryIn = 
				new BinaryReader(
				new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read));

			// create the array list
			List<Product> products = new List<Product>();

			// read the data from the file and store it in the List<Product>
			while (binaryIn.PeekChar() != -1)
			{
				Product product = new Product();
				product.Code = binaryIn.ReadString();
				product.Description = binaryIn.ReadString();
				product.Price = binaryIn.ReadDecimal();
				products.Add(product);
			}

			// close the input stream for the binary file
			binaryIn.Close();

			return products;
		}
Example #25
0
		public void SetDataFrom (BinaryReader reader)
		{
			File = reader.ReadString();
			LineNumber = reader.ReadInt32();
			LinePosition = reader.ReadInt32();
			ErrorMessage = reader.ReadString();
		}
Example #26
0
		public static void Register()
		{
			using (var manifestResourceStream = typeof(SettingsRegister).Assembly.GetManifestResourceStream("Raven.Studio.Settings.dat"))
			{
				if (manifestResourceStream == null || manifestResourceStream.Length == 0)
				{
					return;
				}

				using (var reader = new BinaryReader(manifestResourceStream))
				using (var aes = new AesManaged())
				{
					aes.Key = reader.ReadBytes(32);
					aes.IV = reader.ReadBytes(16);

					using (var cryptoStream = new CryptoStream(manifestResourceStream, aes.CreateDecryptor(), CryptoStreamMode.Read))
					using (var cryptoReader = new BinaryReader(cryptoStream))
					{
						var licensee = cryptoReader.ReadString();
						var licenseKey = cryptoReader.ReadString();
						ActiproSoftware.Products.ActiproLicenseManager.RegisterLicense(licensee, licenseKey);
					}
				}
			}
		} 
Example #27
0
 //true = all files are ok, no need to update
 public static bool Vertify()
 {
     try
     {
         using (var reader = new BinaryReader(new FileStream(Globals.IndexFile, FileMode.Open, FileAccess.Read)))
         {
             reader.ReadString(); //GTA2.NET
             var fileVersion = new Version(reader.ReadString());
             var localVersion = new Version(IndexFileVersion);
             if (fileVersion < localVersion)
                 return false;
             var localVersionAttributes = NamedVersionAttribute.GetTypesWithVersionAttribute(Assembly.GetExecutingAssembly());
             var fileVersionAttributes = new Dictionary<string, Version>();
             var count = reader.ReadInt32();
             for (var i = 0; i < count; i++)
             {
                 fileVersionAttributes.Add(reader.ReadString(), new Version(reader.ReadString()));
             }
             foreach (var localVersionAttribute in localVersionAttributes)
             {
                 Version version;
                 if (!fileVersionAttributes.TryGetValue(localVersionAttribute.Key, out version))
                     return false;
                 if (version < localVersionAttribute.Value)
                     return false;
             }
         }
         return true;
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e.Message);
         return false;
     }
 }
		public void SetDataFrom(BinaryReader reader)
		{
			Type = (InformationType) reader.ReadInt32();
			Project = reader.ReadString();
			Assembly = reader.ReadString();
			Runner = System.Type.GetType(reader.ReadString());
		}
Example #29
0
        public IndexedFS(Filesystem msys)
        {
            _msys = msys;
            if (!msys.EnumFiles().GetEnumerator().MoveNext())
            {
            //Create index
                msys.AllocSpace(0,512);
                Stream mstream = new ObservableStream(0, msys);
                BinaryWriter mwriter = new BinaryWriter(mstream);

                mwriter.Write(filemappings.Count);
                cval++;
            }
            ObservableStream fstr = new ObservableStream(0, msys);
            BinaryReader mreader = new BinaryReader(fstr);
            int count = mreader.ReadInt32();

            for (int i = 0; i < count; i++)
            {

                if (mreader.ReadBoolean())
                {
                    filemappings.Add(mreader.ReadString(), mreader.ReadInt64());
                }
                else
                {
                    dirmappings.Add(mreader.ReadString(), mreader.ReadInt64());

                }

                cval++;
            }
        }
        public void Read(BinaryReader reader)
        {
            TestName = reader.ReadString();
            CurrentVersion = reader.ReadString();
            Frame = reader.ReadString();

            // Read image header
            var width = reader.ReadInt32();
            var height = reader.ReadInt32();
            var format = (PixelFormat)reader.ReadInt32();
            var textureSize = reader.ReadInt32();

            // Read image data
            var imageData = new byte[textureSize];
            using (var lz4Stream = new LZ4Stream(reader.BaseStream, CompressionMode.Decompress, false, textureSize))
            {
                if (lz4Stream.Read(imageData, 0, textureSize) != textureSize)
                    throw new EndOfStreamException("Unexpected end of stream");
            }

            var pinnedImageData = GCHandle.Alloc(imageData, GCHandleType.Pinned);
            var description = new ImageDescription
            {
                Dimension = TextureDimension.Texture2D,
                Width = width,
                Height = height,
                ArraySize = 1,
                Depth = 1,
                Format = format,
                MipLevels = 1,
            };

            Image = Image.New(description, pinnedImageData.AddrOfPinnedObject(), 0, pinnedImageData, false);
        }