Page MenuHomeFeedback Tracker

Suggestion to add ToBase64String and FromBase64String methods to Serializer class.
Feedback, UrgentPublic

Description

Adding this method will simplify the process of data conversion for various purposes such as saving, network transmission and further processing. Modders will be able to use this method to quickly and easily convert data into a Base64 string without having to implement their own conversion logic.

Example of possible usage:

class Foo
{
	void SaveItem(ItemBase ib)
	{
		ScriptReadWriteContext ctx = new ScriptReadWriteContext;
		ib.OnStoreSave(ctx.GetWriteContext());
		
		string base64 = ctx.GetReadContext().ToBase64String();
		
		//send base64 via restAPI
	}
		
	void LoadItem(string type, string data)
	{
		ScriptReadWriteContext ctx = new ScriptReadWriteContext;
		ParamsReadContext read_ctx = ctx.GetReadContext();
		
		if (read_ctx.FromBase64String(data))
		{
			ItemBase ib;
			
			if ( Class.CastTo(ib, GetGame().CreateObjectEx(type, vector.Zero, ECE_PLACE_ON_SURFACE)) )
				ib.OnStoreLoad(read_ctx, int.MAX);
		}
	}
}

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General

Event Timeline

T3Z created this task.Mar 11 2024, 11:35 AM
Geez changed the task status from New to Feedback.Mar 12 2024, 10:52 AM