Esempio n. 1
0
 /// <summary>
 /// Load the structure from a binary reader
 /// </summary>
 /// <param name="reader">   Binary reader</param>
 public void LoadFromStream(System.IO.BinaryReader reader) {
     m_lVal1 = reader.ReadInt64();
     m_lVal2 = reader.ReadInt64();
     m_lVal3 = reader.ReadInt64();
     m_lVal4 = reader.ReadInt64();
     m_eInfo = (ChessBoard.BoardStateMaskE)reader.ReadInt32();
 }
 protected override void readData(System.IO.BinaryReader DataInput)
 {
     this.xPosition = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64()));
     this.yPosition = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64()));
     this.stance = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64()));
     this.zPosition = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64()));
     base.readData(DataInput);
 }
Esempio n. 3
0
 public override object Deserialize(System.IO.BinaryReader binaryReader)
 {
     bool hasValue = binaryReader.ReadBoolean ();
     if (!hasValue)
         return null;
     int typeID = binaryReader.ReadByte ();
     switch (typeID) {
     case 1:
         return binaryReader.ReadBoolean ();
     case 2:
         return binaryReader.ReadByte ();
     case 128:
         return binaryReader.ReadSByte ();
     case 3:
         return binaryReader.ReadInt16 ();
     case 129:
         return binaryReader.ReadUInt16 ();
     case 4:
         return binaryReader.ReadInt32 ();
     case 130:
         return binaryReader.ReadUInt32 ();
     case 5:
         return binaryReader.ReadInt64 ();
     case 131:
         return binaryReader.ReadUInt64 ();
     case 9:
         return binaryReader.ReadDouble ();
     case 16:
         return binaryReader.ReadString ();
     case 144:
         return binaryReader.ReadChar ();
     case 24:
         return new DateTime (binaryReader.ReadInt64 ());
     case 32:
         return new Guid (binaryReader.ReadBytes (16));
     case 36:
         return binaryReader.ReadBytes (binaryReader.ReadInt32 ());
     case 37:
         {
             int count = binaryReader.ReadInt32 ();
             string[] r = new string[count];
             for (int n = 0; n != count; n++)
                 r [n] = binaryReader.ReadString ();
             return r;
         }
     case 38:
         {
             int count = binaryReader.ReadInt32 ();
             long[] r = new long[count];
             for (int n = 0; n != count; n++)
                 r [n] = binaryReader.ReadInt64 ();
             return r;
         }
     default:
         throw new Exception (string.Format ("Serialization for type <{0}> is not supported", typeID));
     }
 }
Esempio n. 4
0
        public override void Read(System.IO.BinaryReader reader)
        {
            base.Read(reader);

            guid = new uidkey(reader);

            lastLogin = new DateTime(reader.ReadInt64());
            createDate = new DateTime(reader.ReadInt64());
            email = reader.ReadString();
            password = reader.ReadString();
        }
 protected override void readData(System.IO.BinaryReader DataInput)
 {
     DataInput.ReadInt32();
     int i = IPAddress.NetworkToHostOrder(DataInput.ReadInt32());
     for (int j = 0; j < i; ++j)
     {
         readString(DataInput, 64);
         DataInput.ReadDouble();
         short l = IPAddress.NetworkToHostOrder(DataInput.ReadInt16());
         for (int k = 0; k < l; ++k)
         {
             DataInput.ReadInt64();
             DataInput.ReadInt64();
             DataInput.ReadInt64();
             DataInput.ReadByte();
         }
     }
 }
Esempio n. 6
0
        public static DDCaps Read(System.IO.BinaryReader r)
        {
            DDCaps caps = new DDCaps();
            caps.caps1 = r.ReadInt32();
            caps.caps2 = r.ReadInt32();
            r.ReadInt64(); // reserved[2]

            return caps;
        }
        public void ReadFrom(ref MyOctreeStorage.ChunkHeader header, System.IO.Stream stream, ref bool isOldFormat)
        {
            m_data.Version = stream.ReadInt64();
            m_data.Seed = stream.ReadInt64();
            m_data.Radius = stream.ReadDouble();
            string generator = stream.ReadString();

            if (m_data.Version != STORAGE_VERSION) {
                isOldFormat = true;
            }

            var def = MyDefinitionManager.Static.GetDefinition<MyPlanetGeneratorDefinition>(MyStringHash.GetOrCompute(generator));

            if (def == null) throw new Exception(String.Format("Cannot load planet generator definition for subtype '{0}'.", generator));

            Generator = def;

            Init();
        }
