public V1ClusterRole GenerateManagerRbac(ResourceLocator resourceTypeService) { var entityRbacPolicyRules = resourceTypeService.GetAttributes <EntityRbacAttribute>() .SelectMany(attribute => attribute.CreateRbacPolicies()); var genericRbacPolicyRules = resourceTypeService.GetAttributes <GenericRbacAttribute>() .Select(attribute => attribute.CreateRbacPolicy()); var rules = entityRbacPolicyRules.Concat(genericRbacPolicyRules).ToList(); if (_hasWebhooks) { var servicePolicies = new EntityRbacAttribute( typeof(V1Service), typeof(V1ValidatingWebhookConfiguration)) { Verbs = RbacVerb.Get | RbacVerb.Create | RbacVerb.Update | RbacVerb.Patch, }.CreateRbacPolicies(); rules = rules.Concat(servicePolicies).ToList(); } return(new V1ClusterRole( null, $"{V1ClusterRole.KubeGroup}/{V1ClusterRole.KubeApiVersion}", V1ClusterRole.KubeKind, new V1ObjectMeta { Name = "operator-role" }, new List <V1PolicyRule>(rules))); }
public void test_write_standard_roundTrip() { CharSource source = ResourceLocator.ofClasspath("com/opengamma/strata/loader/csv/sensitivity-standard.csv").CharSource; ValueWithFailures <ListMultimap <string, CurveSensitivities> > parsed1 = LOADER.parse(ImmutableList.of(source)); assertEquals(parsed1.Failures.size(), 0, parsed1.Failures.ToString()); assertEquals(parsed1.Value.size(), 1); IList <CurveSensitivities> csensList1 = parsed1.Value.get(""); assertEquals(csensList1.Count, 1); CurveSensitivities csens1 = csensList1[0]; StringBuilder buf = new StringBuilder(); WRITER.write(csens1, buf); string content = buf.ToString(); ValueWithFailures <ListMultimap <string, CurveSensitivities> > parsed2 = LOADER.parse(ImmutableList.of(CharSource.wrap(content))); assertEquals(parsed2.Failures.size(), 0, parsed2.Failures.ToString()); assertEquals(parsed2.Value.size(), 1); IList <CurveSensitivities> csensList2 = parsed2.Value.get(""); assertEquals(csensList2.Count, 1); CurveSensitivities csens2 = csensList2[0]; assertEquals(csens2, csens1); }
private IObservable <string> makeFileObservable() { FileInfo f = new FileInfo(ResourceLocator.Path(typeof(Resources), "rec-center-hourly.csv")); try { List <string> arr = new List <string>(); using (StreamReader sr = new StreamReader(f.OpenRead())) { string line = null; while (!sr.EndOfStream) { arr.Add(sr.ReadLine()); } } //Observable <?> o = Observable.from(Files.lines(f.toPath(), Charset.forName("UTF-8")).toArray()); return(arr.ToObservable()); } catch (Exception e) { Console.WriteLine(e); } return(null); }
private TextureManager(params String[] filePrefix) { Prefix = filePrefix; var tileNames = Archive.FindAll<Bitmap>(filePrefix, true); TexArray = new Texture2DArray(8, 8, tileNames.OrderBy(x => x.ToString()).ToArray()); }
public CustomTextBox() { TextWrapping = TextWrapping.Wrap; AcceptsTab = true; AcceptsReturn = true; ResourceLocator.SetColorScheme(Application.Current.Resources, ResourceLocator.DarkColorScheme); }
/// <summary>Builds the display name.</summary> /// <returns>Display name.</returns> protected virtual string BuildName() { var name = property.DisplayName; foreach (Attribute attribute in property.Attributes) { // If we find a SRName attribute, we don't want to continue searching. // We also override an existing Name attribute. if (attribute is SRNameAttribute) { string resName = ((SRNameAttribute)attribute).ResourceName; var result = ResourceLocator.GetString(resName, ownerObjectAssembly); if (!string.IsNullOrEmpty(result)) { name = result; break; } } if (attribute is NameAttribute) { name = ((NameAttribute)attribute).Name; } } return(name); }
public override void Execute() { Guard.ArgumentValue(Command == null && string.IsNullOrEmpty(CommandName), "Command", COMMANDORNAME_MUSTBE_SPECIFIED); if (!this.IsEnabled) { return; } var _command = Command ?? ResourceLocator.GetResource <ICommand>(CommandName); Guard.ArgumentNotNull(_command, "Command", COMMAND_NOT_RESOLVED, CommandName); if (!string.IsNullOrEmpty(SiteArea)) { SiteMapService.InitializeSiteArea(SiteArea, (b) => { if (!b) { throw new SiteMapException(string.Format(AREA_COULDNOT_INITIALIZE, SiteArea, CommandName), SiteArea); } if (_command.CanExecute(CommandParameter)) { _command.Execute(CommandParameter); } }); } else { if (_command.CanExecute(CommandParameter)) { _command.Execute(CommandParameter); } } }
public async void Run(IBackgroundTaskInstance taskInstance) { var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail; if (details != null) { string arguments = details.Argument; var args = arguments.Split(';'); if (args[0] == MarkReadAction) { try { ResourceLocator.RegisterAppDataServiceAdapter(new ApplicationDataServiceService()); ResourceLocator.RegisterPasswordVaultAdapter(new PasswordVaultProvider()); ResourceLocator.RegisterMessageDialogAdapter(new MessageDialogProvider()); Credentials.Init(); } catch (Exception) { //we may be already up and running, pure voodoo } var deff = taskInstance.GetDeferral(); await MalNotificationsQuery.MarkNotifiactionsAsRead(new MalNotification(args[1])); deff.Complete(); } } }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // Register Log4Net DataTemplates var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetDocViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetViewModel), template); template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetMessageToolViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetMessageViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetMessageToolViewModel), template); template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(Log4NetToolViewModel)).GetName().Name, "DataTemplates/Log4NetViewDataTemplate.xaml", "Log4NetToolViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(Log4NetToolViewModel), template); return(paneSel); }
/// <summary> /// Gets all album folder images and caches them in the <see cref="IFanArtCache"/> service. /// </summary> /// <param name="nativeSystemId">The native system id of the media item.</param> /// <param name="albumDirectory"><see cref="ResourcePath>"/> that points to the album directory.</param> /// <param name="albumMediaItemId">Id of the media item.</param> /// <param name="title">Title of the media item.</param> /// <param name="artists">List of artists.</param> /// <returns><see cref="Task"/> that completes when the images have been cached.</returns> protected async Task ExtractAlbumFolderFanArt(string nativeSystemId, ResourcePath albumDirectory, Guid albumMediaItemId, string title, IList <Tuple <Guid, string> > artists) { try { FanArtPathCollection paths = null; IList <ResourcePath> potentialArtistImages = null; using (IResourceAccessor accessor = new ResourceLocator(nativeSystemId, albumDirectory).CreateAccessor()) if (accessor is IFileSystemResourceAccessor fsra) { paths = GetAlbumFolderFanArt(fsra); //See if there's an actor fanart directory and try and get any actor fanart if (artists != null && artists.Count > 0 && fsra.ResourceExists(".artists")) { using (IFileSystemResourceAccessor actorsDirectory = fsra.GetResource(".artists")) potentialArtistImages = LocalFanartHelper.GetPotentialFanArtFiles(actorsDirectory); } } if (paths != null) { await SaveFolderImagesToCache(nativeSystemId, paths, albumMediaItemId, title).ConfigureAwait(false); } if (potentialArtistImages != null) { await SavePersonFolderImages(nativeSystemId, potentialArtistImages, artists).ConfigureAwait(false); } } catch (Exception ex) { Logger.Warn("AudioFanArtHandler: Exception while reading folder images for '{0}'", ex, albumDirectory); } }
private void AdapterOnDeviceDiscovered(object sender, DeviceEventArgs e) { _spotTimes[e.Device.Id] = DateTime.UtcNow; var device = ScannedDeviceViewModels.FirstOrDefault(model => model.ScannedDevice.Device.Id == e.Device.Id); if (device != null) { device.SignalStrength = e.Device.Rssi; } else { using (var scope = ResourceLocator.ObtainScope()) { ScannedDeviceViewModels.Add(scope.TypedResolve <ScannedDeviceViewModel>(new ScannedDevice { Device = e.Device, Guid = e.Device.Id, MacAddress = _bluetoothDeviceDataExtractor.GetMacAddressFromDevice(e.Device), AdvertisedName = e.Device.Name, SignalStrength = e.Device.Rssi })); } } }
protected override async void OnStartup(StartupEventArgs e) { try { ResourceLocator.RegisterDependencies(AdapterDelegate); } catch (Exception) { await new MessageBoxProvider().ShowMessageBoxOk("Unable to find one or more plugins, terminating.", "Error"); Current.Shutdown(); } try { _configuration = JsonConvert.DeserializeObject <AppConfiguration>(File.ReadAllText(@"configuration.json")); } catch (Exception ex) { _configuration = new AppConfiguration { LogErrors = true, LogWarning = true, LogInfo = false, }; ResourceLocator.Logger.Log($"Unable to find configuration file, using default one.\n{ex}", LogSeverity.Warning); } base.OnStartup(e); }
/// <summary> /// Gets all collection folder images and caches them in the <see cref="IFanArtCache"/> service. /// </summary> /// <param name="mediaItemLocator"><see cref="IResourceLocator>"/> that points to the file.</param> /// <param name="collectionMediaItemId">Id of the series media item.</param> /// <param name="title">Title of the media item.</param> /// <returns><see cref="Task"/> that completes when the images have been cached.</returns> protected async Task ExtractCollectionFolderFanArt(IResourceLocator mediaItemLocator, Guid collectionMediaItemId, string title) { var collectionDirectory = ResourcePathHelper.Combine(mediaItemLocator.NativeResourcePath, "../../"); var centralCollectionDirectory = ResourcePathHelper.Combine(mediaItemLocator.NativeResourcePath, "../../../" + MOVIESET_FANART_FOLDER); var centralCollectionDirectory2 = ResourcePathHelper.Combine(mediaItemLocator.NativeResourcePath, "../../" + MOVIESET_FANART_FOLDER); var movieDirectory = ResourcePathHelper.Combine(mediaItemLocator.NativeResourcePath, "../"); try { FanArtPathCollection paths = new FanArtPathCollection(); using (IResourceAccessor accessor = new ResourceLocator(mediaItemLocator.NativeSystemId, centralCollectionDirectory).CreateAccessor()) paths.AddRange(GetCollectionFolderFanArt(accessor as IFileSystemResourceAccessor)); using (IResourceAccessor accessor = new ResourceLocator(mediaItemLocator.NativeSystemId, centralCollectionDirectory2).CreateAccessor()) paths.AddRange(GetCollectionFolderFanArt(accessor as IFileSystemResourceAccessor)); using (IResourceAccessor accessor = new ResourceLocator(mediaItemLocator.NativeSystemId, collectionDirectory).CreateAccessor()) paths.AddRange(GetCollectionFolderFanArt(accessor as IFileSystemResourceAccessor)); using (IResourceAccessor accessor = new ResourceLocator(mediaItemLocator.NativeSystemId, movieDirectory).CreateAccessor()) paths.AddRange(GetMovieFolderCollectionFanArt(accessor as IFileSystemResourceAccessor)); await SaveFolderImagesToCache(mediaItemLocator.NativeSystemId, paths, collectionMediaItemId, title).ConfigureAwait(false); } catch (Exception ex) { Logger.Warn("MovieFanArtHandler: Exception while reading folder images for '{0}'", ex, collectionDirectory); } }
private void ChangeTheme() { this.Dispatcher.Invoke(() => { // Get system app theme and set app theme based on values RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"); if (int.TryParse(reg.GetValue("AppsUseLightTheme").ToString(), out int result)) { Log.Information("Got selected theme from user, applying."); if (result == 0) { Log.Information("Applying dark mode."); TitleBarBackground = System.Windows.Media.Brushes.Black; ResourceLocator.SetColorScheme(Application.Current.Resources, ResourceLocator.DarkColorScheme); } else { Log.Information("Applying light mode."); TitleBarBackground = System.Windows.Media.Brushes.White; ResourceLocator.SetColorScheme(Application.Current.Resources, ResourceLocator.LightColorScheme); } } reg.Close(); reg.Dispose(); }); }
/// <summary> /// Finds the editor template. /// </summary> /// <returns>DataTemplate the Editor should be applied.</returns> protected virtual DataTemplate FindEditorTemplate() { if (Entry == null) { return(null); } var editor = Entry.Editor; if (editor == null) { return(null); } var template = editor.InlineTemplate as DataTemplate; if (template != null) { return(template); } if (editor.InlineTemplate == null) { Console.Out.WriteLine($"Can't find template for {Entry.Name}"); return(null); } return(ResourceLocator.GetResource(editor.InlineTemplate) as DataTemplate); }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // FileStatsView var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(FileStatsViewModel)).GetName().Name, "DataTemplates/FileStatsViewDataTemplate.xaml", "FileStatsViewTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(FileStatsViewModel), template); // RecentFiles template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(RecentFilesTWViewModel)).GetName().Name, "DataTemplates/RecentFilesViewDataTemplate.xaml", "RecentFilesViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(RecentFilesTWViewModel), template); // FileExplorer template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(FileExplorerViewModel)).GetName().Name, "DataTemplates/FileExplorerViewDataTemplate.xaml", "FileExplorerViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(FileExplorerViewModel), template); return(paneSel); }
public Task TestExtractVideoFolderFanArt(Guid mediaItemId, ResourcePath path) { IResourceLocator locator = new ResourceLocator("test", path); var aspects = new Dictionary <Guid, IList <MediaItemAspect> >(); return(ExtractFolderFanArt(locator, mediaItemId, "video", aspects)); }
/// <summary> Initializes the Velocity Runtime with properties file. /// The properties file may be in the file system proper, /// or the properties file may be in the classpath. /// </summary> private void setDefaultProperties() { //UPGRADE_ISSUE: Class 'java.lang.ClassLoader' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"' //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassgetClassLoader"' // ClassLoader classLoader = this.GetType().getClassLoader(); // // try { // //UPGRADE_TODO: Method java.lang.ClassLoader.getResourceAsStream was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1095"' // System.IO.Stream inputStream = classLoader.getResourceAsStream(NVelocity.Runtime.RuntimeConstants_Fields.DEFAULT_RUNTIME_PROPERTIES); // FileInfo file = new FileInfo(NVelocity.Runtime.RuntimeConstants_Fields.DEFAULT_RUNTIME_PROPERTIES); // // configuration.Load(inputStream); // // info("Default Properties File: " + new System.IO.FileInfo(NVelocity.Runtime.RuntimeConstants_Fields.DEFAULT_RUNTIME_PROPERTIES).FullName); // } // catch (System.IO.IOException ioe) { // System.Console.Error.WriteLine("Cannot get Velocity Runtime default properties!"); // } // TODO - there might be a better way try { ResourceLocator file = new ResourceLocator(RuntimeConstants_Fields.DEFAULT_RUNTIME_PROPERTIES); configuration.Load(file.OpenRead()); info("Default Properties File: " + file.FullName); } catch (System.Exception ex) { debugOutput.WriteLine("Cannot get NVelocity Runtime default properties!\n" + ex.Message); debugOutput.Flush(); } }
public void test_parse_grid_full() { CharSource source = ResourceLocator.ofClasspath("com/opengamma/strata/loader/csv/sensitivity-grid-full.csv").CharSource; assertEquals(LOADER_CCP.isKnownFormat(source), true); ValueWithFailures <ListMultimap <string, CurveSensitivities> > test = LOADER_CCP.parse(ImmutableList.of(source)); assertEquals(test.Failures.size(), 0, test.Failures.ToString()); IList <CurveSensitivities> list0 = test.Value.get("SCHEME~TR1"); assertEquals(list0.Count, 1); CurveSensitivities csens0 = list0[0]; assertEquals(csens0.Id, StandardId.of("SCHEME", "TR1")); assertEquals(csens0.Info.getAttribute(CCP_ATTR), "LCH"); assertEquals(csens0.TypedSensitivities.size(), 2); assertSens(csens0, ZERO_RATE_DELTA, "GBCURVE", GBP, "1M, 3M, 6M", 1, 2, 3); assertSens(csens0, ZERO_RATE_GAMMA, "GBCURVE", GBP, "1M, 3M, 6M", 4, 5, 6); IList <CurveSensitivities> list1 = test.Value.get("OG-Sensitivity~TR2"); assertEquals(list1.Count, 1); CurveSensitivities csens1 = list1[0]; assertEquals(csens1.Id, StandardId.of("OG-Sensitivity", "TR2")); assertEquals(csens1.Info.getAttribute(CCP_ATTR), "CME"); assertEquals(csens1.TypedSensitivities.size(), 1); assertSens(csens1, ZERO_RATE_DELTA, "GBCURVE", GBP, "1M, 3M, 6M", 7, 8, 9); }
/// <summary> /// Gets all season folder images and caches them in the <see cref="IFanArtCache"/> service. /// </summary> /// <param name="mediaItemLocator"><see cref="IResourceLocator>"/> that points to the file.</param> /// <param name="seasonMediaItemId">Id of the season media item.</param> /// <param name="title">Title of the media item.</param> /// <param name="seasonNumber">Season number.</param> /// <param name="actors">Collection of actor ids and names.</param> /// <returns><see cref="Task"/> that completes when the images have been cached.</returns> protected async Task ExtractSeasonFolderFanArt(IResourceLocator mediaItemLocator, Guid seasonMediaItemId, string title, int?seasonNumber, IList <Tuple <Guid, string> > actors) { var seasonDirectory = ResourcePathHelper.Combine(mediaItemLocator.NativeResourcePath, "../"); try { FanArtPathCollection paths = null; IList <ResourcePath> potentialActorImages = null; using (IResourceAccessor accessor = new ResourceLocator(mediaItemLocator.NativeSystemId, seasonDirectory).CreateAccessor()) if (accessor is IFileSystemResourceAccessor fsra) { paths = GetSeasonFolderFanArt(fsra, seasonNumber); //See if there's an actor fanart directory and try and get any actor fanart if (actors != null && actors.Count > 0 && fsra.ResourceExists(".actors")) { using (IFileSystemResourceAccessor actorsDirectory = fsra.GetResource(".actors")) potentialActorImages = LocalFanartHelper.GetPotentialFanArtFiles(actorsDirectory); } } if (paths != null) { await SaveFolderImagesToCache(mediaItemLocator.NativeSystemId, paths, seasonMediaItemId, title).ConfigureAwait(false); } if (potentialActorImages != null) { await SavePersonFolderImages(mediaItemLocator.NativeSystemId, potentialActorImages, actors).ConfigureAwait(false); } } catch (Exception ex) { Logger.Warn("SeriesFanArtHandler: Exception while reading folder images for '{0}'", ex, seasonDirectory); } }
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) { AttackMissView = new AttackMissView(this); ACTTabControl = new ACTTabControl(this); pluginScreenSpace.Text = Assembly.GetExecutingAssembly().GetName().Name; pluginScreenSpace.Controls.Add(ACTTabControl); ACTTabControl.InitializeSettings(); Settings = new DataManager(this); Settings.Load(); ACTTabControl.Show(); String path = ResourceLocator.findResourcePath("resources/wav/miss.wav"); if (path != null) { soundPlayer = new SoundPlayer(path); } ActGlobals.oFormActMain.AfterCombatAction += AfterCombatAction; ActGlobals.oFormActMain.OnCombatStart += CombatStarted; ActGlobals.oFormActMain.OnLogLineRead += OnLogLineRead; }
TViewModel ICustomDialogDependencyResolver.Resolve <TViewModel>() { using (var scope = ResourceLocator.ObtainScope()) { return(scope.Resolve <TViewModel>()); } }
//------------------------------------------------------------------------- /// <summary> /// Loads one or more CSV format curve files for a specific date. /// <para> /// Only those quotes that match the specified date will be loaded. /// </para> /// <para> /// If the files contain a duplicate entry an exception will be thrown. /// /// </para> /// </summary> /// <param name="marketDataDate"> the curve date to load </param> /// <param name="groupsResource"> the curve groups CSV resource </param> /// <param name="settingsResource"> the curve settings CSV resource </param> /// <param name="curveValueResources"> the CSV resources for curves </param> /// <returns> the loaded curves, mapped by an identifying key </returns> /// <exception cref="IllegalArgumentException"> if the files contain a duplicate entry </exception> public static ImmutableList <RatesCurveGroup> load(LocalDate marketDataDate, ResourceLocator groupsResource, ResourceLocator settingsResource, ICollection <ResourceLocator> curveValueResources) { ICollection <CharSource> curveCharSources = curveValueResources.Select(r => r.CharSource).ToList(); ListMultimap <LocalDate, RatesCurveGroup> map = parse(d => marketDataDate.Equals(d), groupsResource.CharSource, settingsResource.CharSource, curveCharSources); return(ImmutableList.copyOf(map.get(marketDataDate))); }
public override void OnReceive(Context context, Intent intent) { try { try { ResourceLocator.RegisterAppDataServiceAdapter(new ApplicationDataServiceService()); } catch (Exception) { //Log.Debug("MALCLient", "AppData present."); } try { ResourceLocator.RegisterPasswordVaultAdapter(new PasswordVaultProvider()); } catch (Exception) { //Log.Debug("MALCLient", "Vault present."); } Credentials.Init(); //Log.Debug("MALCLient", "Setting up notification fetching."); new NotificationTaskManager().StartTask(BgTasks.Notifications, context); new NotificationTaskManager().StartTask(BgTasks.AiredNotification, context); } catch (Exception) { //It can throw error on startup of OS... I really don't want that no matter what. } }
/// <summary> /// Register viewmodel types with <seealso cref="DataTemplate"/> for a view /// and return all definitions with a <seealso cref="PanesTemplateSelector"/> instance. /// </summary> /// <param name="paneSel"></param> /// <returns></returns> private PanesTemplateSelector RegisterDataTemplates(PanesTemplateSelector paneSel) { // StartPageView var template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(StartPageViewModel)).GetName().Name, "DataTemplates/StartPageViewDataTemplate.xaml", "StartPageViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(StartPageViewModel), template); //EdiView template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(EdiViewModel)).GetName().Name, "DataTemplates/EdiViewDataTemplate.xaml", "EdiViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(EdiViewModel), template); // MiniUml template = ResourceLocator.GetResource <DataTemplate>( Assembly.GetAssembly(typeof(MiniUmlViewModel)).GetName().Name, "DataTemplates/MiniUMLViewDataTemplate.xaml", "MiniUMLViewDataTemplate") as DataTemplate; paneSel.RegisterDataTemplate(typeof(MiniUmlViewModel), template); return(paneSel); }
/// <summary> /// Gets all rates curves. /// </summary> /// <returns> the map of all rates curves </returns> public virtual SortedDictionary <LocalDate, RatesCurveGroup> loadAllRatesCurves() { if (!subdirectoryExists(CURVES_DIR)) { throw new System.ArgumentException("No rates curves directory found"); } ResourceLocator curveGroupsResource = getResource(CURVES_DIR, CURVES_GROUPS_FILE); if (curveGroupsResource == null) { throw new System.ArgumentException(Messages.format("Unable to load rates curves: curve groups file not found at {}/{}", CURVES_DIR, CURVES_GROUPS_FILE)); } ResourceLocator curveSettingsResource = getResource(CURVES_DIR, CURVES_SETTINGS_FILE); if (curveSettingsResource == null) { throw new System.ArgumentException(Messages.format("Unable to load rates curves: curve settings file not found at {}/{}", CURVES_DIR, CURVES_SETTINGS_FILE)); } ListMultimap <LocalDate, RatesCurveGroup> curveGroups = RatesCurvesCsvLoader.loadAllDates(curveGroupsResource, curveSettingsResource, RatesCurvesResources); // There is only one curve group in the market data file so this will always succeed IDictionary <LocalDate, RatesCurveGroup> curveGroupMap = Maps.transformValues(curveGroups.asMap(), groups => groups.GetEnumerator().next()); return(new SortedDictionary <>(curveGroupMap)); }
//------------------------------------------------------------------------- public void test_parse_list() { CharSource source = ResourceLocator.ofClasspath("com/opengamma/strata/loader/csv/sensitivity-list.csv").CharSource; assertEquals(LOADER.isKnownFormat(source), true); ValueWithFailures <ListMultimap <string, CurveSensitivities> > test = LOADER.parse(ImmutableList.of(source)); assertEquals(test.Failures.size(), 0, test.Failures.ToString()); assertEquals(test.Value.size(), 1); IList <CurveSensitivities> list = test.Value.get(""); assertEquals(list.Count, 1); CurveSensitivities csens0 = list[0]; assertEquals(csens0.TypedSensitivities.size(), 3); string tenors = "1D, 1W, 2W, 1M, 3M, 6M, 12M, 2Y, 5Y, 10Y"; assertSens(csens0, ZERO_RATE_DELTA, "GBP", GBP, tenors, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); assertSens(csens0, ZERO_RATE_DELTA, "GBP-LIBOR", GBP, tenors, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); assertSens(csens0, ZERO_RATE_GAMMA, "GBP", GBP, tenors, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1); assertSens(csens0, ZERO_RATE_GAMMA, "GBP-LIBOR", GBP, tenors, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1); assertSens(csens0, OTHER, "GBP", GBP, tenors, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0); assertSens(csens0, OTHER, "GBP-LIBOR", GBP, tenors, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0); }
public ushort GetIndex(ResourceLocator namePrefix, params String[] nameSuffix) { var joined = new String[namePrefix.Length + nameSuffix.Length]; Array.Copy(namePrefix, joined, namePrefix.Length); Array.Copy(nameSuffix, 0, joined, namePrefix.Length, nameSuffix.Length); return GetIndex(joined); }
public Face(JObject obj, Dictionary<String, ResourceLocator> skin) { Texture = skin[(String) obj["texture"]]; Vertices = ((JArray) obj["verts"]) .Select(x => new Vertex((JObject) x)) .ToArray(); }
/// <summary> /// Asynchronously saves the folder image with the specified path to the specified directory. /// </summary> /// <param name="nativeSystemId">The native system id of the path.</param> /// <param name="path">Path to the image to save.</param> /// <param name="saveDirectory">Directory to save the image.</param> /// <returns>A <see cref="Task"/> that completes when the image has been saved.</returns> protected async Task <bool> TrySaveFolderImage(string nativeSystemId, ResourcePath path, string saveDirectory) { string savePath = Path.Combine(saveDirectory, "Folder." + ResourcePathHelper.GetFileName(path.ToString())); try { if (File.Exists(savePath)) { return(false); } using (IResourceAccessor accessor = new ResourceLocator(nativeSystemId, path).CreateAccessor()) if (accessor is IFileSystemResourceAccessor fsra) { using (Stream ms = fsra.OpenRead()) using (FileStream fs = File.OpenWrite(savePath)) await ms.CopyToAsync(fs).ConfigureAwait(false); return(true); } } catch (Exception ex) { // Decoding of invalid image data can fail, but main MediaItem is correct. Logger.Warn("{0}: Error saving folder image to path '{1}'", ex, _metadata.Name, savePath); } return(false); }
TViewModel IViewModelResolver.Resolve <TViewModel>() { using (var scope = ResourceLocator.ObtainScope()) { return(scope.Resolve <TViewModel>()); } }
// load quotes private void loadQuotes(ImmutableMarketDataBuilder builder, LocalDate marketDataDate) { if (!subdirectoryExists(QUOTES_DIR)) { log.debug("No quotes directory found"); return; } ResourceLocator quotesResource = getResource(QUOTES_DIR, QUOTES_FILE); if (quotesResource == null) { log.error("Unable to load quotes: quotes file not found at {}/{}", QUOTES_DIR, QUOTES_FILE); return; } try { IDictionary <QuoteId, double> quotes = QuotesCsvLoader.load(marketDataDate, quotesResource); builder.addValueMap(quotes); } catch (Exception ex) { log.error("Error loading quotes", ex); } }
/// <summary> /// Load a properties file from the classpath /// </summary> /// <param name="propertiesFile">the properties file to load.</param> /// <returns>a properties instance loaded with the properties from /// the file. If no file can be found it returns an empty instance. /// </returns> protected internal virtual ExtendedProperties loadFromClassPath(String propertiesFile) { ExtendedProperties properties = new ExtendedProperties(); try { // This is a hack for now to make sure that properties // files referenced in the filesystem work in // a JAR file. We have to deprecate the use // of $generator.templatePath in templates first // and this hack will allow those same templates // that use $generator.templatePath to work in // JAR files. if (propertiesFile.StartsWith("$generator")) { propertiesFile = propertiesFile.Substring("$generator.templatePath/".Length); } ResourceLocator rl = new ResourceLocator(propertiesFile); Stream inputStream = rl.OpenRead(); properties.Load(inputStream); } catch (System.IO.IOException) { // do nothing } return(properties); }
/// <summary> /// Sets the roof index of a rectangle of tiles to build a roof /// </summary> /// <param name="x">Horizontal start position</param> /// <param name="y">Vertical start position</param> /// <param name="width">Width of the roof</param> /// <param name="depth">Depth of the roof</param> /// <param name="height">Height of the roof from the ground</param> /// <param name="texture">Tile texture name</param> /// <param name="slant">Direction of slant</param> /// <param name="tiles">Tile array to build the roof in</param> public static void BuildRoof(TileBuilder[,] tiles, int x, int y, int width, int depth, int height, ResourceLocator texture, Face slant = Face.None) { int tw = tiles.GetLength(0); int th = tiles.GetLength(1); for (int i = 0; i < width; ++i) { int tx = x + i; if (tx >= 0 && tx < tw) { for (int j = 0; j < depth; ++j) { int ty = y + j; if (ty >= 0 && ty < th) tiles[tx, ty].SetRoof(height, slant, texture); } } } }
private ResourceLocator CreateAccount(SDataService ws, int numContacts, int numOpportunities) { Dictionary<String, object> accValues = new Dictionary<string, object>(); accValues["AccountName"] = "Test Account"; ResourceLocator account = CreateResource(ws, "Account", accValues); ResourceLocator[] contactIds = new ResourceLocator[numContacts]; while (numContacts > 0) { contactIds[numContacts - 1] = CreateContact(ws, account.Id); numContacts--; } while (numOpportunities > 0) { CreateOpportunity(ws, account.Id, contactIds); numOpportunities--; } return account; }
private ResourceLocator CreateOpportunity(SDataService ws, String accountId, ResourceLocator[] contactIds) { Dictionary<String, object> oppValues = new Dictionary<string, object>(); oppValues["Account"] = new SDataPayload { Key = accountId }; oppValues["Description"] = "Test Opportunity"; oppValues["Owner"] = new SDataPayload { Key = "SYST00000001" }; SDataPayload[] contacts = new SDataPayload[contactIds.Length]; int i = 0; foreach (ResourceLocator conId in contactIds) { SDataPayload oppCon = new SDataPayload { ResourceName = "OpportunityContact" }; oppCon.Values["Contact"] = new SDataPayload { Key = conId.Id }; contacts[i++] = oppCon; } oppValues["OpportunityContacts"] = contacts; return CreateResource(ws, "Opportunity", oppValues, "opportunities"); }
/// <summary> /// Sets the wall indices of a row of adjacent tiles to build a wall /// </summary> /// <param name="x">Horizontal position of the wall</param> /// <param name="y">Vertical position of the wall</param> /// <param name="face">Direction the exterior of the wall is facing</param> /// <param name="width">Width of the wall</param> /// <param name="height">Height of the wall</param> /// <param name="inTexture">Interior tile texture name</param> /// <param name="exTexture">Exterior tile texture name</param> /// <param name="tiles">Tile array to build the wall in</param> public static void BuildWall(TileBuilder[,] tiles, int x, int y, Face face, int width, int height, ResourceLocator inTexture, ResourceLocator exTexture) { BuildWall(tiles, x, y, face, width, 0, height, inTexture, exTexture); }
/// <summary> /// Sets the wall indices of a row of adjacent tiles to build a wall /// </summary> /// <param name="x">Horizontal position of the wall</param> /// <param name="y">Vertical position of the wall</param> /// <param name="face">Direction the exterior of the wall is facing</param> /// <param name="width">Width of the wall</param> /// <param name="offset">Distance from the ground</param> /// <param name="height">Height of the wall</param> /// <param name="inTexture">Interior tile texture name</param> /// <param name="exTexture">Exterior tile texture name</param> /// <param name="tiles">Tile array to build the wall in</param> public static void BuildWall(TileBuilder[,] tiles, int x, int y, Face face, int width, int offset, int height, ResourceLocator inTexture, ResourceLocator exTexture) { int tw = tiles.GetLength(0); int th = tiles.GetLength(1); for (int j = 0; j < width; ++j) { int tx = x + (face == Face.North || face == Face.South ? j : 0); int ty = y + (face == Face.East || face == Face.West ? j : 0); if (tx >= 0 && tx < tw && ty >= 0 && ty < th) for (int i = 0; i < height; ++i) tiles[tx, ty].SetWall(face, i + offset, inTexture); tx += face.GetNormalX(); ty += face.GetNormalY(); if (tx >= 0 && tx < tw && ty >= 0 && ty < th) for (int i = 0; i < height; ++i) tiles[tx, ty].SetWall(face.GetOpposite(), i + offset, exTexture); } }
/// <summary> /// Builds a solid (non hollow) box /// </summary> /// <param name="x">Horizontal position of the box</param> /// <param name="y">Vertical position of the box</param> /// <param name="width">Width of the box</param> /// <param name="depth">Depth of the box</param> /// <param name="height">Height of the box</param> /// <param name="wallTexture">Top tile texture for the box</param> /// <param name="topTexture">Wall tile texture for the box</param> /// <param name="tiles">Tile array to build the box in</param> public static void BuildSolid(TileBuilder[,] tiles, int x, int y, int width, int depth, int height, ResourceLocator wallTexture, ResourceLocator topTexture) { BuildFloor(tiles, x, y, width, depth, height, topTexture); BuildWall(tiles, x - 1, y, Face.East, depth, height, wallTexture); BuildWall(tiles, x, y - 1, Face.South, width, height, wallTexture); BuildWall(tiles, x + width, y, Face.West, depth, height, wallTexture); BuildWall(tiles, x, y + depth, Face.North, width, height, wallTexture); }
private void DeleteResource(SDataService ws, String resourceName, ResourceLocator resourceId) { var sru = new SDataSingleResourceRequest(ws); sru.ResourceKind = resourceName.ToLower() + "s"; sru.ResourceSelector = "'" + resourceId.Id + "'"; sru.Delete(); }
private ResourceLocator[] CreateAccounts(SDataService svc, int numAccounts, int numContacts, int numOpportunities) { ResourceLocator[] createdAccounts = new ResourceLocator[numAccounts]; while (numAccounts > 0) { createdAccounts[numAccounts - 1] = CreateAccount(svc, numContacts, numOpportunities); numAccounts--; } return createdAccounts; }