unsafe static void Main()
 {
     field          = new VersionedData();
     field.Major    = 2;
     field.Minor    = 1;
     field.Data[10] = 20;
 }
        private void buttonOpenFile_Click(object sender, EventArgs e)
        {
            var openFile = new OpenFileDialog
            {
                ShowReadOnly       = true,
                AddExtension       = true,
                AutoUpgradeEnabled = true,
                Filter             = @"servers.json|servers.json"
            };

            if (openFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var f = File.ReadAllText(openFile.FileName);

            ;
            var cfg = VersionedData.Load(f);

            Text = $"Serverrs.json Editor [Loaded, Api ver. {cfg.Api}]";
            switch (cfg.Api)
            {
            case VersionedServers.ApiVersion:
            {
                var versionedServers = VersionedServers.Load(f);
                ShowEditor_1(versionedServers);
                break;
            }
            }
        }
Ejemplo n.º 3
0
        unsafe static void Main()
        {
            var versioned = new VersionedData();

            versioned.Major    = 2;
            versioned.Minor    = 1;
            versioned.Data[10] = 20;
        }
 public byte[] EncodeSharedAuth(SharedAuthSecret secret)
 {
     try {
         SharedAuthSecretImpl sharedAuth = (SharedAuthSecretImpl)secret;
         int           i             = 0;
         VersionedData?actualVersion = null;
         VersionedData?legacyVersion = null;
         if (!sharedAuth.Legacy)
         {
             // se não é legacy, tem a versão atual. Pode ter a versão legacy ou não.
             ExportedSharedAuth exportedAuth   = new ExportedSharedAuth(sharedAuth.BusId, sharedAuth.Attempt, sharedAuth.Secret);
             TypeCode           exportedAuthTC = _orb.create_tc_for_type(typeof(ExportedSharedAuth));
             Any    any     = new Any(exportedAuth, exportedAuthTC);
             byte[] encoded = _codec.encode_value(any);
             actualVersion = new VersionedData(ExportVersion.ConstVal, encoded);
             i++;
         }
         if (sharedAuth.LegacyAttempt != null)
         {
             core.v2_0.data_export.ExportedSharedAuth legacyAuth =
                 new core.v2_0.data_export.ExportedSharedAuth(sharedAuth.BusId,
                                                              sharedAuth.LegacyAttempt, sharedAuth.Secret);
             TypeCode legacyExportedAuthTC = _orb.create_tc_for_type(typeof(core.v2_0.data_export.ExportedSharedAuth));
             Any      any           = new Any(legacyAuth, legacyExportedAuthTC);
             byte[]   legacyEncoded = _codec.encode_value(any);
             legacyVersion = new VersionedData(CurrentVersion.ConstVal, legacyEncoded);
             i++;
         }
         VersionedData[] versions = new VersionedData[i];
         // A ordem das versões exportadas IMPORTA. A 2.1 deve vir antes da 2.0.
         if (legacyVersion != null)
         {
             versions[--i] = legacyVersion.Value;
         }
         if (actualVersion != null)
         {
             versions[--i] = actualVersion.Value;
         }
         return(EncodeExportedVersions(versions, _magicTagSharedAuth));
     }
     catch (InvalidTypeForEncoding e) {
         const string message =
             "Falha inesperada ao codificar uma autenticação compartilhada para exportação.";
         Logger.Error(message, e);
         throw new OpenBusInternalException(message, e);
     }
 }
 public byte[] EncodeChain(CallerChain chain)
 {
     try {
         CallerChainImpl chainImpl     = (CallerChainImpl)chain;
         int             i             = 0;
         VersionedData?  actualVersion = null;
         VersionedData?  legacyVersion = null;
         if (!chainImpl.Legacy)
         {
             // se não é legacy, tem a versão atual. Pode ter a versão legacy ou não.
             TypeCode signedChainTC = _orb.create_tc_for_type(typeof(SignedData));
             Any      any           = new Any(chainImpl.Signed.Chain, signedChainTC);
             byte[]   encoded       = _codec.encode_value(any);
             actualVersion = new VersionedData(ExportVersion.ConstVal, encoded);
             i++;
         }
         if (chainImpl.Signed.LegacyChain.encoded != null)
         {
             ExportedCallChain exported = new ExportedCallChain(chainImpl.BusId,
                                                                chainImpl.Signed.LegacyChain);
             TypeCode exportedChainTC = _orb.create_tc_for_type(typeof(ExportedCallChain));
             Any      any             = new Any(exported, exportedChainTC);
             byte[]   legacyEncoded   = _codec.encode_value(any);
             legacyVersion = new VersionedData(CurrentVersion.ConstVal, legacyEncoded);
             i++;
         }
         VersionedData[] versions = new VersionedData[i];
         // A ordem das versões exportadas IMPORTA. A 2.1 deve vir antes da 2.0.
         if (legacyVersion != null)
         {
             versions[--i] = legacyVersion.Value;
         }
         if (actualVersion != null)
         {
             versions[--i] = actualVersion.Value;
         }
         return(EncodeExportedVersions(versions, _magicTagCallChain));
     }
     catch (InvalidTypeForEncoding e) {
         const string message =
             "Falha inesperada ao codificar uma cadeia para exportação.";
         Logger.Error(message, e);
         throw new OpenBusInternalException(message, e);
     }
 }