Esempio n. 8
0
        protected override void readData(System.IO.BinaryReader DataInput)
        {
            this.explosionX = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64())); ;
            this.explosionY = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64())); ;
            this.explosionZ = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(DataInput.ReadInt64())); ;
            this.explosionSize = BitConverter.ToSingle(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(DataInput.ReadInt32())), 0);
            int i = DataInput.ReadInt32();
            int j = (int)this.explosionX;
            int k = (int)this.explosionY;
            int l = (int)this.explosionZ;

            for (int i1 = 0; i1 < i; ++i1)
            {
                int j1 = DataInput.ReadByte() + j;
                int k1 = DataInput.ReadByte() + k;
                int l1 = DataInput.ReadByte() + l;
            }

            this.playerVelocityX = BitConverter.ToSingle(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(DataInput.ReadInt32())), 0);
            this.playerVelocityY = BitConverter.ToSingle(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(DataInput.ReadInt32())), 0);
            this.playerVelocityZ = BitConverter.ToSingle(BitConverter.GetBytes(IPAddress.NetworkToHostOrder(DataInput.ReadInt32())), 0);
        }
        internal override void Read(System.IO.BinaryReader reader, BinaryReadInfo readInfo)
        {
            uint length = reader.ReadUInt32();

            ID = reader.ReadUInt32();
            uint numSections = reader.ReadUInt32();

            string componentName = null;
            bool canResize = false;
            bool canFlip = false;
            double minSize = ComponentHelper.GridSize;
            List<ComponentProperty> properties = new List<ComponentProperty>();
            List<ConnectionGroup> connections = new List<ConnectionGroup>();
            List<RenderDescription> renderDescriptions = new List<RenderDescription>();
            List<Conditional<FlagOptions>> flagOptions = new List<Conditional<FlagOptions>>();
            ComponentDescriptionMetadata descriptionMetadata = new ComponentDescriptionMetadata();
            uint? iconResourceId = null;

            for (uint sectionCounter = 0; sectionCounter < numSections; sectionCounter++)
            {
                ushort sectionType = reader.ReadUInt16();
                uint sectionLength = reader.ReadUInt32();

                #region Metadata
                if (sectionType == (uint)BinaryConstants.ComponentSectionType.Metadata)
                {
                    componentName = reader.ReadString();
                    canResize = reader.ReadBoolean();
                    canFlip = reader.ReadBoolean();
                    minSize = reader.ReadDouble();
                    descriptionMetadata.Type = String.Format("Binary r{0} (*.cdcom)", readInfo.FormatVersion);
                    descriptionMetadata.GUID = new Guid(reader.ReadBytes(16));
                    descriptionMetadata.Author = reader.ReadString();
                    if (readInfo.IsSignatureValid && readInfo.Certificate != null && readInfo.IsCertificateTrusted)
                        descriptionMetadata.Author = readInfo.Certificate.GetNameInfo(X509NameType.EmailName, false);
                    descriptionMetadata.Version = new Version(reader.ReadUInt16(), reader.ReadUInt16());
                    descriptionMetadata.AdditionalInformation = reader.ReadString();
                    descriptionMetadata.ImplementSet = reader.ReadString();
                    descriptionMetadata.ImplementItem = reader.ReadString();
                    descriptionMetadata.Signature.IsHashValid = readInfo.IsSignatureValid;
                    descriptionMetadata.Signature.Certificate = readInfo.Certificate;
                    descriptionMetadata.Signature.IsCertificateTrusted = readInfo.IsCertificateTrusted;
                    int iconResource = reader.ReadInt32();
                    if (iconResource != -1)
                        iconResourceId = (uint)iconResource;
                    long created = reader.ReadInt64();
                }
                #endregion
                #region Flags
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Flags)
                {
                    uint numFlagGroups = reader.ReadUInt32();
                    for (uint j = 0; j < numFlagGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                            conditions = reader.ReadConditionTree();
                        else
                            conditions = reader.ReadConditionCollection();

                        FlagOptions value = (FlagOptions)reader.ReadUInt32();
                        flagOptions.Add(new Conditional<FlagOptions>(value, conditions));
                    }
                }
                #endregion
                #region Properties
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Properties)
                {
                    uint numProperties = reader.ReadUInt32();
                    for (uint j = 0; j < numProperties; j++)
                    {
                        string propertyName = reader.ReadString();
                        string serializedName = reader.ReadString();
                        string displayName = reader.ReadString();
                        BinaryType propType;
                        object rawDefaultValue = reader.ReadType(out propType);
                        PropertyUnion defaultValue = propType.ToPropertyUnion(rawDefaultValue);
                        string[] enumOptions = null;
                        if (propType == BinaryType.Enum)
                        {
                            enumOptions = new string[reader.ReadInt32()];
                            for (int k = 0; k < enumOptions.Length; k++)
                                enumOptions[k] = reader.ReadString();
                        }

                        // Format rules
                        List<ComponentPropertyFormat> formatRules = new List<ComponentPropertyFormat>();
                        uint numFormatRules = reader.ReadUInt32();
                        for (uint k = 0; k < numFormatRules; k++)
                        {
                            IConditionTreeItem conditions;
                            if (readInfo.FormatVersion > 1)
                                conditions = reader.ReadConditionTree();
                            else
                                conditions = reader.ReadConditionCollection();
                            string formatRule = reader.ReadString();
                            formatRules.Add(new ComponentPropertyFormat(formatRule, conditions));
                        }

                        // Other conditions
                        uint numOtherConditions = reader.ReadUInt32();
                        Dictionary<PropertyOtherConditionType, IConditionTreeItem> otherConditions = new Dictionary<PropertyOtherConditionType, IConditionTreeItem>((int)numOtherConditions);
                        for (uint k = 0; k < numOtherConditions; k++)
                        {
                            uint uintConditionType = reader.ReadUInt32();
                            IConditionTreeItem conditions;
                            if (readInfo.FormatVersion > 1)
                                conditions = reader.ReadConditionTree();
                            else
                                conditions = reader.ReadConditionCollection();
                            PropertyOtherConditionType conditionType = (PropertyOtherConditionType)uintConditionType;
                            otherConditions.Add(conditionType, conditions);
                        }

                        properties.Add(new ComponentProperty(propertyName, serializedName, displayName, BinaryIOExtentions.BinaryTypeToPropertyType(propType), defaultValue, formatRules.ToArray(), otherConditions, enumOptions));
                    }
                }
                #endregion
                #region Configurations
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Configurations)
                {
                    uint numConfigurations = reader.ReadUInt32();
                    for (int j = 0; j < numConfigurations; j++)
                    {
                        string configurationName = reader.ReadString();
                        string implementationName = reader.ReadString();

                        int numSetters = reader.ReadInt32();
                        var setters = new Dictionary<string, PropertyUnion>(numSetters);
                        for (int k = 0; k < numSetters; k++)
                        {
                            BinaryType tempType;
                            string name = reader.ReadString();
                            var setterValue = reader.ReadType(out tempType);
                            setters.Add(name, tempType.ToPropertyUnion(setterValue));
                        }

                        int iconID = reader.ReadInt32();

                        var configuration = new ComponentConfiguration(implementationName, configurationName, setters);
                        descriptionMetadata.Configurations.Add(configuration);

                        if (iconID != -1)
                            iconResources.Add(configuration, (uint)iconID);
                    }
                }
                #endregion
                #region Connections
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Connections)
                {
                    uint numConnectionGroups = reader.ReadUInt32();
                    List<ConnectionGroup> connectionGroups = new List<ConnectionGroup>();
                    for (int j = 0; j < numConnectionGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                            conditions = reader.ReadConditionTree();
                        else
                            conditions = reader.ReadConditionCollection();

                        List<ConnectionDescription> tConnections = new List<ConnectionDescription>();
                        uint numConnections = reader.ReadUInt32();
                        for (uint k = 0; k < numConnections; k++)
                        {
                            tConnections.Add(new ConnectionDescription(reader.ReadComponentPoint(), reader.ReadComponentPoint(), (ConnectionEdge)reader.ReadInt32(), reader.ReadString()));
                        }

                        connections.Add(new ConnectionGroup(conditions, tConnections.ToArray()));
                    }
                }
                #endregion
                #region Render
                else if (sectionType == (uint)BinaryConstants.ComponentSectionType.Render)
                {
                    uint numRenderGroups = reader.ReadUInt32();
                    for (uint j = 0; j < numRenderGroups; j++)
                    {
                        IConditionTreeItem conditions;
                        if (readInfo.FormatVersion > 1)
                            conditions = reader.ReadConditionTree();
                        else
                            conditions = reader.ReadConditionCollection();

                        int numRenderCommands = (int)reader.ReadUInt32();
                        List<IRenderCommand> renderCommands = new List<IRenderCommand>(numRenderCommands);
                        for (int k = 0; k < numRenderCommands; k++)
                        {
                            RenderCommandType commandType = (RenderCommandType)reader.ReadUInt32();
                            switch (commandType)
                            {
                                case RenderCommandType.Line:
                                    {
                                        ComponentPoint start = reader.ReadComponentPoint();
                                        ComponentPoint end = reader.ReadComponentPoint();
                                        double thickness = reader.ReadDouble();
                                        renderCommands.Add(new Line(start, end, thickness));
                                    }
                                    continue;
                                case RenderCommandType.Rect:
                                    {
                                        ComponentPoint location = reader.ReadComponentPoint();
                                        double width = reader.ReadDouble();
                                        double height = reader.ReadDouble();
                                        double thickness = reader.ReadDouble();
                                        bool fill = (reader.ReadUInt32() == 0 ? false : true);
                                        renderCommands.Add(new Rectangle(location, width, height, thickness, fill));
                                    }
                                    continue;
                                case RenderCommandType.Ellipse:
                                    {
                                        ComponentPoint centre = reader.ReadComponentPoint();
                                        double radiusX = reader.ReadDouble();
                                        double radiusY = reader.ReadDouble();
                                        double thickness = reader.ReadDouble();
                                        bool fill = (reader.ReadUInt32() == 0 ? false : true);
                                        renderCommands.Add(new Ellipse(centre, radiusX, radiusY, thickness, fill));
                                    }
                                    continue;
                                case RenderCommandType.Path:
                                    {
                                        ComponentPoint start = reader.ReadComponentPoint();
                                        double thickness = reader.ReadDouble();
                                        bool fill = (reader.ReadUInt32() == 0 ? false : true);

                                        int numCommands = reader.ReadInt32();
                                        List<IPathCommand> pathCommands = new List<IPathCommand>(numCommands);
                                        for (int l = 0; l < numCommands; l++)
                                        {
                                            CommandType pType = (CommandType)reader.ReadInt32();
                                            IPathCommand theCommand = null;
                                            switch (pType)
                                            {
                                                case CommandType.MoveTo:
                                                    theCommand = new MoveTo();
                                                    break;
                                                case CommandType.LineTo:
                                                    theCommand = new LineTo();
                                                    break;
                                                case CommandType.CurveTo:
                                                    theCommand = new CurveTo();
                                                    break;
                                                case CommandType.EllipticalArcTo:
                                                    theCommand = new EllipticalArcTo();
                                                    break;
                                                case CommandType.QuadraticBeizerCurveTo:
                                                    theCommand = new QuadraticBeizerCurveTo();
                                                    break;
                                                case CommandType.SmoothCurveTo:
                                                    theCommand = new SmoothCurveTo();
                                                    break;
                                                case CommandType.SmoothQuadraticBeizerCurveTo:
                                                    theCommand = new SmoothQuadraticBeizerCurveTo();
                                                    break;
                                                default:
                                                    theCommand = new ClosePath();
                                                    break;
                                            }
                                            theCommand.Read(reader);
                                            pathCommands.Add(theCommand);
                                        }

                                        renderCommands.Add(new RenderPath(start, thickness, fill, pathCommands));
                                    }
                                    continue;
                                case RenderCommandType.Text:
                                    {
                                        byte formattedTextVersion = reader.ReadByte();
                                        ComponentPoint location = reader.ReadComponentPoint();
                                        TextAlignment alignment = (TextAlignment)reader.ReadUInt32();

                                        uint numTextRuns = reader.ReadUInt32();
                                        List<TextRun> textRuns = new List<TextRun>((int)numTextRuns);
                                        for (uint l = 0; l < numTextRuns; l++)
                                        {
                                            TextRunFormattingType formattingType = (TextRunFormattingType)reader.ReadUInt32();
                                            double runSize = reader.ReadDouble();
                                            string runText = reader.ReadString();
                                            textRuns.Add(new TextRun(runText, new TextRunFormatting(formattingType, runSize)));
                                        }

                                        renderCommands.Add(new Text(location, alignment, textRuns));
                                    }
                                    continue;
                            }
                        }

                        renderDescriptions.Add(new RenderDescription(conditions, renderCommands.ToArray()));
                    }
                }
                #endregion
                #region Skip
                else
                {
                    // Unknown type - skip
                    reader.BaseStream.Seek(sectionLength, SeekOrigin.Current);
                }
                #endregion
            }

            ComponentDescription = new ComponentDescription(ID.ToString(), componentName, canResize, canFlip, minSize, properties.ToArray(), connections.ToArray(), renderDescriptions.ToArray(), flagOptions.ToArray(), descriptionMetadata);

            if (iconResourceId.HasValue)
                mainIconResource = iconResourceId.Value;
        }
