using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using ZionVault.Util;

namespace ZionRobot.Models.Search
{
	// Token: 0x0200002D RID: 45
	public class Element : IDisposable
	{
		// Token: 0x1700007B RID: 123
		// (get) Token: 0x06000142 RID: 322 RVA: 0x00007FA8 File Offset: 0x000061A8
		// (set) Token: 0x06000143 RID: 323 RVA: 0x00007FB0 File Offset: 0x000061B0
		public string Name { get; set; }

		// Token: 0x1700007C RID: 124
		// (get) Token: 0x06000144 RID: 324 RVA: 0x00007FB9 File Offset: 0x000061B9
		// (set) Token: 0x06000145 RID: 325 RVA: 0x00007FC1 File Offset: 0x000061C1
		public string Where { get; set; }

		// Token: 0x1700007D RID: 125
		// (get) Token: 0x06000146 RID: 326 RVA: 0x00007FCA File Offset: 0x000061CA
		// (set) Token: 0x06000147 RID: 327 RVA: 0x00007FD2 File Offset: 0x000061D2
		public string GoTo { get; set; }

		// Token: 0x1700007E RID: 126
		// (get) Token: 0x06000148 RID: 328 RVA: 0x00007FDB File Offset: 0x000061DB
		// (set) Token: 0x06000149 RID: 329 RVA: 0x00007FE3 File Offset: 0x000061E3
		public string Attribute { get; set; }

		// Token: 0x1700007F RID: 127
		// (get) Token: 0x0600014A RID: 330 RVA: 0x00007FEC File Offset: 0x000061EC
		// (set) Token: 0x0600014B RID: 331 RVA: 0x00007FF4 File Offset: 0x000061F4
		public List<string> Replaces { get; set; }

		// Token: 0x17000080 RID: 128
		// (get) Token: 0x0600014C RID: 332 RVA: 0x00007FFD File Offset: 0x000061FD
		// (set) Token: 0x0600014D RID: 333 RVA: 0x00008005 File Offset: 0x00006205
		public List<string> RemoveChars { get; set; }

		// Token: 0x17000081 RID: 129
		// (get) Token: 0x0600014E RID: 334 RVA: 0x0000800E File Offset: 0x0000620E
		// (set) Token: 0x0600014F RID: 335 RVA: 0x00008016 File Offset: 0x00006216
		public bool IsHtml { get; set; }

		// Token: 0x17000082 RID: 130
		// (get) Token: 0x06000150 RID: 336 RVA: 0x0000801F File Offset: 0x0000621F
		// (set) Token: 0x06000151 RID: 337 RVA: 0x0000802D File Offset: 0x0000622D
		public string Value
		{
			get
			{
				return this.Apply(this.value);
			}
			set
			{
				this.value = value;
			}
		}

		// Token: 0x06000152 RID: 338 RVA: 0x00008036 File Offset: 0x00006236
		public void Dispose()
		{
			GC.SuppressFinalize(this);
		}

		// Token: 0x06000153 RID: 339 RVA: 0x00008040 File Offset: 0x00006240
		public Element(string name, string where, string goTo, string attribute, bool isHtml)
		{
			this.Name = name;
			this.Where = where;
			this.GoTo = goTo;
			this.Attribute = attribute;
			this.IsHtml = isHtml;
			this.RemoveChars = new List<string>();
			this.Replaces = new List<string>();
		}

		// Token: 0x06000154 RID: 340 RVA: 0x00008098 File Offset: 0x00006298
		public Element(string name, string where, string value, string goTo, bool isHtml, string attribute = null)
		{
			this.Name = name;
			this.Where = where;
			this.value = value;
			this.GoTo = goTo;
			this.Attribute = (string.IsNullOrEmpty(attribute) ? string.Empty : attribute);
			this.IsHtml = isHtml;
			this.RemoveChars = new List<string>();
			this.Replaces = new List<string>();
		}

		// Token: 0x06000155 RID: 341 RVA: 0x00008108 File Offset: 0x00006308
		public Element(XmlElement node)
		{
			this.Name = node.GetAttribute("Name");
			this.Where = node.GetAttribute("Where");
			this.GoTo = node.GetAttribute("GoTo");
			this.Attribute = (node.GetAttribute("Attribute") ?? null);
			this.value = node.InnerText;
			this.IsHtml = (!string.IsNullOrEmpty(node.GetAttribute("IsHtml")) && bool.Parse(node.GetAttribute("IsHtml")));
			this.RemoveChars = new List<string>();
			string removeChars = node.GetAttribute("RemoveChars") ?? null;
			bool flag = !string.IsNullOrEmpty(removeChars);
			if (flag)
			{
				removeChars.Split(new char[]
				{
					';'
				}).ToList<string>().ForEach(delegate(string @char)
				{
					this.RemoveChars.Add(@char);
				});
			}
			this.Replaces = new List<string>();
			string replaces = node.GetAttribute("Replaces") ?? null;
			bool flag2 = !string.IsNullOrEmpty(replaces);
			if (flag2)
			{
				replaces.Split(new char[]
				{
					';'
				}).ToList<string>().ForEach(delegate(string replace)
				{
					this.Replaces.Add(replace);
				});
			}
		}

		// Token: 0x06000156 RID: 342 RVA: 0x0000824C File Offset: 0x0000644C
		private string Apply(string value)
		{
			bool flag = this.RemoveChars.Count<string>() > 0;
			if (flag)
			{
				value = StringFormat.RemoveChars(value, this.RemoveChars);
			}
			bool flag2 = this.Replaces.Count<string>() > 0;
			if (flag2)
			{
				value = StringFormat.Replace(value, this.Replaces);
			}
			return value;
		}

		// Token: 0x06000157 RID: 343 RVA: 0x000082A4 File Offset: 0x000064A4
		public XmlNode AppendTo(XmlDocument xDoc)
		{
			XmlElement element = xDoc.CreateElement("Element");
			element.SetAttribute("Name", this.Name);
			element.SetAttribute("Goto", this.GoTo);
			element.SetAttribute("Attribute", this.Attribute);
			element.SetAttribute("IsHtml", this.IsHtml.ToString());
			element.InnerText = this.value;
			return element;
		}

		// Token: 0x04000078 RID: 120
		private string value;
	}
}
