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

namespace ZionRobot.Models.Search
{
	// Token: 0x0200002F RID: 47
	public class Element : IDisposable
	{
		// Token: 0x17000080 RID: 128
		// (get) Token: 0x0600014D RID: 333 RVA: 0x000082CC File Offset: 0x000064CC
		// (set) Token: 0x0600014E RID: 334 RVA: 0x000082D4 File Offset: 0x000064D4
		public string Name { get; set; }

		// Token: 0x17000081 RID: 129
		// (get) Token: 0x0600014F RID: 335 RVA: 0x000082DD File Offset: 0x000064DD
		// (set) Token: 0x06000150 RID: 336 RVA: 0x000082E5 File Offset: 0x000064E5
		public string Where { get; set; }

		// Token: 0x17000082 RID: 130
		// (get) Token: 0x06000151 RID: 337 RVA: 0x000082EE File Offset: 0x000064EE
		// (set) Token: 0x06000152 RID: 338 RVA: 0x000082F6 File Offset: 0x000064F6
		public string GoTo { get; set; }

		// Token: 0x17000083 RID: 131
		// (get) Token: 0x06000153 RID: 339 RVA: 0x000082FF File Offset: 0x000064FF
		// (set) Token: 0x06000154 RID: 340 RVA: 0x00008307 File Offset: 0x00006507
		public string Attribute { get; set; }

		// Token: 0x17000084 RID: 132
		// (get) Token: 0x06000155 RID: 341 RVA: 0x00008310 File Offset: 0x00006510
		// (set) Token: 0x06000156 RID: 342 RVA: 0x00008318 File Offset: 0x00006518
		public List<string> Replaces { get; set; }

		// Token: 0x17000085 RID: 133
		// (get) Token: 0x06000157 RID: 343 RVA: 0x00008321 File Offset: 0x00006521
		// (set) Token: 0x06000158 RID: 344 RVA: 0x00008329 File Offset: 0x00006529
		public List<string> RemoveChars { get; set; }

		// Token: 0x17000086 RID: 134
		// (get) Token: 0x06000159 RID: 345 RVA: 0x00008332 File Offset: 0x00006532
		// (set) Token: 0x0600015A RID: 346 RVA: 0x0000833A File Offset: 0x0000653A
		public bool IsHtml { get; set; }

		// Token: 0x17000087 RID: 135
		// (get) Token: 0x0600015B RID: 347 RVA: 0x00008343 File Offset: 0x00006543
		// (set) Token: 0x0600015C RID: 348 RVA: 0x00008351 File Offset: 0x00006551
		public string Value
		{
			get
			{
				return this.Apply(this.value);
			}
			set
			{
				this.value = value;
			}
		}

		// Token: 0x0600015D RID: 349 RVA: 0x0000835A File Offset: 0x0000655A
		public void Dispose()
		{
			GC.SuppressFinalize(this);
		}

		// Token: 0x0600015E RID: 350 RVA: 0x00008364 File Offset: 0x00006564
		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: 0x0600015F RID: 351 RVA: 0x000083BC File Offset: 0x000065BC
		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: 0x06000160 RID: 352 RVA: 0x0000842C File Offset: 0x0000662C
		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: 0x06000161 RID: 353 RVA: 0x00008570 File Offset: 0x00006770
		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: 0x06000162 RID: 354 RVA: 0x000085C8 File Offset: 0x000067C8
		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: 0x0400007E RID: 126
		private string value;
	}
}
