Worms4Editor/LibXom/Data/XomString.cs

71 lines
1.6 KiB
C#
Raw Permalink Normal View History

2023-01-07 09:36:13 +00:00
using LibXom.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibXom.Data
{
public class XomString : XomFileComponent
{
private string value;
public override int Id
{
get
{
2023-03-07 07:49:53 +00:00
return this.fileBelongs.calculateIdForXomStrings(this);
2023-01-07 09:36:13 +00:00
}
}
public string Value
{
get
{
2023-01-11 09:22:45 +00:00
return this.value;
2023-01-07 09:36:13 +00:00
}
2023-01-11 09:22:45 +00:00
}
public int Length
{
get
{
return Encoding.UTF8.GetByteCount(this.Value);
}
}
2023-03-03 15:59:36 +00:00
public override bool Equals(object? obj)
2023-01-12 03:50:02 +00:00
{
2023-03-07 07:49:53 +00:00
if (obj is XomString)
return this.Value.Equals((obj as XomString).Value, StringComparison.InvariantCulture);
else if(obj is string)
return this.Value.Equals((obj as string), StringComparison.InvariantCulture);
2023-03-03 15:59:36 +00:00
else
return false;
2023-01-12 03:50:02 +00:00
}
2023-03-03 15:59:36 +00:00
2023-03-07 07:49:53 +00:00
public override int GetHashCode()
{
return this.Value.GetHashCode();
}
2023-03-03 15:59:36 +00:00
/*
public void OverwriteXomString(string newValue)
{
this.value = newValue;
fileBelongs.updateStringById(this.Id, this);
}
*/
2023-01-11 09:22:45 +00:00
public override string ToString()
{
return this.Value;
2023-01-07 09:36:13 +00:00
}
2023-01-09 06:28:17 +00:00
internal XomString(XomFile fromFile, string value)
2023-01-07 09:36:13 +00:00
{
this.fileBelongs = fromFile;
this.value = value;
}
}
}