Esempio n. 10
0
 public object Deserialize2(System.IO.BinaryReader reader, int lenght)
 {
     var result = new InputValue[lenght];
     for (int i = 0; i < lenght; i++ )
     {
         result[i] = new InputValue
         {
             Id = reader.ReadInt64(),
             Value = reader.ReadInt64(),
             UTCFrom = DateTime.FromBinary(reader.ReadInt64()),
             UTCTo = DateTime.FromBinary(reader.ReadInt64()),
             IsDeletedValue = reader.ReadBoolean(),
             ImportEventId = reader.ReadInt64(),
             ObsolescenceEventId = reader.ReadInt64(),
         };
     }
     return result;
 }
Esempio n. 11
0
 protected override void readData(System.IO.BinaryReader DataInput)
 {
     this.worldAge = IPAddress.NetworkToHostOrder(DataInput.ReadInt64());
     this.time = IPAddress.NetworkToHostOrder(DataInput.ReadInt64());
 }
Esempio n. 12
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());
            }
                case JSONBinaryTag.LongValue:
            {
                return new JSONData(aReader.ReadInt64());
            }

            default:
            {
                throw new Exception("Error deserializing JSON. Unknown tag: " + type);
            }
            }
        }
        //private bool shouldWriteVersion1;
        //public void WriteVersion1()
        //{
        //    shouldWriteVersion1 = true;
        //}

        //private void WriteVersion1(XmlWriter writer)
        //{
        //    writer.WriteElementString("Version", "1");

        //    writer.WriteStartElement("DataType");
        //    var dataType = Data != null ? Data.GetType() : null;
        //    writer.WriteValue(dataType != null ? dataType.GetTraceLabQualifiedName() : "null");
        //    writer.WriteEndElement();

        //    // Serialize the data.
        //    writer.WriteStartElement("Data");

        //    if (dataType != null)
        //    {
        //        var serial = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(dataType, null);
        //        serial.Serialize(writer, Data);
        //    }

        //    writer.WriteEndElement();
        //}


        #endregion



        #region IRawSerializable Members

        public void ReadData(System.IO.BinaryReader reader)
        {
            var dataVersion = reader.ReadInt64();
            if (dataVersion == CurrentVersion)
            {
                ReadCurrentRawVersion(reader);
            }
        }
    public void Read(System.IO.BinaryReader r)
    {
        #if DEBUG
        int LCount = r.ReadInt32();
        #else
        int LCount = Sql.Read7BitEncodedInt(r);
        #endif

        FList.Capacity = LCount;
        for(; LCount > 0; LCount--)
          FList.Add(r.ReadInt64());
    }
