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

namespace ZionRobot.Models.Search
{
	// Token: 0x02000025 RID: 37
	public class Element : IDisposable
	{
		// Token: 0x1700005C RID: 92
		// (get) Token: 0x060000FC RID: 252 RVA: 0x00006D38 File Offset: 0x00004F38
		// (set) Token: 0x060000FD RID: 253 RVA: 0x00006D40 File Offset: 0x00004F40
		public string Name { get; set; }

		// Token: 0x1700005D RID: 93
		// (get) Token: 0x060000FE RID: 254 RVA: 0x00006D49 File Offset: 0x00004F49
		// (set) Token: 0x060000FF RID: 255 RVA: 0x00006D51 File Offset: 0x00004F51
		public string Where { get; set; }

		// Token: 0x1700005E RID: 94
		// (get) Token: 0x06000100 RID: 256 RVA: 0x00006D5A File Offset: 0x00004F5A
		// (set) Token: 0x06000101 RID: 257 RVA: 0x00006D62 File Offset: 0x00004F62
		public string GoTo { get; set; }

		// Token: 0x1700005F RID: 95
		// (get) Token: 0x06000102 RID: 258 RVA: 0x00006D6B File Offset: 0x00004F6B
		// (set) Token: 0x06000103 RID: 259 RVA: 0x00006D73 File Offset: 0x00004F73
		public string Attribute { get; set; }

		// Token: 0x17000060 RID: 96
		// (get) Token: 0x06000104 RID: 260 RVA: 0x00006D7C File Offset: 0x00004F7C
		// (set) Token: 0x06000105 RID: 261 RVA: 0x00006D84 File Offset: 0x00004F84
		public List<string> Replaces { get; set; }

		// Token: 0x17000061 RID: 97
		// (get) Token: 0x06000106 RID: 262 RVA: 0x00006D8D File Offset: 0x00004F8D
		// (set) Token: 0x06000107 RID: 263 RVA: 0x00006D95 File Offset: 0x00004F95
		public List<string> RemoveChars { get; set; }

		// Token: 0x17000062 RID: 98
		// (get) Token: 0x06000108 RID: 264 RVA: 0x00006D9E File Offset: 0x00004F9E
		// (set) Token: 0x06000109 RID: 265 RVA: 0x00006DA6 File Offset: 0x00004FA6
		public bool IsHtml { get; set; }

		// Token: 0x17000063 RID: 99
		// (get) Token: 0x0600010A RID: 266 RVA: 0x00006DAF File Offset: 0x00004FAF
		// (set) Token: 0x0600010B RID: 267 RVA: 0x00006DBD File Offset: 0x00004FBD
		public string Value
		{
			get
			{
				return this.Apply(this.value);
			}
			set
			{
				this.value = value;
			}
		}

		// Token: 0x0600010C RID: 268 RVA: 0x00006DC6 File Offset: 0x00004FC6
		public void Dispose()
		{
			GC.SuppressFinalize(this);
		}

		// Token: 0x0600010D RID: 269 RVA: 0x00006DD0 File Offset: 0x00004FD0
		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: 0x0600010E RID: 270 RVA: 0x00006E28 File Offset: 0x00005028
		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: 0x0600010F RID: 271 RVA: 0x00006E98 File Offset: 0x00005098
		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: 0x06000110 RID: 272 RVA: 0x00006FDC File Offset: 0x000051DC
		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: 0x06000111 RID: 273 RVA: 0x00007034 File Offset: 0x00005234
		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: 0x04000064 RID: 100
		private string value;
	}
}
