コード例 #1
0
 public static IdentificationMessage ReadFromBms1Stream(IBms1Reader reader)
 {
     return reader.ReadBlock(
         () => new IdentificationMessage()
         { 
             InterfaceName = reader.ReadString(),
             InterfaceVersion = reader.ReadInt16(),
             ApplicationName = reader.ReadString(),
             ApplicationVersion = VersionBase.ReadFromBms1Stream(reader),
             ApplicationInstance = reader.ReadString(),
         });
 }
コード例 #2
0
 public static VersionBase ReadFromBms1Stream(IBms1Reader reader)
 {
     var type = reader.Internal.BlockTypeId;
     if (type == VersionDotNet.Bms1BlockTypeId)
     {
         return VersionDotNet.CreateFromBms1Stream(reader);
     }
     else if (type == VersionPLC.Bms1BlockTypeId)
     {
         return VersionPLC.CreateFromBms1Stream(reader);
     }
     else
     {   // TODO: test it, it reads another block-frame ?
         return reader.ReadBlock<VersionPLC>(null); // skip when null or unknown block type
     }
 }
コード例 #3
0
 /// <summary>
 /// Here we demonstrate how to stream a member class of a closed library.
 /// The extension method reads System.Version from a BMS1 stream.
 /// </summary>
 public static Version ReadFromBms1Stream(this Version version, IBms1Reader reader)
 {
     return reader.ReadBlock(
         () => new Version(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()));
 }
コード例 #4
0
        public string AdditionaInfo = "None"; // not transferred before V.2

        internal static VersionDotNet CreateFromBms1Stream(IBms1Reader reader)
        {
            return reader.ReadBlock(
                () => new VersionDotNet()
                {
                    Version = MessageExtensions.ReadFromBms1Stream(null, reader),
                    // Intentionally, we do not read AdditionalInfo. This simulates a new sender and an older receiver;
                });
        }
コード例 #5
0
 public static IdleMessage ReadFromBms1Stream(IBms1Reader reader)
 {
     // ReadBlock calls us back, in case the deserialization method is not null.
     return reader.ReadBlock<IdleMessage>(() => new IdleMessage());
 }
コード例 #6
0
        public string AdditionaInfo = "None"; // not transferred before V.2

        internal static VersionPLC CreateFromBms1Stream(IBms1Reader reader)
        {
            return reader.ReadBlock(()=>
                {
                    var dto = new VersionPLC();
                    dto.Version = reader.ReadString();
                    dto.CpuType = reader.ReadEnum<CpuType>();
                    if (!reader.Internal.EndOfBlock)
                    {
                        // starting with V.2, more data is transferred. When sender has V.1, AdditionaInfo is "None".
                        dto.AdditionaInfo = reader.ReadString();
                    }
                    return dto;
                });
        }