Ejemplo n.º 1
0
            // obj to IDictionary<String, Object>
            public override bool TrySerializeNonPrimitiveObject(object input, out object output)
            {
                try
                {
                    Type objectType = input.GetType();

                    if (/*typeof(IBmobWritable).IsAssignableFrom(objectType)*/ input is IBmobWritable)
                    {
                        IBmobWritable obj     = (IBmobWritable)input;
                        BmobOutput    tOutput = new BmobOutput();
                        obj.write(tOutput, isPrint);

                        output = tOutput.getData();
                        return(true);
                    }
                    else if (objectType == typeof(BmobInt) ||
                             objectType == typeof(BmobLong) ||
                             objectType == typeof(BmobDouble) ||
                             objectType == typeof(BmobBoolean) ||
                             objectType == typeof(BmobACL))
                    {
                        object value = 0;
                        if (input is BmobInt)
                        {
                            value = (input as BmobInt).Get();
                        }
                        else if (input is BmobLong)
                        {
                            value = (input as BmobLong).Get();
                        }
                        else if (input is BmobDouble)
                        {
                            value = (input as BmobDouble).Get();
                        }
                        else if (input is BmobBoolean)
                        {
                            value = (input as BmobBoolean).Get();
                        }
                        else if (input is BmobACL)
                        {
                            value = (input as BmobACL).Get();
                        }

                        output = value;
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    BmobDebug.Log(e);
                }

                return(base.TrySerializeNonPrimitiveObject(input, out output));
            }