Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class StringExtensions
- {
- public static string GetRightName(this string s)
- {
- switch (s)
- {
- case "object":
- return "@object";
- case "base":
- return "@base";
- case "params":
- return "@params";
- default:
- return s;
- }
- }
- public static string Uppercase(this string s) => char.ToUpper(s[0]) + s.Substring(1);
- public static string GetRightType(this string s)
- {
- switch (s)
- {
- case "uint16":
- return "ushort";
- case "uint32":
- return "uint";
- case "int16":
- return "short";
- case "float32":
- return "float";
- case "float64":
- return "double";
- case "int8":
- return "sbyte";
- case "uint8":
- return "byte";
- case "int32":
- return "int";
- case "int64":
- return "long";
- default:
- return s;
- }
- }
- public static string GetRightCastWriteMethod(string writeMethod)
- {
- switch (writeMethod)
- {
- case "writeVarInt":
- return "int";
- case "writeVarShort":
- return "short";
- default:
- return "short";
- }
- }
- public static string GetRigthCast(string type, string writeMethod)
- {
- switch (type)
- {
- case "uint32":
- switch (writeMethod)
- {
- case "writeVarInt":
- return "(int)";
- case "readVarInt":
- return "(uint)";
- case "writeInt":
- return "(int)";
- case "readInt":
- return "(uint)";
- default:
- return "";
- }
- case "int8":
- switch (writeMethod)
- {
- case "writeByte":
- return "(byte)";
- case "readByte":
- return "(sbyte)";
- default:
- return "";
- }
- case "uint16":
- switch (writeMethod)
- {
- case "writeVarShort":
- return "(short)";
- case "readVarShort":
- return "(ushort)";
- case "readShort":
- return "(ushort)";
- case "writeShort":
- return "(short)";
- default:
- return "";
- }
- default:
- return "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement