コード例 #1
0
        private void SetValues(NetworkPackage networkPackage, List <NetworkPackageValue> values, byte[] bytes)
        {
            foreach (NetworkPackageValue value in values)
            {
                dynamic converter = GetConverter(value.Type);

                if (converter != null)
                {
                    if (value.ByteCount <= 1)
                    {
                        networkPackage[value.Name] = ConvertToByte(converter, bytes[value.RowNumber - 1]);
                    }
                    else
                    {
                        SetByteArrayValues(value, bytes, converter);
                    }
                }
            }
        }
コード例 #2
0
        public NetworkPackage Generate(byte[] bytes)
        {
            PackageHelpers packageHelpers = new PackageHelpers();

            NetworkPackage networkPackage = NetworkPackages.FirstOrDefault();

            if (networkPackage != null)
            {
                int rowIndex = networkPackage.Type.RowNumber - 1;

                if (bytes.Count() >= rowIndex)
                {
                    byte type = bytes[rowIndex];
                    networkPackage = NetworkPackages.Where(x => x.Type.Value == type).FirstOrDefault();
                    List <NetworkPackageValue> values = packageHelpers.GetNetworkPackageValues(networkPackage);
                    SetValues(networkPackage, values, bytes);
                }
            }


            return(networkPackage);
        }
コード例 #3
0
 public void AddPackage(NetworkPackage networkPackage)
 {
     // yeni eklenen tipin özellikleri öncekiler ile farklı ise hata ver
     NetworkPackages.Add(networkPackage);
 }