private void EnsureProfileProperties(ILifetimeScope scope, ITargetingProfileConfig config, SPSite site)
 {
     var logger = scope.Resolve<ILogger>();
     var userProfilePropertyHelper = scope.Resolve<IUserProfilePropertyHelper>();
     foreach (var userProfilePropertyInfo in config.UserProfileProperties)
     {
         logger.Info("Ensuring profile property '{0}'", userProfilePropertyInfo.Name);
         userProfilePropertyHelper.EnsureProfileProperty(site, userProfilePropertyInfo);
     }
 }
        private void EnsureProfileSyncTimerJob(ILifetimeScope scope, ITargetingProfileConfig config, SPSite site)
        {
            var timerJobName = config.TimerJobName;

            // Delete if it already exists
            DeleteTimerJobIfExists(site, timerJobName);

            // Register timer job with scheduling
            var timerJob = scope.Resolve<SPJobDefinition>(
                new TypedParameter(typeof(string), timerJobName),
                new TypedParameter(typeof(SPWebApplication), site.WebApplication));

            timerJob.Schedule = config.TimerJobSchedule;

            // Service accout for the application pool must be set
            // http://technet.microsoft.com/en-us/library/ee513067.aspx
            timerJob.Update();
        }