Esempio n. 15
0
        /// <summary>
        /// Читает P-объект из бинарного ридера, начиная с текущего места
        /// </summary>
        /// <param name="typ"></param>
        /// <param name="br"></param>
        /// <returns></returns>
        internal static object GetPO(PType typ, System.IO.BinaryReader br)
        {
            switch (typ.Vid)
            {
                case PTypeEnumeration.none: return null;
                case PTypeEnumeration.boolean: return br.ReadBoolean();
                case PTypeEnumeration.integer: return br.ReadInt32();
                case PTypeEnumeration.longinteger: return br.ReadInt64();
                case PTypeEnumeration.real: return br.ReadDouble();
                case PTypeEnumeration.@byte: return br.ReadByte();
                case PTypeEnumeration.fstring:
                    {
                        //int len = ((PTypeFString)typ).Length;
                        int size = ((PTypeFString)typ).Size;
                        byte[] arr = new byte[size];
                        arr = br.ReadBytes(size);
                        string s = System.Text.Encoding.Unicode.GetString(arr);
                        return s;
                    }
                case PTypeEnumeration.sstring:
                    {
                        int len = br.ReadInt32();
                        char[] chrs = br.ReadChars(len);
                        return new string(chrs);
                    }
                case PTypeEnumeration.record:
                    {
                        PTypeRecord r_tp = (PTypeRecord)typ;
                        object[] fields = new object[r_tp.Fields.Length];
                        for (int i = 0; i < r_tp.Fields.Length; i++)
                        {
                            fields[i] = GetPO(r_tp.Fields[i].Type, br);
                        }
                        return fields;
                    }
                case PTypeEnumeration.sequence:
                    {
                        PTypeSequence mts = (PTypeSequence)typ;
                        PType tel = mts.ElementType;
                        long llen = br.ReadInt64();
                        object[] els = new object[llen];
                        for (long ii = 0; ii < llen; ii++) els[ii] = GetPO(tel, br);
                        return els;
                    }
                case PTypeEnumeration.union:
                    {
                        PTypeUnion mtu = (PTypeUnion)typ;
                        int v = br.ReadByte();
                        PType mt = mtu.Variants[v].Type;
                        return new object[] { v, GetPO(mt, br) };
                    }

                default: throw new Exception("Err in TPath Get(): type is not implemented " + typ.Vid);
            }
        }
Esempio n. 16
0
 public void Deserialize(System.IO.BinaryReader reader)
 {
     Id = reader.ReadInt64();
     StatusType = (StatusType)reader.ReadInt32();
     User = reader.ReadObject<TwitterUser>();
     Text = reader.ReadString();
     CreatedAt = reader.ReadDateTime();
     IsFavored = reader.ReadBoolean();
     if (reader.ReadBoolean())
     {
         Source = reader.ReadString();
     }
     InReplyToStatusId = reader.ReadNullableLong();
     InReplyToUserId = reader.ReadNullableLong();
     if (reader.ReadBoolean())
     {
         InReplyToScreenName = reader.ReadString();
     }
     RetweetedOriginalId = reader.ReadNullableLong();
     Latitude = reader.ReadNullableDouble();
     Longitude = reader.ReadNullableDouble();
     if (reader.ReadBoolean())
     {
         FavoritedUsers = reader.ReadIds().ToArray();
     }
     if (reader.ReadBoolean())
     {
         RetweetedUsers = reader.ReadIds().ToArray();
     }
     RetweetedOriginal = reader.ReadObject<TwitterStatus>();
     Recipient = reader.ReadObject<TwitterUser>();
     if (reader.ReadBoolean())
     {
         Entities = reader.ReadCollection<TwitterEntity>().ToArray();
     }
 }
Esempio n. 17
0
        private void ReadNode(System.IO.BinaryReader file)
        {
            // Read node info
            mType = (ENodeType)file.ReadInt32();
            mName = file.ReadString();
            mOffset = file.ReadInt64();
            int count = file.ReadInt32();

            // Recursively read child nodes
            for (int i = 0; i < count; i++)
            {
                CCatalogNode node = new CCatalogNode();
                mNodes.Add(node);
                node.ReadNode(file);
            }
        }
    public void Read(System.IO.BinaryReader r)
    {
        //BinaryFormatter LFormatter = new BinaryFormatter();
        //FList = (List<DateTime>)LFormatter.Deserialize(r.BaseStream);

        #if DEBUG
        int LCount = r.ReadInt32();
        #else
        int LCount = Sql.Read7BitEncodedInt(r);
        #endif

        FList.Capacity = LCount;
        for(; LCount > 0; LCount--)
          FList.Add(DateTime.FromBinary(r.ReadInt64()));
    }
Esempio n. 19
0
        public override void Deserialize(System.IO.BinaryReader reader)
        {
            base.Deserialize(reader);

            StartingFlags = reader.ReadInt64();
        }
Esempio n. 20
0
 internal RisenPakFile(System.IO.BinaryReader bR, RisenPakFilePart P, RisenPak Container)
 {
     base.name = string.Empty;
     base.parent = P;
     int l = bR.ReadInt32();
     if (l != 0)
         l++;
     base.name = new string(bR.ReadChars(l));
     offset = bR.ReadInt64();
     base.TimeCreated = bR.ReadInt64();
     base.TimeLastAccessed = bR.ReadInt64();
     base.TimeLastModified = bR.ReadInt64();
     base.Attributes = (RisenPakAttributes)bR.ReadUInt32() | RisenPakAttributes.RisenPakAttribute_Packed;
     encrypt = (RisenPakEncryption)bR.ReadUInt32();
     Compression = (RisenPakCompression)bR.ReadUInt32();
     compSize = bR.ReadInt32();
     uncompSize = bR.ReadInt32();
     m_Stream = null;
     _init(Container);
 }
Esempio n. 21
0
 internal RisenPakDirectory(System.IO.BinaryReader bR, RisenPakFilePart P2, RisenPak Container)
 {
     base.name = string.Empty;
     base.parent = P2;
     int l = bR.ReadInt32();
     if (l != 0)
         l++;
     base.name = new string(bR.ReadChars(l));
     base.TimeCreated = bR.ReadInt64();
     base.TimeLastAccessed = bR.ReadInt64();
     base.TimeLastModified = bR.ReadInt64();
     base.Attributes = (RisenPakAttributes)bR.ReadUInt32() | RisenPakAttributes.RisenPakAttribute_Packed;
     int count = bR.ReadInt32();
     children = new List<RisenPakFilePart>();
     for (int i = 0; i < count; i++)
     {
         RisenPakAttributes attrib = (RisenPakAttributes)bR.ReadUInt32();
         if ((attrib & RisenPakAttributes.RisenPakAttribute_Directory) == RisenPakAttributes.RisenPakAttribute_Directory)
             children.Add(new RisenPakDirectory(bR, this, Container));
         else children.Add(new RisenPakFile(bR, this, Container));
     }
     _init(Container);
 }
