123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.Collections;
- using System.Collections.Specialized;
- using Agora.Rtc.LitJson;
- namespace Agora.Rtc
- {
- public class Optional<T>
- {
- private T value;
- private bool hasValue;
- public Optional()
- {
- hasValue = false;
- }
- public bool HasValue()
- {
- return hasValue;
- }
- public T GetValue()
- {
- return this.value;
- }
- public void SetValue(T val)
- {
- this.hasValue = true;
- this.value = val;
- }
- public void SetEmpty()
- {
- this.hasValue = false;
- }
- }
- public class OptionalJsonParse
- {
- public virtual void ToJson(JsonWriter writer)
- {
- throw new NotImplementedException();
- }
- public virtual void WriteEnum(LitJson.JsonWriter writer, Object obj)
- {
- Type obj_type = obj.GetType();
- Type e_type = Enum.GetUnderlyingType(obj_type);
- if (e_type == typeof(long))
- writer.Write((long)obj);
- else if (e_type == typeof(uint))
- writer.Write((uint)obj);
- else if (e_type == typeof(ulong))
- writer.Write((ulong)obj);
- else if (e_type == typeof(ushort))
- writer.Write((ushort)obj);
- else if (e_type == typeof(short))
- writer.Write((short)obj);
- else if (e_type == typeof(byte))
- writer.Write((byte)obj);
- else if (e_type == typeof(sbyte))
- writer.Write((sbyte)obj);
- else
- writer.Write((int)obj);
- }
- }
- }
|