/// <summary>Instantiates new MangoPayApi object.</summary> public MangoPayApi() { // default config setup Config = new Configuration(); OAuthTokenManager = new AuthorizationTokenManager(this); // API managers initialization AuthenticationManager = new ApiOAuth(this); Clients = new ApiClients(this); Users = new ApiUsers(this); Wallets = new ApiWallets(this); PayIns = new ApiPayIns(this); PayOuts = new ApiPayOuts(this); Refunds = new ApiRefunds(this); Transfers = new ApiTransfers(this); CardRegistrations = new ApiCardRegistrations(this); Cards = new ApiCards(this); Events = new ApiEvents(this); CardPreAuthorizations = new ApiCardPreAuthorizations(this); Hooks = new ApiHooks(this); Kyc = new ApiKyc(this); Disputes = new ApiDisputes(this); Idempotency = new ApiIdempotency(this); Mandates = new ApiMandates(this); Reports = new ApiReports(this); SingleSignOns = new ApiSingleSignOns(this); PermissionGroups = new ApiPermissionGroups(this); BankingAlias = new ApiBankingAliases(this); UboDeclarations = new ApiUboDeclarations(this); }
private static void LoadFinalMods() { var registeredMods = ModRegistry.GetRegisteredItems(); foreach (var mod in registeredMods.Where(n => n.ModState == ModState.Unloaded)) { Log.Verbose($"Loading mod: {mod.Name} by {mod.Author}"); try { ApiEvents.InvokeModPreLoad(mod); mod.OnBeforeLoaded(); if (mod.HasContent) { mod.LoadContent(); } if (mod.HasDll) { mod.LoadModDll(); } mod.ModState = ModState.Loaded; mod.OnAfterLoaded(); Log.Success($"Loaded Mod: {mod.Name} v{mod.Version} by {mod.Author}"); ApiEvents.InvokeModPostLoad(mod); } catch (Exception ex) { mod.ModState = ModState.Errored; Log.Exception($"Error loading mod {mod.Name} by {mod.Author}", ex); ApiEvents.InvokeModLoadError(mod); } } }
/// <summary> /// Show calendar events for the first time. /// </summary> public async Task <ActionResult> Index() { var token = await GetTokenCache(); var data = await ApiEvents.GetEvents(token); return(View(data)); }
/// <summary> /// Show calendar events for paging. /// </summary> public async Task <ActionResult> Index(EventsModel model) { var token = await GetTokenCache(); var data = await ApiEvents.GetEvents(token, model.page *model.page_size); data.page = model.page; return(View(data)); }
/// <summary> /// Check whether access_token cache is created and stores if not. /// </summary> async Task <string> GetTokenCache() { var tokenCache = (Token)HttpContext.Cache.Get("access_token"); if (tokenCache == null) { tokenCache = await ApiEvents.GetToken(); HttpContext.Cache.Add("access_token", tokenCache, null, DateTime.Now.AddSeconds(tokenCache.expires_in), Cache.NoSlidingExpiration, CacheItemPriority.AboveNormal, null); } return(tokenCache.access_token); }
/// <summary> /// Create a new event and redirects to Index view if successfull or show error if not. /// </summary> public async Task <ActionResult> Create(EventModel model) { var token = await GetTokenCache(); var result = await ApiEvents.CreateEvent(token, model); if (result.statusCode != 0) { foreach (var item in result.details) { ModelState.AddModelError(string.Empty, item); } return(View()); } else { return(RedirectToAction("Index")); } }
/// <summary>Instantiates new MangoPayApi object.</summary> public MangoPayApi() { // default config setup Config = new Configuration(); OAuthTokenManager = new AuthorizationTokenManager(this); // API managers initialization AuthenticationManager = new ApiOAuth(this); Clients = new ApiClients(this); Users = new ApiUsers(this); Wallets = new ApiWallets(this); PayIns = new ApiPayIns(this); PayOuts = new ApiPayOuts(this); Refunds = new ApiRefunds(this); Transfers = new ApiTransfers(this); CardRegistrations = new ApiCardRegistrations(this); Cards = new ApiCards(this); Events = new ApiEvents(this); CardPreAuthorizations = new ApiCardPreAuthorizations(this); Hooks = new ApiHooks(this); }
private static void LoadFinalMods() { var registeredMods = ModRegistry.GetRegisteredItems(); foreach (var mod in registeredMods.Where(n => n.ModState == ModState.Unloaded)) { Log.Verbose($"Loading mod: {mod.Name} by {mod.Author}"); try { ApiEvents.InvokeModPreLoad(mod); mod.OnBeforeLoaded(); if (mod.HasContent) { mod.LoadContent(); } if (mod.HasDll) { mod.LoadModDll(); } mod.ModState = ModState.Loaded; mod.OnAfterLoaded(); Log.Success($"Loaded Mod: {mod.Name} v{mod.Version} by {mod.Author}"); ApiEvents.InvokeModPostLoad(mod); } catch (Exception ex) { mod.ModState = ModState.Errored; Log.Exception($"Error loading mod {mod.Name} by {mod.Author}", ex); ApiEvents.InvokeModLoadError(mod); } } // See ReferenceFix.Data.BuildXnaTypeCache() // Since mod loading is done we don't need this anymore. // There are a lot of types, so might as well save the memory. ReferenceHelper.XnaTypes.Clear(); }
private static void LoadFinalMods() { Func <ModManifest[], List <ModManifest>, List <ModManifest>, List <ModManifest>, ModManifest[]> getModsForThisPass = (mods, modsLoaded, modsErrored, modsProcessed) => { Func <ModDependency, bool> isDependencyLoaded = dependency => { if (dependency.IsRequired) { return(modsLoaded.Any(ld => ld.UniqueId.Equals(dependency.UniqueId))); } var dependentMod = mods.FirstOrDefault(n => n.UniqueId.Equals(dependency.UniqueId)); return(dependentMod?.ModState != ModState.Unloaded); }; return (mods.Where( n => n.ModState == ModState.Unloaded && (n.Dependencies == null || n.Dependencies.All(d => isDependencyLoaded(d)))) .ToArray()); }; var modsToLoad = ModRegistry.GetRegisteredItems().Where(n => n.IsFarmhandMod).Cast <ModManifest>().ToArray(); var loadedMods = new List <ModManifest>(); var erroredMods = new List <ModManifest>(); var processedMods = new List <ModManifest>(); var modsThisPass = getModsForThisPass(modsToLoad, loadedMods, erroredMods, processedMods); while (modsThisPass.Any()) { foreach (var mod in modsThisPass) { processedMods.Add(mod); if (mod.ModState == ModState.DependencyLoadError) { erroredMods.Add(mod); continue; } Log.Verbose($"Loading mod: {mod.Name} by {mod.Author}"); try { ApiEvents.InvokeModPreLoad(mod); mod.OnBeforeLoaded(); if (mod.HasContent) { mod.LoadContent(); } if (mod.HasDll) { if (!mod.LoadModDll()) { mod.ModState = ModState.Errored; ApiEvents.InvokeModLoadError(mod); erroredMods.Add(mod); BubbleDependencyLoadError(mod); continue; } } mod.ModState = ModState.Loaded; mod.OnAfterLoaded(); Log.Success($"Loaded Mod: {mod.Name} v{mod.Version} by {mod.Author}"); ApiEvents.InvokeModPostLoad(mod); loadedMods.Add(mod); } catch (Exception ex) { mod.ModState = ModState.Errored; Log.Exception($"Error loading mod {mod.Name} by {mod.Author}", ex); ApiEvents.InvokeModLoadError(mod); erroredMods.Add(mod); BubbleDependencyLoadError(mod); break; } } modsThisPass = getModsForThisPass(modsToLoad, loadedMods, erroredMods, processedMods); } // See ReferenceFix.Data.BuildXnaTypeCache() // Since mod loading is done we don't need this anymore. // There are a lot of types, so might as well save the memory. ReferenceHelper.XnaTypes.Clear(); }
public static void registerEventHandler(ApiEvents eventhandler) { eventtrigger = eventhandler; }