public void Serialize(IBinarySerializer s) { Path = s.SerializeObject <UbiArtPath>(Path, name: nameof(Path)); IsFree = s.SerializeBool <uint>(IsFree, name: nameof(IsFree)); IndexType = s.Serialize <Index>(IndexType, name: nameof(IndexType)); VisualType = s.Serialize <Prisoner>(VisualType, name: nameof(VisualType)); }
private void PersistOffset(PullRequest pullRequest) { try { var consumedQueueOffset = pullRequest.ProcessQueue.GetConsumedQueueOffset(); if (consumedQueueOffset >= 0) { if (!pullRequest.ProcessQueue.TryUpdatePreviousConsumedQueueOffset(consumedQueueOffset)) { return; } var request = new UpdateQueueOffsetRequest(GroupName, pullRequest.MessageQueue, consumedQueueOffset); var remotingRequest = new RemotingRequest((int)RequestCode.UpdateQueueOffsetRequest, _binarySerializer.Serialize(request)); _remotingClient.InvokeOneway(remotingRequest); _logger.DebugFormat("Sent queue consume offset to broker. group:{0}, consumerId:{1}, topic:{2}, queueId:{3}, offset:{4}", GroupName, Id, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId, consumedQueueOffset); } } catch (Exception ex) { if (_isBrokerServerConnected) { _logger.Error(string.Format("PersistOffset has exception, consumerId:{0}, group:{1}, topic:{2}, queueId:{3}", Id, GroupName, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId), ex); } } }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { // 3DS files can not be serialized separately if (IPKVersion == 4) { throw new BinarySerializableException("File data for IPK 4 can not be serialized separately"); } // Read common values OffsetCount = s.Serialize <uint>(OffsetCount, name: nameof(OffsetCount)); Size = s.Serialize <uint>(Size, name: nameof(Size)); CompressedSize = s.Serialize <uint>(CompressedSize, name: nameof(CompressedSize)); TStamp = s.Serialize <ulong>(TStamp, name: nameof(TStamp)); Offsets = s.SerializeArray <ulong>(Offsets, (int)OffsetCount, name: nameof(Offsets)); // For any game after Origins the path is in the standard format if (IPKVersion >= 5) { Path = s.SerializeObject <UbiArtPath>(Path, name: nameof(Path)); } else { Path = new UbiArtPath(s.SerializeLengthPrefixedString(Path?.FullPath, name: nameof(Path))); } }
/// <summary> /// Serialize logic /// </summary> /// <param name="serializer">Serializer</param> /// <param name="writer">Writer</param> /// <param name="settings">Settings</param> /// <returns>How many bytes have been written</returns> public int Serialize(IBinarySerializer serializer, BinaryWriter writer, BinarySerializerSettings settings = null) { // Write type and version var ret = 2; writer.Write((byte)Type); writer.Write(Version); // Serialize exclusive data ret += SerializeExclusiveData(serializer, writer, settings); // Serialize shared content ret += serializer.Serialize(Attributes, writer, settings); ret += serializer.Serialize(Inputs, writer, settings); ret += serializer.Serialize(Outputs, writer, settings); // Serialize sign if (settings?.Filter?.Invoke(nameof(Witness)) != false) { ret += serializer.Serialize(Witness, writer, settings); } return(ret); }
public void Serialize(IBinarySerializer s) { LastSpawnDay = s.Serialize <uint>(LastSpawnDay, name: nameof(LastSpawnDay)); MaxRewardNb = s.Serialize <uint>(MaxRewardNb, name: nameof(MaxRewardNb)); RemainingRewards = s.Serialize <uint>(RemainingRewards, name: nameof(RemainingRewards)); RewardType = s.Serialize <uint>(RewardType, name: nameof(RewardType)); }
private void PersistOffset(PullRequest pullRequest) { try { var consumedMinQueueOffset = pullRequest.ProcessQueue.GetConsumedMinQueueOffset(); if (consumedMinQueueOffset >= 0) { if (!pullRequest.ProcessQueue.TryUpdatePreviousConsumedMinQueueOffset(consumedMinQueueOffset)) { return; } if (Setting.MessageModel == MessageModel.BroadCasting) { _localOffsetStore.PersistQueueOffset(GroupName, pullRequest.MessageQueue, consumedMinQueueOffset); } else if (Setting.MessageModel == MessageModel.Clustering) { var request = new UpdateQueueOffsetRequest(GroupName, pullRequest.MessageQueue, consumedMinQueueOffset); var remotingRequest = new RemotingRequest((int)RequestCode.UpdateQueueOffsetRequest, _binarySerializer.Serialize(request)); _remotingClient.InvokeOneway(remotingRequest, 10000); _logger.DebugFormat("Sent new queue offset to broker. group:{0}, consumerId:{1}, topic:{2}, queueId:{3}, offset:{4}", GroupName, Id, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId, consumedMinQueueOffset); } } } catch (Exception ex) { _logger.Error(string.Format("PersistOffset has exception, consumerId:{0}, group:{1}, topic:{2}, queueId:{3}", Id, GroupName, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId), ex); } }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { Lums = s.Serialize <byte>(Lums, name: nameof(Lums)); TeensiesFreed = s.Serialize <byte>(TeensiesFreed, name: nameof(TeensiesFreed)); Unknown1 = s.Serialize <byte>(Unknown1, name: nameof(Unknown1)); Unknown2 = s.SerializeArray <byte>(Unknown2, 11, name: nameof(Unknown2)); }
public void Serialize(IBinarySerializer s) { PickedUpLums = s.SerializeUbiArtObjectArray <PackedObjectPath>(PickedUpLums, name: nameof(PickedUpLums)); TakenTooth = s.SerializeUbiArtObjectArray <PackedObjectPath>(TakenTooth, name: nameof(TakenTooth)); AlreadySeenCutScenes = s.SerializeUbiArtObjectArray <PackedObjectPath>(AlreadySeenCutScenes, name: nameof(AlreadySeenCutScenes)); FoundRelicMask = s.Serialize <uint>(FoundRelicMask, name: nameof(FoundRelicMask)); FoundCageMask = s.Serialize <uint>(FoundCageMask, name: nameof(FoundCageMask)); }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { PlayersLumCount = s.SerializeUbiArtArray <uint>(PlayersLumCount, name: nameof(PlayersLumCount)); TreasuresLumCount = s.SerializeUbiArtArray <uint>(TreasuresLumCount, name: nameof(TreasuresLumCount)); LocalLumsCount = s.Serialize <int>(LocalLumsCount, name: nameof(LocalLumsCount)); PendingLumsCount = s.Serialize <int>(PendingLumsCount, name: nameof(PendingLumsCount)); TempLumsCount = s.Serialize <int>(TempLumsCount, name: nameof(TempLumsCount)); }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { DirectoryIndex = s.Serialize <int>(DirectoryIndex, name: nameof(DirectoryIndex)); FileName = s.SerializeOpenSpaceEncryptedString(FileName, XORKey, name: nameof(FileName)); FileXORKey = s.SerializeArray <byte>(FileXORKey, 4, name: nameof(FileXORKey)); Checksum = s.Serialize <uint>(Checksum, name: nameof(Checksum)); Pointer = s.Serialize <uint>(Pointer, name: nameof(Pointer)); Size = s.Serialize <uint>(Size, name: nameof(Size)); }
public async Task AddBlockHeader(BlockHeader blockHeader) { var blockHeaderBytes = _binarySerializer.Serialize(blockHeader); await _redisDbContext.Set(blockHeader.Hash.BuildDataBlockKey(), blockHeaderBytes); await _redisDbContext.AddToIndex(RedisIndex.BlockTimestamp, blockHeader.Hash, blockHeader.Timestamp); await _redisDbContext.AddToIndex(RedisIndex.BlockHeight, blockHeader.Hash, blockHeader.Index); }
public async Task StoreDownstreamIdTokenResponseAsync(string id, DownstreamAuthorizeResponse response) { var key = OIDCPipleLineStoreUtils.GenerateDownstreamIdTokenResponseKey(id); var data = _binarySerializer.Serialize(response); DistributedCacheEntryOptions options = new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(_options.ExpirationMinutes) }; await _cache.SetAsync(key, data, options); }
public void Serialize(IBinarySerializer s) { HasMet = s.SerializeBool <uint>(HasMet, name: nameof(HasMet)); UpdateRequested = s.SerializeBool <uint>(UpdateRequested, name: nameof(UpdateRequested)); HasWonPetCup = s.SerializeBool <uint>(HasWonPetCup, name: nameof(HasWonPetCup)); TeensyLocksOpened = s.Serialize <uint>(TeensyLocksOpened, name: nameof(TeensyLocksOpened)); ChallengeLocksOpened = s.Serialize <uint>(ChallengeLocksOpened, name: nameof(ChallengeLocksOpened)); TutoCount = s.Serialize <uint>(TutoCount, name: nameof(TutoCount)); DisplayQuoteStates = s.SerializeUbiArtArray <bool>(DisplayQuoteStates, name: nameof(DisplayQuoteStates)); }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { Header_0 = s.SerializeArray <byte>(Header_0, 35, name: nameof(Header_0)); CompressionType = s.Serialize <TextureCompressionType>(CompressionType, name: nameof(CompressionType)); Dimensions = s.Serialize <int>(Dimensions, name: nameof(Dimensions)); Width = BitHelpers.ExtractBits(Dimensions, 13, 0) + 1; Height = BitHelpers.ExtractBits(Dimensions, 13, 13) + 1; Header_1 = s.SerializeArray <byte>(Header_1, 12, name: nameof(Header_1)); ImgData = s.SerializeArray <byte>(ImgData, (int)(s.Stream.Length - s.Stream.Position), name: nameof(ImgData)); }
public void CreateTopic(string topic, int initialQueueCount) { var requestData = _binarySerializer.Serialize(new CreateTopicRequest(topic, initialQueueCount)); var remotingRequest = new RemotingRequest((int)RequestCode.CreateTopic, requestData); var remotingResponse = _remotingClient.InvokeSync(remotingRequest, 30000); if (remotingResponse.Code != (int)ResponseCode.Success) { throw new Exception(string.Format("CreateTopic failed, errorMessage: {0}", Encoding.UTF8.GetString(remotingResponse.Body))); } }
public void Serialize(IBinarySerializer s) { ISDs = s.SerializeUbiArtObjectArray <UbiArtObjKeyObjValuePair <UbiArtStringID, UbiArtGeneric <Ray_PersistentGameData_ISD> > >(ISDs, name: nameof(ISDs)); CageMapPassedDoors = s.SerializeUbiArtObjectArray <PackedObjectPath>(CageMapPassedDoors, name: nameof(CageMapPassedDoors)); WonChallenges = s.Serialize <uint>(WonChallenges, name: nameof(WonChallenges)); LevelState = s.Serialize <SPOT_STATE>(LevelState, name: nameof(LevelState)); BestTimeAttack = s.Serialize <uint>(BestTimeAttack, name: nameof(BestTimeAttack)); BestLumAttack = s.Serialize <uint>(BestLumAttack, name: nameof(BestLumAttack)); HasWarning = s.SerializeBool <uint>(HasWarning, name: nameof(HasWarning)); IsSkipped = s.SerializeBool <uint>(IsSkipped, name: nameof(IsSkipped)); Trackingdata = s.SerializeObject <Ray_PersistentGameData_LevelTracking>(Trackingdata, name: nameof(Ray_PersistentGameData_LevelTracking)); }
/// <summary> /// Handles the serialization using the specified serializer /// </summary> /// <param name="s">The serializer</param> public void Serialize(IBinarySerializer s) { LivesCount = s.Serialize <byte>(LivesCount, name: nameof(LivesCount)); Unk_01 = s.Serialize <byte>(Unk_01, name: nameof(Unk_01)); LivesDigit0 = s.Serialize <byte>(LivesDigit0, name: nameof(LivesDigit0)); LivesDigit1 = s.Serialize <byte>(LivesDigit1, name: nameof(LivesDigit1)); Unk_04 = s.Serialize <byte>(Unk_04, name: nameof(Unk_04)); Unk_05 = s.Serialize <byte>(Unk_05, name: nameof(Unk_05)); TingsCount = s.Serialize <byte>(TingsCount, name: nameof(TingsCount)); TingsDigit0 = s.Serialize <byte>(TingsDigit0, name: nameof(TingsDigit0)); TingsDigit1 = s.Serialize <byte>(TingsDigit1, name: nameof(TingsDigit1)); MaxHealth = s.Serialize <byte>(MaxHealth, name: nameof(MaxHealth)); }
public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request) { var pullMessageRequest = _binarySerializer.Deserialize <PullMessageRequest>(request.Body); if (pullMessageRequest.QueueOffset < 0) { var lastConsumedQueueOffset = _offsetManager.GetQueueOffset( pullMessageRequest.MessageQueue.Topic, pullMessageRequest.MessageQueue.QueueId, pullMessageRequest.ConsumerGroup); var queueCurrentOffset = _messageService.GetQueueCurrentOffset( pullMessageRequest.MessageQueue.Topic, pullMessageRequest.MessageQueue.QueueId); var nextQueueOffset = lastConsumedQueueOffset + 1; if (lastConsumedQueueOffset == -1) { nextQueueOffset = queueCurrentOffset + 1; } var response = new PullMessageResponse(new QueueMessage[0], nextQueueOffset); var responseData = _binarySerializer.Serialize(response); return(new RemotingResponse((int)PullStatus.NextOffsetReset, request.Sequence, responseData)); } var messages = _messageService.GetMessages( pullMessageRequest.MessageQueue.Topic, pullMessageRequest.MessageQueue.QueueId, pullMessageRequest.QueueOffset, pullMessageRequest.PullMessageBatchSize); if (messages.Count() > 0) { var pullMessageResponse = new PullMessageResponse(messages); var responseData = _binarySerializer.Serialize(pullMessageResponse); return(new RemotingResponse((int)PullStatus.Found, request.Sequence, responseData)); } else { var pullRequest = new PullRequest( request.Sequence, pullMessageRequest, context, DateTime.Now, SuspendPullRequestMilliseconds, ExecutePullRequest, ExecutePullRequest, ExecuteReplacedPullRequest); _brokerController.SuspendedPullRequestManager.SuspendPullRequest(pullRequest); return(null); } }
public async Task SetAsync <T>(string key, T value, TimeSpan?timeSpan = null) { try { await Semaphore.WaitAsync(); await _distributedCache.SetAsync(key, _binarySerializer.Serialize(value), new DistributedCacheEntryOptions()); } finally { Semaphore.Release(); } }
protected override int SerializeExclusiveData(IBinarySerializer serializer, BinaryWriter writer, BinarySerializerSettings settings = null) { var l = 1; writer.Write((byte)AssetType); l += writer.WriteVarString(Name); writer.Write(Amount.Value); l += Fixed8.Size; writer.Write(Precision); l++; l += serializer.Serialize(Owner, writer, settings); l += serializer.Serialize(Admin, writer, settings); return(l); }
public void Serialize(object obj, BinaryDataWriter writer) { BinaryDataWriter childWriter = writer.TryWriteNode(sizeof(byte)); _serializer.Serialize(_getter(obj), childWriter); if (childWriter.Length <= 0) { return; } WriteKey(_index, writer); childWriter.PushNode(); }
public void Serialize(IBinarySerializer s) { Levels = s.SerializeUbiArtObjectArray <UbiArtObjKeyObjValuePair <UbiArtStringID, UbiArtGeneric <PersistentGameData_Level> > >(Levels, name: nameof(Levels)); Rewards = s.SerializeObject <SaveSession>(Rewards, name: nameof(Rewards)); Score = s.SerializeObject <Ray_PersistentGameData_Score>(Score, name: nameof(Score)); WorldMapData = s.SerializeObject <Ray_PersistentGameData_WorldMap>(WorldMapData, name: nameof(WorldMapData)); TrackingData = s.SerializeObject <Ray_PersistentGameData_UniverseTracking>(TrackingData, name: nameof(TrackingData)); DiscoveredCageMapList = s.SerializeUbiArtObjectArray <AbsoluteObjectPath>(DiscoveredCageMapList, name: nameof(DiscoveredCageMapList)); TeethReturned = s.Serialize <uint>(TeethReturned, name: nameof(TeethReturned)); UsedPlayerIDInfo = s.SerializeObject <UbiArtStringID>(UsedPlayerIDInfo, name: nameof(UsedPlayerIDInfo)); SprintTutorialDisabled = s.Serialize <int>(SprintTutorialDisabled, name: nameof(SprintTutorialDisabled)); CostumeLastPrice = s.Serialize <uint>(CostumeLastPrice, name: nameof(CostumeLastPrice)); CostumesUsed = s.SerializeUbiArtObjectArray <UbiArtStringID>(CostumesUsed, name: nameof(CostumesUsed)); }
public void Serialize(Stream stream, object value, IBinarySerializer serializer, object[] parameters) { var stringValue = (string)value; if (stringValue == null) { serializer.Serialize(0, stream); return; } var compactLength = Encoding.UTF8.GetByteCount(stringValue).ToCompactBytes(); serializer.Serialize(compactLength, stream); serializer.Serialize(Encoding.UTF8.GetBytes(stringValue), stream); }
public void Serialize(Stream stream, object value, IBinarySerializer serializer, object[] parameters) { var stringValue = (string)value; if (stringValue == null) { serializer.Serialize(0, stream); return; } var compactLength = Scale.EncodeCompactInteger(stringValue.Length).Bytes; serializer.Serialize(compactLength, stream); serializer.Serialize(Encoding.Unicode.GetBytes(stringValue), stream); }
private void Serialize(IsolatedStorageFile file, string fileName, IBinarySerializer bin, LicenceData data) { using (var stream = file.CreateFile(fileName)) { var local = new LocalData { Temp = new byte[new Random().Next(677, 2322)], License = bin.Serialize(data) }; new Random().NextBytes(local.Temp); var bytes = bin.Serialize(local); stream.Write(bytes, 0, bytes.Length); } }
public void AddBlockHeader(BlockHeader blockHeader) { //Convert to bytes var blockHeaderBytes = _serializer.Serialize(blockHeader); //Write the redis database with the binary bytes _redis.Database.Set(DataEntryPrefix.DataBlock, blockHeader.Hash.ToString(), blockHeaderBytes); //Add secondary indexes to find block hash by timestamp or height //Add to timestamp / blockhash index _redis.Database.AddToIndex(RedisIndex.BlockTimestamp, blockHeader.Timestamp, blockHeader.Hash.ToString()); //Add to heignt / blockhash index _redis.Database.AddToIndex(RedisIndex.BlockHeight, blockHeader.Index, blockHeader.Hash.ToString()); }
public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest) { var request = _binarySerializer.Deserialize <QueryConsumerInfoRequest>(remotingRequest.Body); var consumerInfoList = new List <ConsumerInfo>(); if (!string.IsNullOrEmpty(request.GroupName)) { var consumerGroups = _consumerManager.QueryConsumerGroup(request.GroupName); foreach (var consumerGroup in consumerGroups) { foreach (var topicConsumeInfo in GetConsumerInfoForGroup(consumerGroup, request.Topic)) { consumerInfoList.Add(topicConsumeInfo); } } } else { var consumerGroups = _consumerManager.GetAllConsumerGroups(); foreach (var consumerGroup in consumerGroups) { foreach (var topicConsumeInfo in GetConsumerInfoForGroup(consumerGroup, request.Topic)) { consumerInfoList.Add(topicConsumeInfo); } } } var data = _binarySerializer.Serialize(consumerInfoList); return(new RemotingResponse((int)ResponseCode.Success, remotingRequest.Sequence, data)); }
public Task SaveVectorAsync(CancellationToken token = default(CancellationToken)) { using (var dialog = new FolderBrowserDialog() { SelectedPath = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName }) { DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { var directoryPath = dialog.SelectedPath; var fileName = "vector_" + DateTime.Now.ToString("yyyy-dd-M-HH-mm-ss"); var fileExtension = VecExtension; var filePath = Path.Combine(directoryPath, fileName + "." + fileExtension); var canvasState = _canvasHistoryManager.GetSnapshot(); var canvasStateBytes = _binarySerializer.Serialize(canvasState); File.WriteAllBytes(filePath, canvasStateBytes); } return(Task.FromResult(0)); //Task.CompletedTask; } }
public SerializedValue Serialize(Type type, object data) { if (type == null) { throw new ArgumentNullException("type"); } if (type.AssemblyQualifiedName == null) { throw new ArgumentException("The type has no assembly qualified name.", "type"); } var format = _formatSelector.GetFormat(type, data); switch (format) { case SerializationFormat.Null: return(new SerializedValue(type.AssemblyQualifiedName)); case SerializationFormat.BinaryFormatter: var binaryData = _binarySerializer.Serialize(data); return(new SerializedValue(type.AssemblyQualifiedName, binaryData)); case SerializationFormat.UnityJson: var jsonData = _unityJsonSerializer.Serialize(data); return(new SerializedValue(type.AssemblyQualifiedName, jsonData)); default: throw new NotSupportedException(string.Format( "The serialization format '{0}' is not supported.", format)); } }
public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest) { var request = _binarySerializer.Deserialize <QueryTopicQueueInfoRequest>(remotingRequest.Body); var topicQueueInfoList = new List <TopicQueueInfo>(); var topicList = !string.IsNullOrEmpty(request.Topic) ? new List <string> { request.Topic } : _queueService.GetAllTopics().ToList(); foreach (var topic in topicList) { var queues = _queueService.QueryQueues(topic).ToList(); foreach (var queue in queues) { var topicQueueInfo = new TopicQueueInfo(); topicQueueInfo.Topic = queue.Topic; topicQueueInfo.QueueId = queue.QueueId; topicQueueInfo.QueueCurrentOffset = queue.CurrentOffset; topicQueueInfo.QueueMinOffset = queue.GetMinQueueOffset(); topicQueueInfo.QueueMessageCount = queue.GetMessageRealCount(); topicQueueInfo.QueueMaxConsumedOffset = _offsetManager.GetMinOffset(queue.Topic, queue.QueueId); topicQueueInfo.Status = queue.Status; topicQueueInfoList.Add(topicQueueInfo); } } var data = _binarySerializer.Serialize(topicQueueInfoList); return(new RemotingResponse((int)ResponseCode.Success, remotingRequest.Sequence, data)); }