Ejemplo n.º 1
0
        private void btnUploadS_Click(object sender, EventArgs e)
        {
            object loadObject;

            if (openDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filePath = openDialog.FileName;

            try
            {
                InterfaceS serializer = GetSerializer(filePath);
                if (serializer == null)
                {
                    MessageBox.Show("Десериализация не удалась!");
                    return;
                }
                //десериализуем и кидаем в лист объектов
                loadObject = serializer.Deserialize(filePath);
                ObjectList.Add(loadObject);
                Redraw();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnUploadS_Click(object sender, EventArgs e)
        {
            object loadObject;

            if (openDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filePath = openDialog.FileName;

            try
            {
                //проверяем кодировали ли мы что-то
                if (GetSerializer(filePath) == null)
                {
                    if (IsDecoded(ref filePath) == false)//если не вышло раскодировать
                    {
                        MessageBox.Show("Не загружен алгоритм для дешифрования.");
                        return;
                    }
                }

                InterfaceS serializer = GetSerializer(filePath);
                if (serializer == null)
                {
                    MessageBox.Show("Десериализация не удалась!");
                    return;
                }
                //десериализуем и кидаем в лист объектов
                loadObject = serializer.Deserialize(filePath);
                ObjectList.Add(loadObject);
                Redraw();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }