Esempio n. 1
0
        public static PFObject ToPfObject(this object obj)
        {
            var type       = obj.GetType();
            var pfObj      = PFObject.FromName(type.Name);
            var properties = type.GetProperties();

            foreach (var prop in properties)
            {
                if (Attribute.IsDefined(prop, typeof(IgnoreDataMemberAttribute)))
                {
                    continue;
                }
                string keyName = Attribute.IsDefined(prop, typeof(DataMemberAttribute)) ? ((DataMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(DataMemberAttribute))).Name : prop.Name;
                if (keyName == "UpdatedAt" || keyName == "CreatedAt" || keyName == "ObjectId")
                {
                    continue;
                }
                var      val = prop.GetValue(obj, null);
                NSString valString;
                if (val is DateTime)
                {
                    valString = new NSString(((DateTime)val).ToString("s"));
                }
                else
                {
                    valString = new NSString(val.ToString());
                }
                pfObj.SetObjectforKey(valString, keyName);
            }
            return(pfObj);
        }
        //ParseStarterProjectViewController viewController;

        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            NSUrlResponse url;

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            Parse.Parse.SetApplicationId("appid", "clientkey");
            NSError error = new NSError();

            PFObject testObject = PFObject.FromName("TestObject");

            testObject.SetObjectforKey(new NSString("bar"), "foo");
            testObject.Save(out error);
            //viewController = new ParseStarterProjectViewController ();
            //window.RootViewController = viewController;
            window.MakeKeyAndVisible();

            return(true);
        }