public override IElectionContext CreateElectionContext(IByteArray compressedContext) { GzipCompression compressor = new GzipCompression(); IByteArray decompressedContext = compressor.Decompress(compressedContext); IDataRehydrator electionContextRehydrator = DataSerializationFactory.CreateRehydrator(decompressedContext); var version = electionContextRehydrator.RehydrateRewind <ComponentVersion <ElectionContextType> >(); IElectionContext context = null; if (version.Type == ElectionContextTypes.Instance.Active) { if (version == (1, 0)) { context = new NeuraliumActiveElectionContext(); } } if (version.Type == ElectionContextTypes.Instance.Passive) { if (version == (1, 0)) { context = new NeuraliumPassiveElectionContext(); } } if (context == null) { throw new ApplicationException("Unrecognized election context version."); } context.Rehydrate(electionContextRehydrator, this); decompressedContext.Return(); return(context); }
public ElectionRepository(IElectionContext context) { Context = context; }