Esempio n. 22
0
 public object Deserialize(System.IO.BinaryReader reader)
 {
     return new InputValue
     {
         Id = reader.ReadInt64(),
         Value = reader.ReadInt64(),
         UTCFrom = DateTime.FromBinary(reader.ReadInt64()),
         UTCTo = DateTime.FromBinary(reader.ReadInt64()),
         IsDeletedValue = reader.ReadBoolean(),
         ImportEventId = reader.ReadInt64(),
         ObsolescenceEventId = reader.ReadInt64(),
     };
 }
Esempio n. 23
0
        protected override void Read(System.IO.BinaryReader r)
        {
            Init();

            // Read e_ident
            byte[] e_ident = r.ReadBytes(16);
            if ((e_ident[0] != 0x7f) || (e_ident[1] != (byte)'E') || (e_ident[2] != (byte)'L') || (e_ident[3] != (byte)'F'))
                throw new Exception("Not an ELF file");
            ec = (ElfClass)e_ident[4];
            ed = (ElfData)e_ident[5];

            if ((ec != ElfClass.ELFCLASS32) && (ec != ElfClass.ELFCLASS64))
                throw new Exception("Invalid ELF class: " + e_ident[4].ToString());
            if (ed != ElfData.ELFDATA2LSB)
                throw new Exception("Invalid ELF data type: " + e_ident[5].ToString());

            if (e_ident[6] != 1)
                throw new Exception("Invalid ELF version: " + e_ident[6].ToString());

            // Read the rest of the file header
            switch (ec)
            {
                case ElfClass.ELFCLASS32:
                    ReadElf32FileHeader(r);
                    break;

                case ElfClass.ELFCLASS64:
                    ReadElf64FileHeader(r);
                    break;
            }

            // Identify the arch, OS and machine type
            os = "none";
            binary_type = BinaryTypes[ec];
            architecture = MachineTypes[e_machine];

            // First iterate through and identify the offsets of each section
            List<long> sect_offsets = new List<long>();
            for (int i = 0; i < e_shnum; i++)
            {
                long sh_start = e_shoff + i * e_shentsize;
                r.BaseStream.Seek(sh_start, System.IO.SeekOrigin.Begin);

                switch (ec)
                {
                    case ElfClass.ELFCLASS32:
                        r.BaseStream.Seek(16, System.IO.SeekOrigin.Current);
                        sect_offsets.Add(r.ReadInt32());
                        break;
                    case ElfClass.ELFCLASS64:
                        r.BaseStream.Seek(24, System.IO.SeekOrigin.Current);
                        sect_offsets.Add(r.ReadInt64());
                        break;
                }
            }

            // Now load the section data
            List<SectionHeader> sect_headers = new List<SectionHeader>();
            for (int i = 0; i < e_shnum; i++)
            {
                // First load the section header
                long sh_start = e_shoff + i * e_shentsize;
                r.BaseStream.Seek(sh_start, System.IO.SeekOrigin.Begin);
                SectionHeader sh = null;
                switch (ec)
                {
                    case ElfClass.ELFCLASS32:
                        sh = ReadElf32SectionHeader(r);
                        break;
                    case ElfClass.ELFCLASS64:
                        sh = ReadElf64SectionHeader(r);
                        break;
                }
                sect_headers.Add(sh);

                // Now get the name
                string name = "unknown";
                if (e_shstrndx != 0)
                {
                    long name_offset = sect_offsets[e_shstrndx] +
                        sh.sh_name;
                    name = ReadString(r, name_offset);
                }

                // Now load the actual section
                // Decide on the type of section
                ISection sect = null;
                switch (sh.sh_type)
                {
                    case SectionHeader.SHT_NULL:
                        break;
                    case SectionHeader.SHT_PROGBITS:
                    case SectionHeader.SHT_REL:
                    case SectionHeader.SHT_RELA:
                    case SectionHeader.SHT_HASH:
                    case SectionHeader.SHT_DYNAMIC:
                    case SectionHeader.SHT_NOTE:
                    case SectionHeader.SHT_STRTAB:
                        sect = new ContentsSection(this);
                        break;
                    case SectionHeader.SHT_SYMTAB:
                    case SectionHeader.SHT_DYNSYM:
                        sect = new ElfSymbolSection(this);
                        break;
                    case SectionHeader.SHT_NOBITS:
                        sect = new BssSection(this);
                        break;
                }

                if (sect != null)
                {
                    // Interpret the section type
                    sect.IsWriteable = ((sh.sh_flags & SectionHeader.SHF_WRITE) != 0);
                    sect.IsAlloc = ((sh.sh_flags & SectionHeader.SHF_ALLOC) != 0);
                    sect.IsExecutable = ((sh.sh_flags & SectionHeader.SHF_EXECINSTR) != 0);

                    sect.LoadAddress = sh.sh_addr;
                    sect.Name = name;
                    sect.AddrAlign = sh.sh_addralign;

                    // Load the contents if it has any
                    sect.Length = sh.sh_size;
                    if (sect.HasData)
                    {
                        r.BaseStream.Seek(sh.sh_offset, System.IO.SeekOrigin.Begin);
                        for (long l = 0; l < sh.sh_size; l++)
                            sect.Data[(int)l] = r.ReadByte();
                    }


                }
                sections.Add(sect);
            }

            // Interpret symbols
            for (int i = 0; i < e_shnum; i++)
            {
                SectionHeader sh = sect_headers[i];
                ISection sect = sections[i];

                if ((sh.sh_type == SectionHeader.SHT_SYMTAB) && sect.HasData)
                {
                    int cur_sym = 0;
                    for (long p = 0; p < sect.Length; p += sh.sh_entsize)
                    {
                        ElfSymbol s = null;

                        switch (ec)
                        {
                            case ElfClass.ELFCLASS32:
                                s = ReadElf32Symbol(sect.Data, (int)p);
                                break;
                            case ElfClass.ELFCLASS64:
                                s = ReadElf64Symbol(sect.Data, (int)p);
                                break;
                        }

                        if (s != null)
                        {
                            // Load up the name of the symbol
                            if (sh.sh_link != 0)
                                s.Name = ReadString(sections[sh.sh_link].Data, s.st_name);

                            // Offset
                            s.Offset = s.st_value;

                            // Length
                            s.Size = s.st_size;

                            // Type
                            switch (s.st_bind)
                            {
                                case ElfSymbol.STB_GLOBAL:
                                    s.Type = SymbolType.Global;
                                    break;
                                case ElfSymbol.STB_LOCAL:
                                    s.Type = SymbolType.Local;
                                    break;
                                case ElfSymbol.STB_WEAK:
                                    s.Type = SymbolType.Weak;
                                    break;
                            }
                            switch(s.st_type)
                            {
                                case ElfSymbol.STT_FUNC:
                                    s.ObjectType = SymbolObjectType.Function;
                                    break;
                                case ElfSymbol.STT_OBJECT:
                                    s.ObjectType = SymbolObjectType.Object;
                                    break;
                                default:
                                    s.ObjectType = SymbolObjectType.Unknown;
                                    break;                                    
                            }

                            // DefinedIn
                            if (s.st_shndx == 0)
                            {
                                s.DefinedIn = null;
                                s.Type = SymbolType.Undefined;
                            }
                            else if (s.st_shndx == -15)
                            {
                                // SHN_ABS
                                s.DefinedIn = AbsSection;
                            }
                            else if (s.st_shndx == -14)
                            {
                                // SHN_COMMON
                                s.DefinedIn = CommonSection;
                            }
                            else
                                s.DefinedIn = sections[s.st_shndx];
                        }

                        if(!symbols.Contains(s))
                            symbols.Add(s);
                        ((ElfSymbolSection)sect).elf_syms[cur_sym++] = s;
                    }
                }
            }

            // Interpret relocations
            for (int i = 0; i < e_shnum; i++)
            {
                SectionHeader sh = sect_headers[i];
                ISection sect = sections[i];

                switch (sh.sh_type)
                {
                    case SectionHeader.SHT_REL:
                        ReadRelocationSection(sh, sect, sections, false);
                        break;
                    case SectionHeader.SHT_RELA:
                        ReadRelocationSection(sh, sect, sections, true);
                        break;
                }
            }
        }
