using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Runtime.Serialization;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace Hydro.MapView
|
{
|
[Serializable]
|
public class dict : Dictionary<string, dynamic>
|
{
|
public dict() : base()
|
{
|
}
|
|
public dict(int capacity) : base(capacity)
|
{
|
}
|
|
public dict(IEqualityComparer<string> comparer) : base(comparer)
|
{
|
}
|
public dict(IDictionary<string, dynamic> dictionary) : base(dictionary)
|
{
|
}
|
public dict(int capacity, IEqualityComparer<string> comparer) : base(capacity, comparer)
|
{
|
}
|
public dict(IDictionary<string, dynamic> dictionary, IEqualityComparer<string> comparer) : base(dictionary, comparer)
|
{
|
}
|
protected dict(SerializationInfo info, StreamingContext context)
|
: base(info, context)
|
{
|
Value = info.GetBoolean("Test_Value");
|
}
|
|
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
{
|
base.GetObjectData(info, context);
|
info.AddValue("Test_Value", Value);
|
}
|
//public Dictionary<string, object> Dictionary()
|
//{
|
// Dictionary<string, object> dc = new Dictionary<string, object>(this);
|
// return dc;
|
//}
|
public bool Value { get; set; }
|
|
public bool SetKey(string key, dynamic Value)
|
{
|
if (this.Contains(key))
|
{
|
this[key] = Value;
|
return false;
|
}
|
else
|
{
|
this.Add(key, Value);
|
return true;
|
}
|
}
|
public string[] GetKeys()
|
{
|
return this.Keys.ToArray();
|
}
|
public List<TempForEnum> items()
|
{
|
var temp_list = new List<TempForEnum>();
|
foreach (var Pair in this)
|
{
|
temp_list.Add(new TempForEnum(Pair.Key, Pair.Value));
|
}
|
return temp_list;
|
}
|
public bool Contains(string[] keys)
|
{
|
foreach (var key in keys)
|
if (!this.Contains(key)) return false;
|
return true;
|
}
|
public bool Contains(string key)
|
{
|
return this.ContainsKey(key);
|
}
|
public bool Contains(KeyValuePair<string, dynamic> key)
|
{
|
return this.ContainsKey(key.Key);
|
}
|
public dynamic Get(string key, dynamic @default = null)
|
{
|
if (this.Contains(key))
|
return this[key];//obj.FirstOrDefault((k) => k.Key == key);
|
else
|
return @default;
|
}
|
public dynamic Get(KeyValuePair<string, dynamic> key, dynamic @default = null)
|
{
|
if (this.Contains(key))
|
return this[key];//obj.FirstOrDefault((k) => k.Key == key);
|
else
|
return @default;
|
}
|
public dynamic pop(string key, dynamic @default = null)
|
{
|
if (this.Contains(key))
|
{
|
var temp = this[key];
|
this.Remove(key);
|
return temp;//obj.FirstOrDefault((k) => k.Key == key);
|
}
|
else
|
return @default;
|
}
|
public dynamic pop(KeyValuePair<string, dynamic> key, dynamic @default = null)
|
{
|
if (this.Contains(key))
|
{
|
var temp = this[key];
|
this.Remove(key);
|
return temp;//obj.FirstOrDefault((k) => k.Key == key);
|
}
|
else
|
return @default;
|
}
|
public dynamic this[KeyValuePair<string, dynamic> key]
|
{
|
get { return this[key.Key]; }
|
set { this[key.Key] = value; }
|
}
|
public new dynamic this[string key]
|
{
|
get { return base[key]; }
|
set
|
{
|
if (this.ContainsKey(key)) base[key] = value;
|
else this.Add(key, value);
|
}
|
}
|
public dynamic this[Type key_Type]
|
{
|
get { return base[key_Type.Name]; }
|
set
|
{
|
if (this.ContainsKey(key_Type.Name)) base[key_Type.Name] = value;
|
else
|
{
|
this.Add(key_Type.Name, value);
|
if (this.dic_Type == null)
|
dic_Type = new dict();
|
if (!this.dic_Type.ContainsKey(key_Type.Name))
|
this.dic_Type.Add(key_Type.Name, key_Type);
|
}
|
}
|
}
|
public dict dic_Type;
|
public bool Remove(KeyValuePair<string, dynamic> key)
|
{
|
return this.Remove(key.Key);
|
}
|
|
public List<string> keys()
|
{
|
return this.Keys.ToList();
|
}
|
public List<dynamic> values()
|
{
|
return this.Values.ToList();
|
}
|
|
#region 将Session的元素简单放进dict中,简单处理方便使用
|
|
public Task finish()
|
{
|
return Task.Run(() => { });
|
}
|
public string msg
|
{
|
get { return this.Get("message"); }
|
}
|
public string msg_text
|
{
|
get { return this.Get("message"); }
|
}
|
public string current_arg_text
|
{
|
get { return this.Get("current_arg_text"); }
|
}
|
public dict ctx
|
{
|
get { return this; }
|
}
|
|
#endregion
|
|
#region IntentCommand
|
public double confidence;
|
public string methodName;
|
public dict args;
|
public string current_arg;
|
//current_arg: str = ''
|
public dict(double confidence, string methodName, string current_arg = "", dict args = null)
|
{
|
this.confidence = confidence;
|
this.methodName = methodName;
|
this.args = args;
|
this.current_arg = current_arg;
|
}
|
#endregion
|
|
}
|
|
|
}
|