/// <summary> /// /// </summary> /// <param name="rawValue"></param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public static object GetAsObject(FREObject rawValue) { switch (GetType(rawValue)) { case FreObjectTypeSharp.Object: case FreObjectTypeSharp.Class: return(GetAsDictionary(rawValue)); case FreObjectTypeSharp.Number: return(GetAsDouble(rawValue)); case FreObjectTypeSharp.String: return(GetAsString(rawValue)); case FreObjectTypeSharp.Bytearray: var ba = new FreByteArraySharp(rawValue); ba.Acquire(); var byteData = ba.Bytes; ba.Release(); return(byteData); case FreObjectTypeSharp.Array: case FreObjectTypeSharp.Vector: var arrFre = new FREArray(rawValue); return(arrFre.AsArrayList()); case FreObjectTypeSharp.Bitmapdata: var bmdFre = new FreBitmapDataSharp(rawValue); return(bmdFre.AsBitmap()); case FreObjectTypeSharp.Boolean: return(GetAsBool(rawValue)); case FreObjectTypeSharp.Null: return(null); case FreObjectTypeSharp.Int: return(GetAsInt(rawValue)); case FreObjectTypeSharp.Rectangle: return(new FreRectangleSharp(rawValue).Value); case FreObjectTypeSharp.Point: return(new FrePointSharp(rawValue).Value); case FreObjectTypeSharp.Date: return(GetAsDateTime(rawValue)); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// /// </summary> /// <returns></returns> public ArrayList GetAsArrayList() { var al = new ArrayList(); var len = Length; if (len <= 0) { return(al); } for (uint i = 0; i < len; i++) { var itm = At(i); var type = itm.Type(); switch (type) { case FreObjectTypeSharp.String: al.Add(FreSharpHelper.GetAsString(itm)); break; case FreObjectTypeSharp.Bytearray: var ba = new FreByteArraySharp(itm); ba.Acquire(); var baTarget = new byte[ba.Length]; ba.Bytes.CopyTo(baTarget, 0); al.Add(baTarget); ba.Release(); break; case FreObjectTypeSharp.Array: case FreObjectTypeSharp.Vector: var arrFre = new FREArray(itm); al.Add(arrFre.GetAsArrayList()); break; case FreObjectTypeSharp.Bitmapdata: var bmdFre = new FreBitmapDataSharp(itm); al.Add(bmdFre.GetAsBitmap()); break; case FreObjectTypeSharp.Boolean: al.Add(FreSharpHelper.GetAsBool(itm)); break; case FreObjectTypeSharp.Null: break; case FreObjectTypeSharp.Int: al.Add(FreSharpHelper.GetAsInt(itm)); break; case FreObjectTypeSharp.Object: case FreObjectTypeSharp.Class: al.Add(FreSharpHelper.GetAsDictionary(itm)); break; case FreObjectTypeSharp.Number: al.Add(FreSharpHelper.GetAsDouble(itm)); break; case FreObjectTypeSharp.Rectangle: var rectFre = new FreRectangleSharp(itm); al.Add(rectFre.Value); break; default: throw new ArgumentOutOfRangeException(); } } return(al); }