Esempio n. 24
0
 private void ReadElf64FileHeader(System.IO.BinaryReader r)
 {
     e_type = r.ReadUInt16();
     e_machine = r.ReadUInt16();
     r.ReadUInt32();     // e_version
     e_entry = r.ReadUInt64();
     e_phoff = r.ReadInt64();
     e_shoff = r.ReadInt64();
     e_flags = r.ReadUInt32();
     e_ehsize = r.ReadInt16();
     e_phentsize = r.ReadInt16();
     e_phnum = r.ReadInt16();
     e_shentsize = r.ReadInt16();
     e_shnum = r.ReadInt16();
     e_shstrndx = r.ReadInt16();
 }
Esempio n. 25
0
 public void Deserialize(System.IO.BinaryReader reader)
 {
     Id = reader.ReadInt64();
     ScreenName = reader.ReadString();
     Name = reader.ReadString();
     Description = reader.ReadString();
     Location = reader.ReadString();
     Url = reader.ReadString();
     IsDefaultProfileImage = reader.ReadBoolean();
     ProfileImageUri = reader.ReadUri();
     ProfileImageUriHttps = reader.ReadUri();
     ProfileBackgroundImageUri = reader.ReadUri();
     ProfileBackgroundImageUriHttps = reader.ReadUri();
     ProfileBannerUri = reader.ReadUri();
     IsProtected = reader.ReadBoolean();
     IsVerified = reader.ReadBoolean();
     IsTranslator = reader.ReadBoolean();
     IsContributorsEnabled = reader.ReadBoolean();
     IsGeoEnabled = reader.ReadBoolean();
     StatusesCount = reader.ReadInt64();
     FollowingCount = reader.ReadInt64();
     FollowersCount = reader.ReadInt64();
     FavoritesCount = reader.ReadInt64();
     ListedCount = reader.ReadInt64();
     Language = reader.ReadString();
     CreatedAt = reader.ReadDateTime();
     if (reader.ReadBoolean())
     {
         UrlEntities = reader.ReadCollection<TwitterEntity>().ToArray();
     }
     if (reader.ReadBoolean())
     {
         DescriptionEntities = reader.ReadCollection<TwitterEntity>().ToArray();
     }
 }
Esempio n. 26
0
 private SectionHeader ReadElf64SectionHeader(System.IO.BinaryReader r)
 {
     SectionHeader sh = new SectionHeader();
     sh.sh_name = r.ReadInt32();
     sh.sh_type = r.ReadUInt32();
     sh.sh_flags = r.ReadUInt64();
     sh.sh_addr = r.ReadUInt64();
     sh.sh_offset = r.ReadInt64();
     sh.sh_size = r.ReadInt64();
     sh.sh_link = r.ReadInt32();
     sh.sh_info = r.ReadInt32();
     sh.sh_addralign = r.ReadInt64();
     sh.sh_entsize = r.ReadInt64();
     return sh;
 }
