ReadString() public method

public ReadString ( ) : string
return string
Esempio n. 1
0
 public void readDataFrom(BinaryReader r)
 {
     this.Manufacturer = r.ReadString();
     this.Model = r.ReadString();
     this.PhoneNumber = r.ReadString();
     this.HasCord = r.ReadBoolean();
 }
Esempio n. 2
0
        public void Load(System.IO.BinaryReader reader)
        {
            version = reader.ReadByte();
            if (version > VERSION)
            {
                throw new CacheException("Unknown CacheItem Version.", null, version);
            }

            name             = reader.ReadString();
            type             = reader.ReadString();
            pfd              = new Packages.PackedFileDescriptor();
            pfd.Type         = reader.ReadUInt32();
            pfd.Group        = reader.ReadUInt32();
            pfd.LongInstance = reader.ReadUInt64();
            influence        = reader.ReadInt32();
            score            = reader.ReadInt32();
            guid             = reader.ReadUInt32();
            folder           = reader.ReadString();


            int size = reader.ReadInt32();

            if (size == 0)
            {
                thumb = null;
            }
            else
            {
                byte[]       data = reader.ReadBytes(size);
                MemoryStream ms   = new MemoryStream(data);

                thumb = Image.FromStream(ms);
            }
        }
Esempio n. 3
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();
                }

            }
		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;
		}
Esempio n. 5
0
		public void SetDataFrom (BinaryReader reader)
		{
			File = reader.ReadString();
			LineNumber = reader.ReadInt32();
			LinePosition = reader.ReadInt32();
			ErrorMessage = reader.ReadString();
		}
Esempio n. 6
0
        //読み込み
        public virtual void OnRead(System.IO.BinaryReader reader)
        {
            //バージョンチェック
            int version = reader.ReadInt32();

            if (version == Version)
            {
                List <string> nameList = new List <string>();
                int           count    = reader.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    string key    = reader.ReadString();
                    byte[] buffer = reader.ReadBytes(reader.ReadInt32());
                    nameList.Add(key);
                    BinaryUtil.BinaryRead(buffer, FindWindow(key).ReadPageData);
                }
                string currentWindowName = reader.ReadString();

                ChangeActiveWindows(nameList);
                ChangeCurrentWindow(currentWindowName);
            }
            else
            {
                Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version));
            }
        }
