예제 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var o = new CatThreadPoolRecord();

            while (reader.Read())
            {
                var prop = reader.Value as string;
                if (prop == null)
                {
                    return(o);
                }
                switch (prop)
                {
                case "id":
                case "nodeId":
                    o.Id = reader.ReadAsString();
                    continue;

                case "pid":
                case "p":
                    o.Pid = reader.ReadAsString();
                    continue;

                case "host":
                case "h":
                    o.Host = reader.ReadAsString();
                    continue;

                case "ip":
                case "i":
                    o.Ip = reader.ReadAsString();
                    continue;

                case "port":
                case "po":
                    o.Port = reader.ReadAsString();
                    continue;

                default:
                    var threadPoolField = GetThreadPoolAndField(prop);
                    if (threadPoolField == null)
                    {
                        continue;
                    }
                    string threadPool = threadPoolField.Item1, field = threadPoolField.Item2;

                    var value = reader.ReadAsString();
                    SetThreadPool(threadPool, o, field, value);
                    continue;
                }
            }
            return(o);
        }
		public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
										JsonSerializer serializer)
		{
			var o = new CatThreadPoolRecord();
			while (reader.Read())
			{
				var prop = reader.Value as string;
				if (prop == null) return o;
				switch (prop)
				{
					case "id":
					case "nodeId":
						o.Id = reader.ReadAsString();
						continue;
					case "pid":
					case "p":
						o.Pid = reader.ReadAsString();
						continue;
					case "host":
					case "h":
						o.Host = reader.ReadAsString();
						continue;
					case "ip":
					case "i":
						o.Ip = reader.ReadAsString();
						continue;
					case "port":
					case "po":
						o.Port = reader.ReadAsString();
						continue;
					default:
						var threadPoolField = GetThreadPoolAndField(prop);
						if (threadPoolField == null) continue;
						string threadPool = threadPoolField.Item1, field = threadPoolField.Item2;

						var value = reader.ReadAsString();
						SetThreadPool(threadPool, o, field, value);
						continue;
				}
			}
			return o;
		}
		private void SetThreadPool(string threadPool, CatThreadPoolRecord o, string field, string value)
		{
			switch (threadPool)
			{
				case "bulk":
				case "b":
					if (o.Bulk == null) o.Bulk = new CatThreadPool();
					this.SetFieldValue(o.Bulk, field, value);
					return;
				case "flush":
				case "f":
					if (o.Flush == null) o.Flush = new CatThreadPool();
					this.SetFieldValue(o.Flush, field, value);
					return;
				case "generic":
				case "ge":
					if (o.Generic == null) o.Generic = new CatThreadPool();
					this.SetFieldValue(o.Generic, field, value);
					return;
				case "get":
				case "g":
					if (o.Get == null) o.Get = new CatThreadPool();
					this.SetFieldValue(o.Get, field, value);
					return;
				case "index":
				case "i":
					if (o.Index == null) o.Index = new CatThreadPool();
					this.SetFieldValue(o.Index, field, value);
					return;
				case "management":
				case "ma":
					if (o.Management == null) o.Management = new CatThreadPool();
					this.SetFieldValue(o.Management, field, value);
					return;
				case "merge":
				case "m":
					if (o.Merge == null) o.Merge = new CatThreadPool();
					this.SetFieldValue(o.Merge, field, value);
					return;
				case "optimize":
				case "o":
					if (o.Optimize == null) o.Optimize = new CatThreadPool();
					this.SetFieldValue(o.Optimize, field, value);
					return;
				case "percolate":
				case "p":
					if (o.Percolate == null) o.Percolate = new CatThreadPool();
					this.SetFieldValue(o.Percolate, field, value);
					return;
				case "refresh":
				case "r":
					if (o.Refresh == null) o.Refresh = new CatThreadPool();
					this.SetFieldValue(o.Refresh, field, value);
					return;
				case "search":
				case "s":
					if (o.Search == null) o.Search = new CatThreadPool();
					this.SetFieldValue(o.Search, field, value);
					return;
				case "snapshot":
				case "sn":
					if (o.Snapshot == null) o.Snapshot = new CatThreadPool();
					this.SetFieldValue(o.Snapshot, field, value);
					return;
				case "suggest":
				case "su":
					if (o.Suggest == null) o.Suggest = new CatThreadPool();
					this.SetFieldValue(o.Suggest, field, value);
					return;
				case "warmer":
				case "w":
					if (o.Warmer == null) o.Warmer = new CatThreadPool();
					this.SetFieldValue(o.Warmer, field, value);
					return;
			}
		}
예제 #4
0
        private void SetThreadPool(string threadPool, CatThreadPoolRecord o, string field, string value)
        {
            switch (threadPool)
            {
            case "bulk":
            case "b":
                if (o.Bulk == null)
                {
                    o.Bulk = new CatThreadPool();
                }
                this.SetFieldValue(o.Bulk, field, value);
                return;

            case "flush":
            case "f":
                if (o.Flush == null)
                {
                    o.Flush = new CatThreadPool();
                }
                this.SetFieldValue(o.Flush, field, value);
                return;

            case "generic":
            case "ge":
                if (o.Generic == null)
                {
                    o.Generic = new CatThreadPool();
                }
                this.SetFieldValue(o.Generic, field, value);
                return;

            case "get":
            case "g":
                if (o.Get == null)
                {
                    o.Get = new CatThreadPool();
                }
                this.SetFieldValue(o.Get, field, value);
                return;

            case "index":
            case "i":
                if (o.Index == null)
                {
                    o.Index = new CatThreadPool();
                }
                this.SetFieldValue(o.Index, field, value);
                return;

            case "management":
            case "ma":
                if (o.Management == null)
                {
                    o.Management = new CatThreadPool();
                }
                this.SetFieldValue(o.Management, field, value);
                return;

            case "merge":
            case "m":
                if (o.Merge == null)
                {
                    o.Merge = new CatThreadPool();
                }
                this.SetFieldValue(o.Merge, field, value);
                return;

            case "optimize":
            case "o":
                if (o.Optimize == null)
                {
                    o.Optimize = new CatThreadPool();
                }
                this.SetFieldValue(o.Optimize, field, value);
                return;

            case "percolate":
            case "p":
                if (o.Percolate == null)
                {
                    o.Percolate = new CatThreadPool();
                }
                this.SetFieldValue(o.Percolate, field, value);
                return;

            case "refresh":
            case "r":
                if (o.Refresh == null)
                {
                    o.Refresh = new CatThreadPool();
                }
                this.SetFieldValue(o.Refresh, field, value);
                return;

            case "search":
            case "s":
                if (o.Search == null)
                {
                    o.Search = new CatThreadPool();
                }
                this.SetFieldValue(o.Search, field, value);
                return;

            case "snapshot":
            case "sn":
                if (o.Snapshot == null)
                {
                    o.Snapshot = new CatThreadPool();
                }
                this.SetFieldValue(o.Snapshot, field, value);
                return;

            case "suggest":
            case "su":
                if (o.Suggest == null)
                {
                    o.Suggest = new CatThreadPool();
                }
                this.SetFieldValue(o.Suggest, field, value);
                return;

            case "warmer":
            case "w":
                if (o.Warmer == null)
                {
                    o.Warmer = new CatThreadPool();
                }
                this.SetFieldValue(o.Warmer, field, value);
                return;
            }
        }