Esempio n. 27
0
 public void Read(System.IO.BinaryReader reader)
 {
     Name = reader.ReadString();
     EMail = reader.ReadString();
     CrateTime = new DateTime(reader.ReadInt64());
     City = reader.ReadString();
     Country = reader.ReadString();
 }
Esempio n. 28
0
 public void Deserialize(System.IO.BinaryReader reader)
 {
     Id = reader.ReadInt64();
     ScreenName = reader.ReadString();
     IsDataLacking = reader.ReadBoolean();
     Name = reader.ReadString();
     Description = reader.ReadString();
     Location = reader.ReadString();
     Url = reader.ReadString();
     ProfileImageUri = reader.ReadUri();
     IsProtected = reader.ReadBoolean();
     IsVerified = reader.ReadBoolean();
     IsTranslator = reader.ReadBoolean();
     IsContributorsEnabled = reader.ReadBoolean();
     IsGeoEnabled = reader.ReadBoolean();
     StatusesCount = reader.ReadInt64();
     FriendsCount = reader.ReadInt64();
     FollowersCount = reader.ReadInt64();
     FavoritesCount = reader.ReadInt64();
     ListedCount = reader.ReadInt64();
     Language = reader.ReadString();
     if (!IsDataLacking)
         CreatedAt = reader.ReadDateTime();
 }
        private Boolean ReadValues(System.IO.BinaryReader r)
        {
            Int32 count;
              if(r.BaseStream.Length == 0) return false;
              count = Sql.Read7BitEncodedInt(r);

              if (count == 0) return true;

              for (Int32 i = 0; i < count; i++)
              {
            String    name  = r.ReadString();
            SqlDbType LType = (SqlDbType)r.ReadUInt16();
            Object    value = null;
            Int32 len;
            //Int32 lcid;
            //SqlCompareOptions co;

            switch (LType)
            {
              case SqlDbType.Bit      : value = new SqlBoolean(r.ReadBoolean()); break;
              case SqlDbType.TinyInt  : value = new SqlByte(r.ReadByte()); break;
              case SqlDbType.SmallInt : value = new SqlInt16((Int16)r.ReadInt16()); break;
              case SqlDbType.Int      : value = new SqlInt32((Int32)r.ReadInt32()); break;
              case SqlDbType.BigInt   : value = new SqlInt64(r.ReadInt64()); break;

              case SqlDbType.Binary   :
              case SqlDbType.VarBinary: len = r.ReadUInt16(); value = new SqlBytes(r.ReadBytes(len)); break;

              case SqlDbType.Char     :
              case SqlDbType.VarChar  : //value = new Sql.SqlAnsiString(r); break;
              case SqlDbType.NChar:
              case SqlDbType.NVarChar:
            //co = (SqlCompareOptions)r.ReadUInt16();
            //lcid = r.ReadInt32();
            //value = new SqlString(r.ReadString(), lcid, co);
            value = new SqlString(r.ReadString());
            break;

              case SqlDbType.DateTime     : value = new SqlDateTime(DateTime.FromBinary(r.ReadInt64())); break;
              case SqlDbType.SmallDateTime:
              case SqlDbType.Date         :
              case SqlDbType.DateTime2    : value = DateTime.FromBinary(r.ReadInt64()); break;
              case SqlDbType.Time         : value = TimeSpan.FromTicks(r.ReadInt64()); break;
              case SqlDbType.DateTimeOffset:
            DateTime LDateTime = DateTime.FromBinary(r.ReadInt64());
            value = new DateTimeOffset(LDateTime, TimeSpan.FromTicks(r.ReadInt64()));
            break;

              case SqlDbType.Decimal: value = new SqlDecimal(r.ReadDecimal()); break;
              case SqlDbType.Float  : value = new SqlDouble(r.ReadDouble()); break;
              // Not support SqlDbType.Image
              case SqlDbType.Money  : value = new SqlMoney(r.ReadDecimal()); break;
              case SqlDbType.Real   : value = new SqlSingle(r.ReadDouble()); break;
              case SqlDbType.SmallMoney: value = new SqlMoney(r.ReadDecimal()); break;
              // Not support SqlDbType.Structured
              // Not support SqlDbType.Text
              // Not support SqlDbType.Timestamp
              case SqlDbType.UniqueIdentifier: value = new SqlGuid(r.ReadString()); break;
              // Not support SqlDbType.Variant
              case SqlDbType.Xml:
            XmlReader rXml = XmlReader.Create(new System.IO.StringReader(r.ReadString()));
            value = new SqlXml(rXml);
            break;

              case SqlDbType.Udt:
            // TODO: Пока поддержа только TParams
            //String LTypeName = r.ReadString();
            //value = CreateUdtObject(LTypeName);
            //if (value is IBinarySerialize)
            //  (value as IBinarySerialize).Read(r);
            //else
            //  throw new Exception(String.Format("Невозможно прочитать данные типа UDT '{0}' - не поддерживается IBinarySerialize", LTypeName));
            value = new SqlUdt(r);
            break;

              default:
            throw new Exception(String.Format("Невозможно прочитать данные, тип '{0}' не поддерживается текущей версией {1}", LType.ToString(), this.GetType().Name));
              // Not support SqlDbType.NText
            }
            if (value != null) FData.Add(name, value);
              }

              return true;
        }
 /// <summary>
 /// Reads a 64-bit signed integer
 /// </summary>
 public static void Read( System.IO.BinaryReader reader, out long val )
 {
     val = reader.ReadInt64( );
 }