public AutomapperRegistry() { var platformSpecificRegistry = PlatformAdapter.Resolve <IPlatformSpecificMapperRegistry>(); platformSpecificRegistry.Initialize(); For <ConfigurationStore>().Singleton().Use <ConfigurationStore>() .Ctor <IEnumerable <IObjectMapper> >().Is(MapperRegistry.Mappers); For <IConfigurationProvider>().Use(ctx => ctx.GetInstance <ConfigurationStore>()); For <IConfiguration>().Use(ctx => ctx.GetInstance <ConfigurationStore>()); For <ITypeMapFactory>().Use <TypeMapFactory>(); For <IMappingEngine>().Singleton().Use <MappingEngine>() .SelectConstructor(() => new MappingEngine(null)); this.Scan(scanner => { scanner.AssemblyContainingType <PostProfile>(); scanner.AddAllTypesOf <Profile>().NameBy(item => item.Name); //scanner.AssemblyContainingType<CommentProfile>(); //scanner.AddAllTypesOf<Profile>().NameBy(item => item.Name); //scanner.AssembliesFromApplicationBaseDirectory(); scanner.ConnectImplementationsToTypesClosing(typeof(ITypeConverter <,>)) .OnAddedPluginTypes(t => t.HybridHttpOrThreadLocalScoped()); //scanner.ConnectImplementationsToTypesClosing(typeof(ValueResolver<,>)) // .OnAddedPluginTypes(t => t.HybridHttpOrThreadLocalScoped()); }); }
public static IStoreManager GetStoreManager(StoreConfiguration storeConfiguration = null) { if (storeConfiguration == null) { storeConfiguration = StoreConfiguration.DefaultStoreConfiguration; } if (storeConfiguration.StoreManagerType != null) { return (Activator.CreateInstance(storeConfiguration.StoreManagerType, storeConfiguration) as IStoreManager); } #if BTREESTORE #if SILVERLIGHT return(new IsolatedStorageStoreManager(storeConfiguration)); #else return(storeConfiguration.UseIsolatedStorage ? (IStoreManager) new IsolatedStorageStoreManager(storeConfiguration) : new FileStoreManager(storeConfiguration)); #endif #else #if WINDOWS_PHONE return(new BPlusTreeStore.BPlusTreeStoreManager(storeConfiguration, new IsolatedStoragePersistanceManager())); #elif PORTABLE storeConfiguration.DisableBackgroundWrites = true; return(new BPlusTreeStoreManager(storeConfiguration, PlatformAdapter.Resolve <IPersistenceManager>())); #else return(storeConfiguration.UseIsolatedStorage ? new BPlusTreeStore.BPlusTreeStoreManager(storeConfiguration, new IsolatedStoragePersistanceManager()) : new BPlusTreeStore.BPlusTreeStoreManager(storeConfiguration, new FilePersistenceManager())); #endif #endif }
public App() { // SfdcSDK InitializeSfdcConfig(); SDKManager.CreateClientManager(false); SDKManager.RootApplicationPage = typeof(VisualBrowserPage); SDKManager.EndLoginCallBack = () => { Messenger.Default.Send(new UserLogInMessage()); }; PlatformAdapter.Resolve <ISFApplicationHelper>().Initialize(); // Set up the Logging Service and the custom log action function in the PlatformAdapter var target = new LogFileTarget(); target.RetainDays = 10; LoggingServices.DefaultConfiguration.AddTarget(LoggingLevel.Information, target); PlatformAdapter.SetCustomLoggerAction(LoggingServices.LogAction); // Continue App setup InitializeComponent(); Suspending += OnSuspending; Resuming += OnResuming; // Setup the global crash handler GlobalCrashHandler.Configure(); }
private static void RunExport(object jobData) { var exportJob = jobData as ExportJob; if (exportJob == null) { return; } try { var storeDirectory = exportJob._storeWorker.WriteStore.DirectoryPath; var exportDirectory = Path.Combine(Path.GetDirectoryName(storeDirectory), "import"); #if PORTABLE var persistenceManager = PlatformAdapter.Resolve <IPersistenceManager>(); if (!persistenceManager.DirectoryExists(exportDirectory)) { persistenceManager.CreateDirectory(exportDirectory); } var filePath = Path.Combine(exportDirectory, exportJob._outputFileName); using (var stream = persistenceManager.GetOutputStream(filePath, FileMode.Create)) #else if (!Directory.Exists(exportDirectory)) { Directory.CreateDirectory(exportDirectory); } var filePath = Path.Combine(exportDirectory, exportJob._outputFileName); Logging.LogDebug("Export file path calculated as '{0}'", filePath); using (var stream = File.Open(filePath, FileMode.Create, FileAccess.Write)) #endif { string[] graphs = String.IsNullOrEmpty(exportJob._graphUri) ? null : new[] { exportJob._graphUri }; var triples = exportJob._storeWorker.ReadStore.Match(null, null, null, graphs: graphs); var sw = new StreamWriter(stream); var sink = GetWriterSink(exportJob._exportFormat, sw); var nw = new BrightstarTripleSinkAdapter(sink); foreach (var triple in triples) { nw.Triple(triple); } sink.Close(); sw.Flush(); #if !PORTABLE stream.Flush(true); stream.Close(); #endif } exportJob._successCallback(exportJob._jobId); } catch (Exception ex) { Logging.LogError(BrightstarEventId.ExportDataError, "Error Exporting Data {0} {1}", ex.Message, ex.StackTrace); exportJob._errorCallback(exportJob._jobId, ex); } }
/// <summary> /// Returns a RestClient if user is already authenticated or otherwise kicks off a login flow /// </summary> /// <returns></returns> public RestClient GetRestClient() { RestClient restClient = PeekRestClient(); if (restClient == null) { PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); } return(restClient); }
public static IGraph LoadConfiguration(string configurationPath) { var pm = PlatformAdapter.Resolve <IPersistenceManager>(); ConfigurationLoader.PathResolver = new DotNetRdfConfigurationPathResolver(configurationPath); using (var stream = pm.GetInputStream(configurationPath)) { return(ConfigurationLoader.LoadConfiguration(configurationPath, new Uri(configurationPath), stream)); } }
public BaseController() : base() { AnonymousManagersProvider = new ManagersProvider(); IPlatformSpecificMapperRegistry platformSpecificRegistry = PlatformAdapter.Resolve <IPlatformSpecificMapperRegistry>(true); platformSpecificRegistry.Initialize(); var store = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.Mappers); _mapper = new MappingEngine(store); }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); PlatformAdapter.Resolve <ISFApplicationHelper>().OnActivated(args); var rootFrame = Window.Current.Content as Frame; if (rootFrame != null) { rootFrame.NavigationFailed += OnNavigationFailed; } }
static Path() { var provider = PlatformAdapter.Resolve <IPathSeparatorProvider>(); if (provider != null) { DirectorySeparatorChar = provider.DirectorySeparator; AltDirectorySeparatorChar = provider.AltDirectorySeparator; VolumeSeparatorChar = provider.VolumeSeparator; } }
private void CheckIfLoginNeeded() { Account account = AccountManager.GetAccount(); if (account == null) { PlatformAdapter.SendToCustomLogger("NativeMainPage.CheckIfLoginNeeded - account object is null, calling StartLoginFlow", Windows.Foundation.Diagnostics.LoggingLevel.Verbose); PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); } }
protected SalesforceApplication() { Suspending += OnSuspending; InitializeConfig(); SDKManager.CreateClientManager(false); SDKManager.RootApplicationPage = SetRootApplicationPage(); TokenRefresher = new DispatcherTimer { Interval = TimeSpan.FromMinutes(3) }; TokenRefresher.Tick += RefreshToken; PlatformAdapter.Resolve <ISFApplicationHelper>().Initialize(); }
public static void Initialise(string logFileName, bool enableDebug = false) { _persistenceManager = PlatformAdapter.Resolve <IPersistenceManager>(); if (logFileName != null) { if (!_persistenceManager.FileExists(logFileName)) { _persistenceManager.CreateFile(logFileName); } _logFileName = logFileName; } IsDebugEnabled = enableDebug; }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var webResult = args.WebAuthenticationResult; if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { Uri responseUri = new Uri(webResult.ResponseData.ToString()); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } } }
private async void DoAuthFlow(LoginOptions loginOptions) { Uri loginUri = new Uri(OAuth2.ComputeAuthorizationUrl(loginOptions)); Uri callbackUri = new Uri(loginOptions.CallbackUrl); OAuth2.ClearCookies(loginOptions); WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, loginUri, callbackUri); if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { Uri responseUri = new Uri(webAuthenticationResult.ResponseData.ToString()); AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(loginOptions, authResponse); } }
/// <summary> /// Initializes the mapping engine. /// </summary> /// <returns></returns> public static IMappingEngine Initialize() { // Initialize PlatformAdapter .Resolve <IPlatformSpecificMapperRegistry>() .Initialize(); var config = new ConfigurationStore( new TypeMapFactory(), MapperRegistry.Mappers); // Maps config.CreateMap <DatabaseRegistration, DatabaseItemViewModel>(); // Done return(new MappingEngine(config)); }
private Stream GetImportFileStream(string filePath) { #if PORTABLE var persistenceManager = PlatformAdapter.Resolve <IPersistenceManager>(); if (!persistenceManager.FileExists(filePath)) { ErrorMessage = String.Format("Cannot find file {0} in import directory", _contentFileName); throw new FileNotFoundException(ErrorMessage); } return(persistenceManager.GetInputStream(filePath)); #else if (!File.Exists(filePath)) { ErrorMessage = String.Format("Cannot find file {0} in import directory", _contentFileName); throw new FileNotFoundException(ErrorMessage); } return(_fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)); #endif }
private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e) { var frame = Window.Current.Content as Frame; if (frame == null) { return; } if (frame.SourcePageType.Equals(typeof(PincodeDialog))) { PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); e.Handled = true; } else { e.Handled = false; } }
protected override async Task DoFlushAsync(LogWriteContext context, IEnumerable <LogEventInfo> toFlush) { // create a json object... var env = PlatformAdapter.Resolve <ILoggingEnvironment>(); var wrapper = new JsonPostWrapper(env, toFlush); var json = wrapper.ToJson(); // send... var client = new HttpClient(); var content = new StringContent(json); content.Headers.ContentType.MediaType = "text/json"; // call... this.OnBeforePost(new HttpClientEventArgs(client)); // send... await client.PostAsync(this.Url, content); }
public void StartLoginFlow(LoginOptions loginOptions) { if (loginOptions == null || String.IsNullOrWhiteSpace(loginOptions.CallbackUrl) || String.IsNullOrWhiteSpace(loginOptions.LoginUrl)) { return; } try { var loginUri = new Uri(OAuth2.ComputeAuthorizationUrl(loginOptions)); var callbackUri = new Uri(loginOptions.CallbackUrl); WebAuthenticationBroker.AuthenticateAndContinue(loginUri, callbackUri, null, WebAuthenticationOptions.None); } catch (Exception ex) { PlatformAdapter.SendToCustomLogger("AccountPage.StartLoginFlow - Exception occured", LoggingLevel.Critical); PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Critical); PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); } }
public static ILogManager CreateLogManager(LoggingConfiguration config = null) { var cfg = config ?? DefaultConfiguration; cfg.Freeze(); ILogManager manager; var managerFactory = PlatformAdapter.Resolve <ILogManagerCreator>(false); if (managerFactory != null) { manager = managerFactory.Create(cfg); } else { manager = new LogManagerBase(cfg); } _configurator.OnLogManagerCreated(manager); return(manager); }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult webResult = args.WebAuthenticationResult; var logMsg = String.Format("AccountPage.ContinueWebAuthentication - WebAuthenticationResult: Status={0}", webResult.ResponseStatus); if (webResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { logMsg += string.Format(", ErrorDetail={0}", webResult.ResponseErrorDetail); } PlatformAdapter.SendToCustomLogger(logMsg, LoggingLevel.Verbose); if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { var responseUri = new Uri(webResult.ResponseData); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); } } else if (webResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { SetupAccountPage(); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_authentication_error")); SetupAccountPage(); } }
private async void LockedClick(object sender, KeyRoutedEventArgs e) { if (e.Key != VirtualKey.Accept && e.Key != VirtualKey.Enter) { return; } e.Handled = true; Account account = AccountManager.GetAccount(); if (account == null) { PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); } else if (AuthStorageHelper.ValidatePincode(Passcode.Password)) { PincodeManager.Unlock(); if (Frame.CanGoBack) { Frame.GoBack(); } else { Frame.Navigate(SDKManager.RootApplicationPage); } } else { if (RetryCounter <= 1) { await SDKManager.GlobalClientManager.Logout(); } RetryCounter--; ContentFooter.Text = String.Format(LocalizedStrings.GetString("passcode_incorrect"), RetryCounter); ContentFooter.Visibility = Visibility.Visible; } }
public void TestGetAuthHelper() { var authHelper = PlatformAdapter.Resolve <IAuthHelper>(); Assert.IsNotNull(authHelper); }
private async void DoAuthFlow(LoginOptions loginOptions) { loginOptions.DisplayType = LoginOptions.DefaultStoreDisplayType; var loginUri = new Uri(OAuth2.ComputeAuthorizationUrl(loginOptions)); var callbackUri = new Uri(loginOptions.CallbackUrl); OAuth2.ClearCookies(loginOptions); WebAuthenticationResult webAuthenticationResult; try { PlatformAdapter.SendToCustomLogger( "AccountPage.DoAuthFlow - calling WebAuthenticationBroker.AuthenticateAsync()", LoggingLevel.Verbose); if (loginOptions.UseTwoParamAuthAsyncMethod) { webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(loginOptions.BrokerOptions, loginUri); } else { webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(loginOptions.BrokerOptions, loginUri, callbackUri); } } // If a bad URI was passed in the user is shown an error message by the WebAuthenticationBroken, when user // taps back arrow we are then thrown a FileNotFoundException, but since user already saw error message we // should just swallow that exception catch (FileNotFoundException) { SetupAccountPage(); return; } catch (Exception ex) { PlatformAdapter.SendToCustomLogger("AccountPage.StartLoginFlow - Exception occured", LoggingLevel.Critical); PlatformAdapter.SendToCustomLogger(ex, LoggingLevel.Critical); DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); return; } if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { var responseUri = new Uri(webAuthenticationResult.ResponseData); if (!String.IsNullOrWhiteSpace(responseUri.Query) && responseUri.Query.IndexOf("error", StringComparison.CurrentCultureIgnoreCase) >= 0) { DisplayErrorDialog(LocalizedStrings.GetString("generic_authentication_error")); SetupAccountPage(); } else { try { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.SendToCustomLogger("AccountPage.DoAuthFlow - calling EndLoginFlow()", LoggingLevel.Verbose); await PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(loginOptions, authResponse); } catch (Exception ex) { DisplayErrorDialog($"Login failed: { ex.Message }"); SetupAccountPage(); } } } else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { SetupAccountPage(); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); } }
public void Should_resolve_using_new_factory() { PlatformAdapter.Register <IProxyGeneratorFactory, MyProxyFactory>(); PlatformAdapter.Resolve <IProxyGeneratorFactory>().ShouldBeType <MyProxyFactory>(); PlatformAdapter.Register <IProxyGeneratorFactory, ProxyGeneratorFactoryOverride>(); }
public static void SwitchAccount() { PlatformAdapter.Resolve <IAuthHelper>().StartLoginFlow(); }
static LogWriteContext() { _environment = PlatformAdapter.Resolve <ILoggingEnvironment>(); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { base.OnLaunched(e); PlatformAdapter.Resolve <ISFApplicationHelper>().OnLaunched(e); }
protected void OnSuspending(object sender, SuspendingEventArgs e) { PlatformAdapter.Resolve <ISFApplicationHelper>().OnSuspending(e); }