コード例 #1
0
        public static void Initialize()
        {
            ParseObject.RegisterSubclass <ApParseUser>();
            ParseObject.RegisterSubclass <ApParseInstallation>();
            ParseObject.RegisterSubclass <ApParseSession>();

            ParseObject.RegisterSubclass <ApParseSighting>();
            ParseObject.RegisterSubclass <ApParseSite>();
            ParseObject.RegisterSubclass <ApParseRule>();
            ParseObject.RegisterSubclass <ApParseTaxon>();

            var config = new ParseClient.Configuration
            {
                ApplicationId = ConfigurationManager.AppSettings.ParseApplicationId,
                WindowsKey    = ConfigurationManager.AppSettings.ParseDotNetKey,
                Server        = ConfigurationManager.AppSettings.ParseServerUrl,
            };

            ParseClient.Initialize(config);
            ParseAnalytics.TrackAppOpenedAsync();

#if __ANDROID__
            ParsePush.ParsePushNotificationReceived += ParsePush.DefaultParsePushNotificationReceivedHandler;
            if (ParseUser.CurrentUser != null)
            {
                ParseInstallation.CurrentInstallation["user"] = ParseUser.CurrentUser;
                ParseInstallation.CurrentInstallation.SaveAsync();
            }
#endif
        }
コード例 #2
0
        private Task <ParseCommand> PrepareCommand(ParseCommand command)
        {
            ParseCommand newCommand = new ParseCommand(command);

            // Disabled
            //Task<ParseCommand> installationIdTask = installationIdController.GetAsync().ContinueWith(t =>
            //{
            //    newCommand.Headers.Add(new KeyValuePair<string, string>("X-Parse-Installation-Id", t.Result.ToString()));
            //    return newCommand;
            //});

            // TODO (richardross): Inject configuration instead of using shared static here.
            ParseClient.Configuration configuration = ParseClient.CurrentConfiguration;
            newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Application-Id", configuration.ApplicationID));
            newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Client-Version", ParseClient.VersionString));

            if (configuration.AuxiliaryHeaders != null)
            {
                foreach (KeyValuePair <string, string> header in configuration.AuxiliaryHeaders)
                {
                    newCommand.Headers.Add(header);
                }
            }

            if (!String.IsNullOrEmpty(configuration.VersionInfo.BuildVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-App-Build-Version", configuration.VersionInfo.BuildVersion));
            }
            if (!String.IsNullOrEmpty(configuration.VersionInfo.DisplayVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-App-Display-Version", configuration.VersionInfo.DisplayVersion));
            }
            if (!String.IsNullOrEmpty(configuration.VersionInfo.OSVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-OS-Version", configuration.VersionInfo.OSVersion));
            }

            // TODO (richardross): I hate the idea of having this super tightly coupled static variable in here.
            // Lets eventually get rid of it.
            if (!String.IsNullOrEmpty(ParseClient.MasterKey))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Master-Key", ParseClient.MasterKey));
            }
            else
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Windows-Key", configuration.Key));
            }

            // TODO (richardross): Inject this instead of using static here.
            if (ParseUser.IsRevocableSessionEnabled)
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Revocable-Session", revocableSessionTokentrueValue));
            }

            return(Task.FromResult(newCommand));
            //return new Task<ParseCommand>(() => { return newCommand; });
        }
コード例 #3
0
        Task <ParseCommand> PrepareCommand(ParseCommand command)
        {
            ParseCommand newCommand = new ParseCommand(command);

            Task <ParseCommand> installationIdTask = InstallationIdController.GetAsync().ContinueWith(t =>
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Installation-Id", t.Result.ToString()));
                return(newCommand);
            });

            // TODO: Inject configuration instead of using shared static here.
            ParseClient.Configuration configuration = ParseClient.CurrentConfiguration;
            newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Application-Id", configuration.ApplicationID));
            newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Client-Version", ParseClient.VersionString));

            if (configuration.AuxiliaryHeaders != null)
            {
                foreach (KeyValuePair <string, string> header in configuration.AuxiliaryHeaders)
                {
                    newCommand.Headers.Add(header);
                }
            }

            if (!String.IsNullOrEmpty(configuration.VersionInfo.BuildVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-App-Build-Version", configuration.VersionInfo.BuildVersion));
            }
            if (!String.IsNullOrEmpty(configuration.VersionInfo.DisplayVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-App-Display-Version", configuration.VersionInfo.DisplayVersion));
            }
            if (!String.IsNullOrEmpty(configuration.VersionInfo.OSVersion))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-OS-Version", configuration.VersionInfo.OSVersion));
            }
            if (!String.IsNullOrEmpty(configuration.MasterKey))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Master-Key", configuration.MasterKey));
            }
            else if (!String.IsNullOrEmpty(configuration.Key))
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Windows-Key", configuration.Key));
            }

            // TODO: Inject this instead of using static here.
            if (ParseUser.IsRevocableSessionEnabled)
            {
                newCommand.Headers.Add(new KeyValuePair <string, string>("X-Parse-Revocable-Session", "1"));
            }

            return(installationIdTask);
        }
コード例 #4
0
 public static void Initialize()
 {
     ServiceLocator.Instance.Register <IRestService, RestService>();
     try
     {
         ParseClient.Configuration config = new ParseClient.Configuration
         {
             ApplicationId = "SuperMen",
             WindowsKey    = "rickpham",
             Server        = @"http://ec2-52-63-31-67.ap-southeast-2.compute.amazonaws.com:1337/parse/"
         };
         ParseClient.Initialize(config);
     }
     catch (Exception e)
     {
         Debug.WriteLine("ERRORR ****************************");
         Debug.WriteLine(e.ToString());
     }
 }