Esempio n. 7
0
 public void Load(string fileName)
 {
     using (var reader = new System.IO.BinaryReader(
                new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read)))
     {
         int fileCount = reader.ReadInt32();
         for (int fileIndex = 0; fileIndex < fileCount; fileIndex++)
         {
             var dataFile = new MyResourceDataFile();
             dataFile.FileName = reader.ReadString();
             dataFile.Name     = reader.ReadString();
             var bsLength = reader.ReadInt32();
             if (bsLength > 0)
             {
                 dataFile.Datas = reader.ReadBytes(bsLength);
             }
             var itemCount = reader.ReadInt32();
             for (int iCount = 0; iCount < itemCount; iCount++)
             {
                 var newItem = new MyResourceDataFile.MyResourceDataItem();
                 newItem.Name       = reader.ReadString();
                 newItem.StartIndex = reader.ReadInt32();
                 newItem.BsLength   = reader.ReadInt32();
                 newItem.Key        = reader.ReadInt32();
                 newItem.IsBmp      = reader.ReadBoolean();
                 dataFile.Items.Add(newItem);
             }
             this.Add(dataFile);
         }
     }
 }
 /*
 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();
        }
Esempio n. 10
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;
     }
 }
Esempio n. 11
0
        internal PdfFont(System.IO.BinaryReader reader)
        {
            _fontName           = reader.ReadString();
            _fullName           = reader.ReadString();
            _familyName         = reader.ReadString();
            _weight             = reader.ReadString();
            _isCIDFont          = reader.ReadBoolean();
            _italicAngle        = reader.ReadDouble();
            _isFixedPitch       = reader.ReadBoolean();
            _characterSet       = reader.ReadString();
            _fontBBox           = new AfmRectangle(reader);
            _underlinePosition  = reader.ReadInt16();
            _underlineThickness = reader.ReadInt16();
            _capHeight          = reader.ReadInt16();
            _xheight            = reader.ReadInt16();
            _ascender           = reader.ReadInt16();
            _descender          = reader.ReadInt16();
            _stdHW = reader.ReadInt16();
            _stdVW = reader.ReadInt16();

            _charMetric = new AfmCharMetric[65536];

            UInt16 pos;

            while ((pos = reader.ReadUInt16()) != 0)
            {
                _charMetric[pos] = new AfmCharMetric(reader);
            }
        }
        internal HTTPCacheFileInfo(Uri uri, System.IO.BinaryReader reader, int version)
        {
            this.Uri        = uri;
            this.LastAccess = DateTime.FromBinary(reader.ReadInt64());
            this.BodyLength = reader.ReadInt32();

            switch (version)
            {
            case 2:
                this.MappedNameIDX = reader.ReadUInt64();
                goto case 1;

            case 1:
            {
                this.ETag           = reader.ReadString();
                this.LastModified   = reader.ReadString();
                this.Expires        = DateTime.FromBinary(reader.ReadInt64());
                this.Age            = reader.ReadInt64();
                this.MaxAge         = reader.ReadInt64();
                this.Date           = DateTime.FromBinary(reader.ReadInt64());
                this.MustRevalidate = reader.ReadBoolean();
                this.Received       = DateTime.FromBinary(reader.ReadInt64());
                break;
            }
            }
        }
Esempio n. 13
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++;
            }
        }
Esempio n. 14
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;
 }
        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();
        }
 public void SetDataFrom(BinaryReader reader)
 {
     CorrelationId = new Guid(reader.ReadString());
     Item = reader.ReadString();
     Test = new Chain();
     Test.ReadDataFrom(reader);
 }
Esempio n. 17
0
 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);
 }
Esempio n. 18
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);
         }
     }
 }
		public void SetDataFrom(BinaryReader reader)
		{
			Type = (InformationType) reader.ReadInt32();
			Project = reader.ReadString();
			Assembly = reader.ReadString();
			Runner = System.Type.GetType(reader.ReadString());
		}
Esempio n. 20
0
        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);
        }
        /* 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;
        }
Esempio n. 22
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;
        }
Esempio n. 23
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;
		}
Esempio n. 24
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();
     }
 }
		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 override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
        {
            while (reader.BaseStream.Position < header.DataEndPos)
            {
                var type = (SubRecordType)reader.ReadInt32();
                var size = reader.ReadInt32();

                switch (type)
                {
                case SubRecordType.Id:
                    id = reader.ReadString(size);
                    break;

                case SubRecordType.IntValue:
                    index = reader.ReadInt32();
                    break;

                case SubRecordType.Data:
                    texture = reader.ReadString(size);
                    break;
                }
            }

            records.Add(index, this);
        }
Esempio n. 27
0
 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]);
     }
 }
Esempio n. 28
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));
        }
Esempio n. 29
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;
		}
        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);
            }
        }
Esempio n. 31
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();
   }
 }
Esempio n. 32
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);
            }
        }
Esempio n. 33
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();
            }
        }
Esempio n. 34
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;
        }
Esempio n. 35
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);
					}
				}
			}
		} 
Esempio n. 36
0
        public override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
        {
            while (reader.BaseStream.Position < header.DataEndPos)
            {
                var type = (SubRecordType)reader.ReadInt32();
                var size = reader.ReadInt32();

                switch (type)
                {
                case SubRecordType.Id:
                    name = reader.ReadString(size);
                    break;

                case SubRecordType.Data:
                    calculateFromAllLevelsLessThanPCsLevel = reader.ReadInt32();
                    break;

                case SubRecordType.NextName:
                    chanceNone = reader.ReadByte();
                    break;

                case SubRecordType.Index:
                    index = reader.ReadInt32();
                    break;

                case SubRecordType.CreatureName:
                    creatureNames.Add(reader.ReadString(size));
                    break;

                case SubRecordType.IntValue:
                    pcLevel.Add(reader.ReadInt16());
                    break;
                }
            }
        }
        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;
        }
Esempio n. 38
0
 void IBinarySerialize.Read(System.IO.BinaryReader r)
 {
     _delimiter   = r.ReadString();
     _accumulator = new StringBuilder(r.ReadString());
     if (_accumulator.Length != 0)
     {
         this.IsNull = false;
     }
 }
Esempio n. 39
0
        public UnityEngine.Object DeserializeUnityObject( )
        {
            int inst = reader.ReadInt32();

            if (inst == int.MaxValue)
            {
                return(null);
            }

            string name     = reader.ReadString();
            string typename = reader.ReadString();
            string guid     = reader.ReadString();

            System.Type type = System.Type.GetType(typename);

            if (type == null)
            {
                Debug.LogError("Could not find type '" + typename + "'. Cannot deserialize Unity reference");
                return(null);
            }

            if (!string.IsNullOrEmpty(guid))
            {
                UnityReferenceHelper[] helpers = UnityEngine.Object.FindObjectsOfType(typeof(UnityReferenceHelper)) as UnityReferenceHelper[];

                for (int i = 0; i < helpers.Length; i++)
                {
                    if (helpers[i].GetGUID() == guid)
                    {
                        if (type == typeof(GameObject))
                        {
                            return(helpers[i].gameObject);
                        }
                        else
                        {
                            return(helpers[i].GetComponent(type));
                        }
                    }
                }
            }

            //Try to load from resources
            UnityEngine.Object[] objs = Resources.LoadAll(name, type);

            for (int i = 0; i < objs.Length; i++)
            {
                if (objs[i].name == name || objs.Length == 1)
                {
                    return(objs[i]);
                }
            }

            return(null);
        }
Esempio n. 40
0
        public void Load(System.IO.BinaryReader reader)
        {
            version = reader.ReadByte();
            if (version > VERSION)
            {
                throw new CacheException("Unknown CacheItem Version.", null, version);
            }

            name = reader.ReadString();
            if (version >= 2)
            {
                objdname = reader.ReadString();
            }
            else
            {
                objdname = null;
            }
            if (version >= 3)
            {
                int ct = reader.ReadUInt16();
                valuenames = new string[ct];
                for (int i = 0; i < ct; i++)
                {
                    valuenames[i] = reader.ReadString();
                }
            }
            else
            {
                valuenames = new string[0];
            }

            type             = (SimPe.Data.ObjectTypes)reader.ReadUInt16();
            pfd              = new Packages.PackedFileDescriptor();
            pfd.Type         = reader.ReadUInt32();
            pfd.Group        = reader.ReadUInt32();
            pfd.LongInstance = reader.ReadUInt64();
            guid             = reader.ReadUInt32();


            int size = reader.ReadInt32();

            if (size == 0)
            {
                thumb = null;
            }
            else
            {
                byte[]       data = reader.ReadBytes(size);
                MemoryStream ms   = new MemoryStream(data);

                thumb = Image.FromStream(ms);
            }
        }
Esempio n. 41
0
        public static JSONNode Deserialize(System.IO.BinaryReader aReader)
        {
            JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte();
            switch (type)
            {
                case JSONBinaryTag.Array:
                    {
                        int count = aReader.ReadInt32();
                        JSONArray tmp = new JSONArray();
                        for (int i = 0; i < count; i++)
                            tmp.Add(Deserialize(aReader));
                        return tmp;
                    }
                case JSONBinaryTag.Class:
                    {
                        int count = aReader.ReadInt32();
                        JSONClass tmp = new JSONClass();
                        for (int i = 0; i < count; i++)
                        {
                            string key = aReader.ReadString();
                            var val = Deserialize(aReader);
                            tmp.Add(key, val);
                        }
                        return tmp;
                    }
                case JSONBinaryTag.Value:
                    {
                        return new JSONData(aReader.ReadString());
                    }
                case JSONBinaryTag.IntValue:
                    {
                        return new JSONData(aReader.ReadInt32());
                    }
                case JSONBinaryTag.DoubleValue:
                    {
                        return new JSONData(aReader.ReadDouble());
                    }
                case JSONBinaryTag.BoolValue:
                    {
                        return new JSONData(aReader.ReadBoolean());
                    }
                case JSONBinaryTag.FloatValue:
                    {
                        return new JSONData(aReader.ReadSingle());
                    }

                default:
                    {
                        throw new Exception("Error deserializing JSON. Unknown tag: " + type);
                    }
            }
        }
Esempio n. 42
0
        public override void Load(System.IO.BinaryReader r, uint id)
        {
            base.Load(r, id);

            TemplateName = r.ReadString();
            ANN          = BinarySerializable.GetObject <INeuralNetChromosome>(r);
        }
Esempio n. 43
0
        public void Load(System.IO.BinaryReader reader)
        {
            version = reader.ReadByte();
            if (version > VERSION)
            {
                throw new CacheException("Unknown CacheItem Version.", null, version);
            }

            modelname        = reader.ReadString();
            family           = reader.ReadString();
            def              = reader.ReadBoolean();
            pfd              = new Packages.PackedFileDescriptor();
            pfd.Type         = reader.ReadUInt32();
            pfd.Group        = reader.ReadUInt32();
            pfd.LongInstance = reader.ReadUInt64();
        }
Esempio n. 44
0
 public FollowData(System.IO.BinaryReader reader)
 {
     position = reader.ReadVector3();
     duration = reader.ReadInt16();
     id       = reader.ReadString(32);
     unknown  = reader.ReadInt16();
 }
Esempio n. 45
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public void Unserialize(System.IO.BinaryReader reader)
        {
            unknown1  = (PrimitiveType)reader.ReadUInt32();
            alternate = reader.ReadInt32();
            name      = reader.ReadString();

            ReadBlock(reader, items1);

            if (parent.Version != 0x03)
            {
                opacity = reader.ReadUInt32();
            }
            else
            {
                opacity = 0;
            }

            if (parent.Version != 0x01)
            {
                ReadBlock(reader, items2);
            }
            else
            {
                items2.Clear();
            }
        }
Esempio n. 46
0
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public static System.String readString(System.IO.BinaryReader in_Renamed)
        {
            //UPGRADE_ISSUE: Method 'java.io.DataInputStream.readUTF' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioDataInputStreamreadUTF'"
            System.String s = in_Renamed.ReadString();

            return(s);
        }
Esempio n. 47
0
        public override void Load(System.IO.BinaryReader r, uint id)
        {
            base.Load(r, id);

            TemplateName = r.ReadString();
            Genome       = BinarySerializable.GetObject <Genome>(r);
        }
Esempio n. 48
0
        /// <summary>
        /// 分析网络数据包并进行转换为信息对象
        /// </summary>
        /// <param name="packs">接收到的封包对象</param>
        /// <returns></returns>
        /// <remarks>
        /// 对于分包消息,如果收到的只是片段并且尚未接收完全,则不会进行解析
        /// </remarks>
        public static IPMessager.Entity.Message ParseToMessage(params Entity.PackedNetworkMessage[] packs)
        {
            if (packs.Length == 0 || (packs[0].PackageCount > 1 && packs.Length != packs[0].PackageCount))
            {
                return(null);
            }

            var ms = DecompressMessagePacks(packs);

            if (ms == null)
            {
                OnDecompressFailed(new DecomprssFailedEventArgs(packs));
                return(null);
            }

            //构造读取流
            var br = new System.IO.BinaryReader(ms, System.Text.Encoding.Unicode);

            //开始读出数据
            var m = new FSLib.IPMessager.Entity.Message(packs[0].RemoteIP);

            m.PackageNo = br.ReadUInt64();                                                      //包编号
            var tl = br.ReadUInt64();

            m.Command = (Define.Consts.Commands)(tl & 0xFF); //命令编码
            m.Options = tl & 0xFFFFFF00;                     //命令参数

            m.UserName = br.ReadString();                    //用户名
            m.HostName = br.ReadString();                    //主机名

            var length = br.ReadInt32();

            m.NormalMsgBytes = new byte[length];
            br.Read(m.NormalMsgBytes, 0, length);

            length = br.ReadInt32();
            m.ExtendMessageBytes = new byte[length];
            br.Read(m.ExtendMessageBytes, 0, length);

            if (!Consts.Check(m.Options, Consts.Cmd_All_Option.BinaryMessage))
            {
                m.NormalMsg     = System.Text.Encoding.Unicode.GetString(m.NormalMsgBytes, 0, length);                  //正文
                m.ExtendMessage = System.Text.Encoding.Unicode.GetString(m.ExtendMessageBytes, 0, length);              //扩展消息
            }

            return(m);
        }
Esempio n. 49
0
        /// <summary>
        /// Unserializes a BinaryStream into the Attributes of this Instance
        /// </summary>
        /// <param name="reader">The Stream that contains the FileData</param>
        public override void Unserialize(System.IO.BinaryReader reader)
        {
            tried   = false;
            version = reader.ReadUInt32();

            string name = reader.ReadString();
            uint   myid = reader.ReadUInt32();

            sgres.Unserialize(reader);
            sgres.BlockID = myid;

            if (Parent.Fast)
            {
                elements.Clear();
                links.Clear();
                groups.Clear();
                joints.Clear();
                return;
            }

            int count = reader.ReadInt32();

            elements.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcElement e = new GmdcElement(this);
                e.Unserialize(reader);
                elements.Add(e);
            }

            count = reader.ReadInt32();
            links.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcLink l = new GmdcLink(this);
                l.Unserialize(reader);
                links.Add(l);
            }

            count = reader.ReadInt32();
            groups.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcGroup g = new GmdcGroup(this);
                g.Unserialize(reader);
                groups.Add(g);
            }

            model.Unserialize(reader);

            count = reader.ReadInt32();
            joints.Clear();
            for (int i = 0; i < count; i++)
            {
                GmdcJoint s = new GmdcJoint(this);
                s.Unserialize(reader);
                joints.Add(s);
            }
        }
Esempio n. 50
0
 public bool Deserialize(byte[] data)
 {
     try
     {
         System.IO.MemoryStream ms = new System.IO.MemoryStream(data, false);
         using (System.IO.BinaryReader br = new System.IO.BinaryReader(ms))
         {
             int version = br.ReadInt32();
             int cnt     = br.ReadInt32();
             if (version < VersionWithBaseModel)
             {
                 bool bFemale = false;
                 for (int i = 0; i < cnt; i++)
                 {
                     int    part = br.ReadInt32();
                     string info = br.ReadString();
                     if (part >= 0 && part < _avatarParts.Length)
                     {
                         _avatarParts[part] = info;
                     }
                     bFemale |= info.ToLower().Contains("female");
                 }
                 _baseModel = bFemale ? CustomMetaData.InstanceFemale.baseModel : CustomMetaData.InstanceMale.baseModel;
             }
             else
             {
                 _baseModel = br.ReadString();
                 for (int i = 0; i < cnt; i++)
                 {
                     int    part = br.ReadInt32();
                     string info = br.ReadString();
                     if (part >= 0 && part < _avatarParts.Length)
                     {
                         _avatarParts[part] = info;
                     }
                 }
             }
             return(true);
         }
     }
     catch (System.Exception e)
     {
         Debug.LogWarning("CustomData.Deserialize Error:" + e.Message);
         return(false);
     }
 }
Esempio n. 51
0
        /// <summary>
        /// 分析网络数据包并进行转换为信息对象
        /// </summary>
        /// <param name="packs">接收到的封包对象</param>
        /// <returns></returns>
        /// <remarks>
        /// 对于分包消息,如果收到的只是片段并且尚未接收完全,则不会进行解析
        /// </remarks>
        public static Msg ParseToMessage(params PacketNetWorkMsg[] packs)
        {
            if (packs.Length == 0 || (packs[0].PackageCount > 1 && packs.Length != packs[0].PackageCount))
            {
                return(null);
            }


            var ms = DecompressMessagePacks(packs);

            if (ms == null)
            {
                //事件
                OnDecompressFailed(new PackageEventArgs(packs));
                return(null);
            }
            //构造读取流
            System.IO.BinaryReader br = new System.IO.BinaryReader(ms, System.Text.Encoding.Unicode);
            //开始读出数据
            Msg m = new Msg(packs[0].RemoteIP);

            m.PackageNo = br.ReadInt64();          //包编号

            m.UserName = br.ReadString();          //用户名
            m.HostName = br.ReadString();          //主机名
            m.Command  = (Commands)br.ReadInt64(); //命令
            m.Type     = (Consts)br.ReadInt64();   //数据类型
            int length = br.ReadInt32();           //数据长度

            m.NormalMsgBytes = new byte[length];
            br.Read(m.NormalMsgBytes, 0, length);     //读取内容

            length = br.ReadInt32();                  //附加数据长度
            m.ExtendMessageBytes = new byte[length];
            br.Read(m.ExtendMessageBytes, 0, length); //读取附加数据

            if (m.Type == Consts.MESSAGE_TEXT)
            {
                m.NormalMsg          = System.Text.Encoding.Unicode.GetString(m.NormalMsgBytes, 0, m.NormalMsgBytes.Length);         //正文
                m.ExtendMessage      = System.Text.Encoding.Unicode.GetString(m.ExtendMessageBytes, 0, m.ExtendMessageBytes.Length); //扩展消息
                m.ExtendMessageBytes = null;
                m.NormalMsgBytes     = null;
            }
            return(m);
        }
Esempio n. 52
0
        //把字节流转为manifest对象
        public static ManifestInfo GetManifestFromBytes(byte[] bytes)
        {
            ManifestInfo manifestInfo = null;

            try
            {
                //System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes.Uncompress());
                System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
                System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
                br.BaseStream.Position = 0;
                manifestInfo           = new ManifestInfo();
                manifestInfo.version   = br.ReadString();
                uint      num = br.ReadUInt32();
                AssetInfo assetInfo;
                while (num-- > 0)
                {
                    List <string> fileNameList = new List <string>();

                    string subPath     = br.ReadString();
                    long   length      = br.ReadInt64();
                    long   createDate  = br.ReadInt64();
                    string md5         = br.ReadString();
                    string suffix      = br.ReadString();
                    uint   fileNameNum = br.ReadUInt32();
                    while (fileNameNum-- > 0)
                    {
                        fileNameList.Add(br.ReadString());
                    }
                    assetInfo = new AssetInfo(subPath, length, createDate, md5, suffix, fileNameList);
                    manifestInfo.assetDic.Add(assetInfo.SubPath, assetInfo);
                }
                br.Close();
                ms.Close();
                ms.Dispose();
                return(manifestInfo);
            }
            catch (Exception e)
            {
                Debugger.LogError("GetManifestFromBytes:" + e);
            }
            finally
            {
            }
            return(null);
        }
Esempio n. 53
0
        private GraphMeta DeserializeMeta(ZipEntry entry)
        {
            if (entry == null)
            {
                throw new System.Exception("No metadata found in serialized data.");
            }

#if !ASTAR_NO_JSON
            string s = GetString(entry);

            JsonReader reader = new JsonReader(s, readerSettings);
            return((GraphMeta)reader.Deserialize(typeof(GraphMeta)));

            //JsonConvert.DeserializeObject<GraphMeta>(s,settings);
#else
            var meta = new GraphMeta();

            var mem = new System.IO.MemoryStream();
            entry.Extract(mem);
            mem.Position = 0;
            var reader = new System.IO.BinaryReader(mem);
            if (reader.ReadString() != "A*")
            {
                throw new System.Exception("Invalid magic number in saved data");
            }
            meta.version = new Version(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
            meta.graphs  = reader.ReadInt32();
            meta.guids   = new string[reader.ReadInt32()];
            for (int i = 0; i < meta.guids.Length; i++)
            {
                meta.guids[i] = reader.ReadString();
            }
            meta.typeNames = new string[reader.ReadInt32()];
            for (int i = 0; i < meta.typeNames.Length; i++)
            {
                meta.typeNames[i] = reader.ReadString();
            }
            meta.nodeCounts = new int[reader.ReadInt32()];
            for (int i = 0; i < meta.nodeCounts.Length; i++)
            {
                meta.nodeCounts[i] = reader.ReadInt32();
            }
            return(meta);
#endif
        }
Esempio n. 54
0
 private void DeserializeCallback(System.IO.BinaryReader reader, StatusInstance <TestObj> instance, TestObj obj)
 {
     Assert.AreEqual("hello", reader.ReadString());
     Assert.AreEqual(true, reader.ReadBoolean());
     if (instance.GetStatus <TestStatus>() == TestStatus.A)
     {
         deserializedInstanceA = instance;
     }
 }
Esempio n. 55
0
        private Customer GetCustomerFromBinary(System.IO.BinaryReader binaryReader)
        {
            if (binaryReader == null)
            {
                throw new ArgumentNullException(nameof(binaryReader));
            }

            var customer = new Customer()
            {
                CustomerID = binaryReader.ReadInt32(),
                Name       = binaryReader.ReadString(),
                Address    = binaryReader.ReadString(),
                City       = binaryReader.ReadString(),
                State      = binaryReader.ReadString(),
                ZipCode    = binaryReader.ReadString()
            };

            return(customer);
        }
Esempio n. 56
0
        public Material(System.IO.BinaryReader br)
        {
            m_ambientColor = new Vec4(br);
            m_diffuseColor = new Vec4(br);
            m_name         = br.ReadString();
            bool isOpacityMapNull = br.ReadBoolean();

            if (isOpacityMapNull)
            {
                this.m_opacityMap = null;
            }
            else
            {
                this.m_opacityMap = MaterialMap.Load(br);
            }

            this.m_shininess     = (float)br.ReadDouble();
            this.m_specularColor = new Vec4(br);
            int count = br.ReadInt32();

            if (count > 0)
            {
                for (int i = 0; i < count; ++i)
                {
                    AddMaterialMap(MaterialMap.Load(br));
                }
            }

            this.Transparency = (float)br.ReadDouble();
            this.m_twoSided   = br.ReadBoolean();
            this.m_scale      = (float)br.ReadDouble();
            if (this.m_scale != 1)
            {
                this.hasTexTransform = true;
            }
            if (br.ReadBoolean())
            {
                remapUV    = new Vec2[2];
                remapUV[0] = Vec2.Load(br);
                remapUV[1] = Vec2.Load(br);
            }
            else
            {
                remapUV = null;
            }
            if (br.PeekChar() == '~')
            {
                br.ReadChar();
                count = br.ReadInt32();
                for (int i = 0; i < count; ++i)
                {
                    AddShader(Shader.Load(br));
                }
            }
        }
Esempio n. 57
0
        public RecievePacket handleData(System.IO.BinaryReader br, System.IO.BinaryWriter bw, System.Net.Sockets.TcpClient client)
        {
            byte   code  = br.ReadByte();
            string avi   = "";
            string phash = "";

            if (code == (byte)constants.LOGIN_SUCCESS)
            {
                avi   = br.ReadString();
                phash = br.ReadString();
                Config.LocalScores = false;
            }
            string        user = br.ReadString();
            List <object> l    = new List <object>();

            l.Add(code);
            l.Add(avi);
            l.Add(user);
            l.Add(phash);
            return(new RecievePacket(l));
        }
Esempio n. 58
0
        public static string SendAndWaitString(string channelName, string destId, object packet, int timeout)
        {
            byte[] answer;
            if (SendAndWaitAnswer(channelName, destId, packet, timeout, out answer) == false)
            {
                return(null);
            }
            System.IO.BinaryReader r = new System.IO.BinaryReader(new System.IO.MemoryStream(answer));
            string s = r.ReadString();

            r.Close();
            return(s);
        }
Esempio n. 59
0
        internal virtual void Load(System.IO.BinaryReader reader)
        {
            state = (TriState)reader.ReadByte();
            uid   = reader.ReadUInt32();
            info  = reader.ReadString();
            byte ct = reader.ReadByte();

            data = new uint[ct];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = reader.ReadUInt32();
            }
        }
Esempio n. 60
0
        static public string ReadNullableString(System.IO.BinaryReader r)
        {
            bool isNull = r.ReadBoolean();

            if (isNull)
            {
                return(null);
            }
            else
            {
                return(r.ReadString());
            }
        }