static void Main(string[] args) { /* AdvancedString advs1 = new AdvancedString("пажилой"); * advs1 += " крол"; * Console.WriteLine(advs1); * * AdvancedString advs2 = new AdvancedString("пажилой кролик"); * advs2 -= "ик"; * Console.WriteLine(advs2); * * if (advs1 == advs2) Console.WriteLine("Строки равны"); else Console.WriteLine("Строки не равны"); */ AdvancedString a = new AdvancedString(""); if (a == null) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } Console.ReadKey(); }
byte[] Compress() { AdvancedString Info = ""; foreach (PackEntry entry in Entries) { Info += Convert.ToString(entry.GetArchivePath()) + ";" + (entry.Data.Length) + "|"; } if (Info.EndsWith("|")) { Info = Info.Substring(0, Info.Length - 1); } Byte[] InfoBytes = System.Text.Encoding.Default.GetBytes(Info); int InfoBytesSize = InfoBytes.Length; Byte[] ByteInfoBytesSize = System.Text.Encoding.Default.GetBytes(InfoBytesSize.ToString()); //Fix Array Size to 4 if (ByteInfoBytesSize.Length < 4) { int d = 4 - ByteInfoBytesSize.Length; Byte[] temp = ByteInfoBytesSize; ByteInfoBytesSize = new Byte[4]; for (int i = 3; i >= 0; i += -1) { if (i - d >= 0) { ByteInfoBytesSize[i] = temp[i - d]; } else { ByteInfoBytesSize[i] = 0; } } } MemoryStream ms = new MemoryStream(); //Write InfoByteSize as Bytes[] ms.Write(ByteInfoBytesSize, 0, 4); //Write Info as Bytes[] ms.Write(InfoBytes, 0, InfoBytes.Length); //Write Files as Bytes[] foreach (PackEntry e in Entries) { ms.Write(e.Data, 0, e.Data.Length); } ms.Close(); byte[] buf = new byte[1024]; List <byte> data = new List <byte>(); while (ms.Read(buf, 0, 1024) > 0) { data.AddRange(buf); } return(data.ToArray()); }
public void Insert(AdvancedString s, InsertType t) { if (t == InsertType.Beginning) { Strings.AddFirst(s); } else if (t == InsertType.End) { Strings.AddLast(s); } }
public void Test() { var str = new AdvancedString("Site.Bl.Resource, Site.Core", "pLastName"); var firstVal = str.GetValue(); var cul = new CultureInfo("ru-RU"); Thread.CurrentThread.CurrentCulture = cul; Thread.CurrentThread.CurrentUICulture = cul; var secondVale = str.GetValue(); Assert.IsTrue(string.Compare(firstVal, secondVale) != 0); }
public AdvancedString ToAdvancedString() { AdvancedString a = ""; foreach (AdvancedString s in this.Strings) { foreach (char c in s) { a.Append(c); } } return(a); }
protected AdvancedString(AdvancedString a, string b) { str = new char[a.Length + b.Length]; for (int i = 0; i < str.Length; i++) { if (i < a.Length) { str[i] = a.str[i]; } else { str[i] = b[i - a.Length]; } } Length = str.Length; }
public static AdvancedString operator -(AdvancedString a, string b) { AdvancedString nstr = new AdvancedString(""); bool changed = false; for (int i = 0; i < a.str.Length; i++) { bool ext = false; int start = i, stop = i + b.Length; for (int j = 0; j < b.Length; j++) { if (a.str[i + j] != b[j]) { ext = true; char c1 = a.str[i + j]; char c2 = b[j]; break; } } if (ext) { continue; } changed = true; nstr.str = new char[a.Length - b.Length]; int p = 0; for (int j = 0; j < a.Length; j++) { if (j < start || j > stop) { nstr.str[p] = a.str[j]; p++; } } nstr.Length = nstr.str.Length; break; } if (!changed) { nstr.str = new char[a.Length]; for (int i = 0; i < a.Length; i++) { nstr.str[i] = a.str[i]; } nstr.Length = nstr.str.Length; } return(nstr); }
public ReadableEnumAttribute(AdvancedString v) { this.Value = v; }
public ReadableEnumAttribute(string v) { this.Value = v; }
/// <summary> /// Initializes a new instance of the <see cref="DisplayNameExAttribute"/> class. /// </summary> /// <param name="resourceType">Type of the resource.</param> /// <param name="resourceName">Name of the resource.</param> public DisplayNameExAttribute(string resourceType, string resourceName) { _displayName = new AdvancedString(resourceType, resourceName); }
/// <summary> /// Adds the string + a newline to the collected string /// </summary> /// <param name="s"></param> public void AppendLine(AdvancedString s) { this.Insert(s + Environment.NewLine, InsertType.End); }
/// <summary> /// Adds the specified string to the end of this builder=. /// </summary> /// <param name="str">The string to suffix.</param> public void Append(AdvancedString str) { this.Insert(str, InsertType.End); }
/// <summary> /// Initializes a new instance of the <see cref="DisplayNameExAttribute"/> class. /// </summary> /// <param name="displayname">The displayname.</param> public DisplayNameExAttribute(AdvancedString displayname) { _displayName = displayname; }
public void Insert(AdvancedString s, InsertType t) { if (t == InsertType.Beginning) Strings.AddFirst(s); else if (t == InsertType.End) Strings.AddLast(s); }
/// <summary> /// Initializes a new instance of the <see cref="DisplayNameExAttribute"/> class. /// </summary> /// <param name="displayname">The displayname.</param> public DisplayNameExAttribute(string displayname) { _displayName = new AdvancedString(displayname); }