public static int ValueToInt(TJSONValue Value) { int result; //@ Undeclared identifier(3): 'TJSONString' //@ Unsupported property or method(D): 'Value' //@ Unsupported function or procedure: 'TryStrToInt' if (!TryStrToInt(TJSONString(Value).Value, result)) { throw new Exception("不是數值"); } return(result); }
public static DateTime ValueToDateTime(TJSONValue Value) { DateTime result; //@ Undeclared identifier(3): 'TJSONString' //@ Unsupported property or method(D): 'Value' //@ Unsupported function or procedure: 'TryStrToDateTime' if (!TryStrToDateTime(TJSONString(Value).Value, result)) { throw new Exception("不是日期時間"); } return(result); }
// 值的轉換 public static string ValueToString(TJSONValue Value) { string result; try { //@ Undeclared identifier(3): 'TJSONString' //@ Unsupported property or method(D): 'Value' result = TJSONString(Value).Value; } catch { throw new Exception("不是字串"); } return(result); }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { ((MainTweetPage)mp).listBox1.Items.Add(obj.getString("username") + ": " + obj.getString("message")); SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } }), null); return(null); }
public static bool ValueToBoolean(TJSONValue Value) { bool result; //@ Undeclared identifier(3): 'TJSONFalse' if (Value is TJSONFalse) { result = false; } //@ Undeclared identifier(3): 'TJSONTrue' else if (Value is TJSONTrue) { result = true; } else { throw new Exception("不是布林"); } return(result); }
/** * override this method to implement callbacks actions * @param pars */ public abstract TJSONValue Execute(TJSONValue value, int JSONType);
public static void SetVariantToJSONValue(TJSONValue xObject, object Value) { SetValueToJSONValue(xObject, VariantToValue(Value)); }
public static void SetValueToJSONValue(TJSONValue xObject, DateTime Value) { SetValueToJSONValue(xObject, DateTimeToValue(Value)); }
public static void SetValueToJSONValue(TJSONValue xObject, bool Value) { SetValueToJSONValue(xObject, BooleanToValue(Value)); }
public static void SetValueToJSONValue(TJSONValue xObject, double Value) { SetValueToJSONValue(xObject, DoubleToValue(Value)); }
public static void SetValueToJSONValue(TJSONValue xObject, int Value) { SetValueToJSONValue(xObject, IntToValue(Value)); }
public static void SetValueToJSONValue(TJSONValue xObject, string Value) { SetValueToJSONValue(xObject, StringToValue(Value)); }
// 以序列的方式操作JSON物件(支援多型) public static void SetStratumValue(TJSONObject Owner, string[] Stratum, TJSONValue Value) { int i; int index; int max; TJSONObject mObj; TJSONObject mObj1; TJSONPair mPar; if (Stratum.Length == 0) { return; } mObj = Owner; max = Stratum.GetUpperBound(0); for (i = 0; i < max; i++) { // 只作到倒數第2個 index = IndexOfName(mObj, Stratum[i]); if (index == -1) { mObj1 = new TJSONObject(); //@ Unsupported property or method(A): 'AddPair' mObj.AddPair(Stratum[i], mObj1); mObj = mObj1; // 現在的兒子是下一次的爸爸 } else { //@ Unsupported property or method(A): 'get' mPar = mObj.get(index); //@ Unsupported property or method(C): 'JsonValue' //@ Undeclared identifier(3): 'TJSONObject' if (mPar.JsonValue is TJSONObject) { //@ Unsupported property or method(C): 'JsonValue' //@ Undeclared identifier(3): 'TJSONObject' mObj = TJSONObject(mPar.JsonValue); } else { // 兒子不是TJSONObject就砍掉重建 //@ Unsupported property or method(C): 'JsonValue' //@ Unsupported property or method(D): 'Free' mPar.JsonValue.Free; mObj1 = new TJSONObject(); //@ Unsupported property or method(C): 'JsonValue' mPar.JsonValue = mObj1; mObj = mObj1; // 現在的兒子是下一次的爸爸 } } } // 做最後一個 index = IndexOfName(mObj, Stratum[max]); if (index == -1) { //@ Unsupported property or method(A): 'AddPair' mObj.AddPair(Stratum[max], Value); } else { //@ Unsupported property or method(A): 'Get' //@ Unsupported property or method(D): 'JsonValue' //@ Unsupported property or method(D): 'Free' mObj.Get(index).JsonValue.Free; //@ Unsupported property or method(A): 'Get' //@ Unsupported property or method(D): 'JsonValue' mObj.Get(index).JsonValue = Value; } }
/** * override this method to implement callbacks actions * @param pars */ public abstract TJSONValue Execute(TJSONValue value, int JSONType);
public object AnsiStrToVar2_GetValue(TJSONValue xValue) { object result; return(result); }
public string AnsiStrToVar2_ChkValue(TJSONValue xValue) { string result; return(result); }
public static TJSONValue GetPub_J(TDataPoolNode xNode, string[] xStratum) { TJSONValue result = null; return(result); }
public static void SetPubValue(TDataPoolNode xNode, string[] xStratum, TJSONValue xValue) { }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { string notificationtype = obj.getString("notificationType"); if (notificationtype == "message") { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { System.Windows.Controls.ListBox listbox = ((MainTweetPage)mp).listBox1; listbox.Items.Add(obj.getString("fromusrname") + " " + obj.getString("datetime")); string msgText = obj.getString("message"); int txtPos = 0; int txtLen = 22; while (txtPos < msgText.Length) { string dipTxt = msgText.Substring(txtPos, txtLen); listbox.Items.Add(dipTxt); txtPos = txtPos + txtLen; if (txtPos + txtLen > msgText.Length) { txtLen = msgText.Length - txtPos; } } SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } else if (notificationtype == "cmd") { if (obj.getString("cmd") == "vibrate") { /* SoundEffect.MasterVolume = 1.0f; * SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); * SoundEffectInstance sfxInstance = sfx.CreateInstance(); * sfxInstance.Play();*/ Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 200); timer.Tick += (tsender, tevt) => { var t = tsender as System.Windows.Threading.DispatcherTimer; t.Stop(); Microsoft.Devices.VibrateController.Default.Stop(); }; timer.Start(); } if (obj.getString("cmd") == "ring") { SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } }), null); return(null); }