/** インデックス配列にアイテム設定。 * * 上書き。 * */ public void SetItem(int a_index, JsonItem a_item, bool a_clone) { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.List <JsonItem> t_indexarray = this.value.GetIndexArray(); if (t_indexarray != null) { if ((0 <= a_index) && (a_index < t_indexarray.Count)) { if ((a_clone == true) && (a_item != null)) { t_indexarray[a_index] = a_item.Clone(); } else { t_indexarray[a_index] = a_item; } } else { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif } } }
/** インデックス配列のアイテムチェック。 */ public bool IsExistItem(int a_index, ValueType a_valuetype = ValueType.Mask_All) { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.List <JsonItem> t_indexarray = this.value.GetIndexArray(); if (t_indexarray != null) { if (a_index < t_indexarray.Count) { if ((t_indexarray[a_index].value.valuetype | a_valuetype) > 0) { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert((t_indexarray[a_index].value.valuetype & ValueType.Calc) == 0); #endif return(true); } } } return(false); }
/** 連想配列のアイテムチェック。 */ public bool IsExistItem(string a_itemname, ValueType a_valuetype = ValueType.Mask_All) { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.Dictionary <string, JsonItem> t_associativearray = this.value.GetAssociativeArray(); if (t_associativearray != null) { JsonItem t_value; if (t_associativearray.TryGetValue(a_itemname, out t_value) == true) { if ((t_value.value.valuetype | a_valuetype) > 0) { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert((t_value.value.valuetype & ValueType.Calc) == 0); #endif return(true); } } } return(false); }
/** GetIndexArray */ public System.Collections.Generic.List <JsonItem> GetIndexArray() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.IndexArray); #endif return((System.Collections.Generic.List <JsonItem>) this.raw); }
/** GetBinaryData */ public System.Collections.Generic.List <byte> GetBinaryData() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.BinaryData); #endif return((System.Collections.Generic.List <byte>) this.raw); }
/** GetDecimalNumber */ public decimal GetDecimalNumber() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.DecimalNumber); #endif return((System.Decimal) this.raw); }
/** GetBoolData */ public System.Boolean GetBoolData() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.BoolData); #endif return((System.Boolean) this.raw); }
/** GetFloatingNumber */ public FLOATING_NUMBER_TYPE GetFloatingNumber() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.FloatingNumber); #endif return((FLOATING_NUMBER_TYPE)this.raw); }
/** GetUnsignedNumber */ public UNSIGNED_NUMBER_TYPE GetUnsignedNumber() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.UnsignedNumber); #endif return((UNSIGNED_NUMBER_TYPE)this.raw); }
/** GetAssociativeArray */ public System.Collections.Generic.Dictionary <string, JsonItem> GetAssociativeArray() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.AssociativeArray); #endif return((System.Collections.Generic.Dictionary <string, JsonItem>) this.raw); }
/** GetStringData */ public string GetStringData() { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(this.valuetype == ValueType.StringData); #endif return((string)this.raw); }
/** GetListMax */ public int GetListMax() { if (this.jsonstring != null) { this.JsonStringToValue(); } switch (this.value.valuetype) { case ValueType.AssociativeArray: { System.Collections.Generic.Dictionary <string, JsonItem> t_associativearray = this.value.GetAssociativeArray(); if (t_associativearray != null) { return(t_associativearray.Count); } } break; case ValueType.IndexArray: { System.Collections.Generic.List <JsonItem> t_indexarray = this.value.GetIndexArray(); if (t_indexarray != null) { return(t_indexarray.Count); } } break; case ValueType.StringData: { string t_stringdata = this.value.GetStringData(); if (t_stringdata != null) { return(t_stringdata.Length); } } break; case ValueType.BinaryData: { System.Collections.Generic.List <byte> t_binarydata = this.value.GetBinaryData(); if (t_binarydata != null) { return(t_binarydata.Count); } } break; } #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return(0); }
/** 連想配列キーリスト作成。 */ public System.Collections.Generic.Dictionary <string, JsonItem> .KeyCollection GetAssociativeKeyList() { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.Dictionary <string, JsonItem> t_associativearray = this.value.GetAssociativeArray(); if (t_associativearray != null) { return(t_associativearray.Keys); } #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return(null); }
/** CastToChar */ public System.Char CastToChar() { #pragma warning disable 0162 switch (this.valuetype) { case ValueType.SignedNumber: { return((System.Char)(SIGNED_NUMBER_TYPE) this.raw); } break; case ValueType.UnsignedNumber: { return((System.Char)(UNSIGNED_NUMBER_TYPE) this.raw); } break; case ValueType.FloatingNumber: { return((System.Char)(FLOATING_NUMBER_TYPE) this.raw); } break; case ValueType.DecimalNumber: { return((System.Char)(System.Decimal) this.raw); } break; case ValueType.BoolData: { return((System.Boolean) this.raw ? (System.Char) 1 : (System.Char) 0); } break; default: { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return(default); } break; }
/** インデックス配列のアイテム取得。 */ public JsonItem GetItem(int a_index) { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.List <JsonItem> t_indexlist = this.value.GetIndexArray(); if (t_indexlist != null) { if ((0 <= a_index) && (a_index < t_indexlist.Count)) { return(t_indexlist[a_index]); } } #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return(null); }
/** 連想配列のアイテム取得。 */ public JsonItem GetItem(string a_itemname) { if (this.jsonstring != null) { this.JsonStringToValue(); } System.Collections.Generic.Dictionary <string, JsonItem> t_associativearray = this.value.GetAssociativeArray(); if (t_associativearray != null) { JsonItem t_value; if (t_associativearray.TryGetValue(a_itemname, out t_value) == true) { return(t_value); } } #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return(null); }
/** JSON文字列をセット。 */ public void SetJsonString(string a_jsonstring) { if (a_jsonstring.Length > 0) { ValueType t_valuetype = ValueType_FirstCharValueType.Get(a_jsonstring[0]); #pragma warning disable 0162 switch (t_valuetype) { case ValueType.StringData: case ValueType.AssociativeArray: case ValueType.IndexArray: case ValueType.BinaryData: case ValueType.SignedNumber: case ValueType.UnsignedNumber: case ValueType.FloatingNumber: case ValueType.DecimalNumber: { //保留。 this.jsonstring = a_jsonstring; this.value.ResetFromType(t_valuetype); return; } break; case ValueType.Calc_UnknownNumber: { ValueType t_number_valuetype = ValueType_NumverValueType.Get(a_jsonstring); //保留。 this.jsonstring = a_jsonstring; this.value.ResetFromType(t_number_valuetype); return; } break; case ValueType.Calc_TrueBoolData: { this.jsonstring = null; this.value.Reset(true); return; } break; case ValueType.Calc_FalseBoolData: { this.jsonstring = null; this.value.Reset(false); return; } break; case ValueType.Null: { //NULL処理。 this.jsonstring = null; this.value.ResetFromType(ValueType.Null); return; } break; default: { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif } break; } #pragma warning restore } else { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif } this.jsonstring = null; this.value.ResetFromType(ValueType.Null); }
/** JsonStringToValue */ private void JsonStringToValue() { if (this.jsonstring != null) { #pragma warning disable 0162 switch (this.value.valuetype) { case ValueType.StringData: { System.Text.StringBuilder t_stringbuilder = new System.Text.StringBuilder(this.jsonstring.Length); ConvertJsonStringToObject.StringData.Convert(this.jsonstring, t_stringbuilder); this.value.raw = t_stringbuilder.ToString(); this.jsonstring = null; return; } break; case ValueType.SignedNumber: { SIGNED_NUMBER_TYPE t_value; ConvertJsonStringToObject.SignedNumber.Convert(this.jsonstring, out t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.UnsignedNumber: { UNSIGNED_NUMBER_TYPE t_value; ConvertJsonStringToObject.UnsignedNumber.Convert(this.jsonstring, out t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.FloatingNumber: { FLOATING_NUMBER_TYPE t_value; ConvertJsonStringToObject.FloatingNumber.Convert(this.jsonstring, out t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.IndexArray: { System.Collections.Generic.List <JsonItem> t_value = new System.Collections.Generic.List <JsonItem>(4 + this.jsonstring.Length / 7); ConvertJsonStringToObject.IndexArray.Convert(this.jsonstring, t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.AssociativeArray: { System.Collections.Generic.Dictionary <string, JsonItem> t_value = new System.Collections.Generic.Dictionary <string, JsonItem>(); ConvertJsonStringToObject.AssociativeArray.Convert(this.jsonstring, t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.BoolData: { bool t_value; ConvertJsonStringToObject.BoolData.Convert(this.jsonstring, out t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.DecimalNumber: { System.Decimal t_value; ConvertJsonStringToObject.DecimalNumber.Convert(this.jsonstring, out t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.BinaryData: { System.Collections.Generic.List <byte> t_value = new System.Collections.Generic.List <byte>(4 + this.jsonstring.Length / 2); ConvertJsonStringToObject.BinaryData.Convert(this.jsonstring, t_value); this.value.raw = t_value; this.jsonstring = null; return; } break; case ValueType.Null: { this.value.raw = null; this.jsonstring = null; return; } break; default: { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif this.value.raw = null; this.jsonstring = null; return; } break; } #pragma warning restore } }
/** ValueToJsonString */ public void ValueToJsonString(System.Text.StringBuilder a_stringbuilder, ConvertToJsonStringOption a_option) { if (this.jsonstring != null) { a_stringbuilder.Append(this.jsonstring); return; } #pragma warning disable 0162 switch (this.value.valuetype) { case ValueType.AssociativeArray: { ConvertObjectToJsonString.AssociativeArray.Convert(this.value.GetAssociativeArray(), a_stringbuilder, a_option); return; } break; case ValueType.IndexArray: { ConvertObjectToJsonString.IndexArray.Convert(this.value.GetIndexArray(), a_stringbuilder, a_option); return; } break; case ValueType.StringData: { ConvertObjectToJsonString.StringData.Convert(this.value.GetStringData(), a_stringbuilder, a_option); return; } break; case ValueType.SignedNumber: { ConvertObjectToJsonString.SignedNumber.Convert(this.value.GetSignedNumber(), a_stringbuilder, a_option); return; } break; case ValueType.UnsignedNumber: { ConvertObjectToJsonString.UnsignedNumber.Convert(this.value.GetUnsignedNumber(), a_stringbuilder, a_option); return; } break; case ValueType.FloatingNumber: { ConvertObjectToJsonString.FloatingNumber.Convert(this.value.GetFloatingNumber(), a_stringbuilder, a_option); return; } break; case ValueType.BoolData: { ConvertObjectToJsonString.BoolData.Convert(this.value.GetBoolData(), a_stringbuilder, a_option); return; } break; case ValueType.DecimalNumber: { ConvertObjectToJsonString.DecimalNumber.Convert(this.value.GetDecimalNumber(), a_stringbuilder, a_option); return; } break; case ValueType.BinaryData: { ConvertObjectToJsonString.BinaryData.Convert(this.value.GetBinaryData(), a_stringbuilder, a_option); return; } break; case ValueType.Null: { //NULL処理。 a_stringbuilder.Append("null"); return; } break; default: { #if (DEF_BLUEBACK_JSONITEM_ASSERT) DebugTool.Assert(false); #endif return; } break; } #pragma warning restore }