internal static string getResourceName(string text) { DictionaryEntry entry = resourceSet.OfType <DictionaryEntry>() .FirstOrDefault(e => e.Value.ToString().Equals(text, StringComparison.OrdinalIgnoreCase)); return(text.Equals(entry.Value.ToString(), StringComparison.OrdinalIgnoreCase) ? entry.Key.ToString() : text); }
/// <summary> /// Função pra iterar sob os Resources e seus respectivos arquivos a serem minificados /// </summary> /// <param name="FileContentSB">StringBuilder esperado para mudança de estados, concatenação com os conteúdos minificados</param> internal void IterateOnResourceRepository(ref StringBuilder fileContentSB) { ResourceSet resourceSet = null; global::System.Resources.ResourceManager[] ResourceManagerArray = new global::System.Resources.ResourceManager[] { }; try { ResourceManagerArray = this._resourceManager.ToArray(); DictionaryEntry[] filesAndContents = null; for (int i = 0; i < ResourceManagerArray.Length; i++) { filesAndContents = new DictionaryEntry[] { }; resourceSet = ResourceManagerArray[i].GetResourceSet(CultureInfo.CurrentUICulture, true, true); filesAndContents = resourceSet.OfType <DictionaryEntry>().OrderBy(x => x.Key).ToArray(); for (int j = 0; j < filesAndContents.Length; j++) { _minifiedOperations.ConcatenateAndMinifieContent(ref fileContentSB, filesAndContents[j].Value.ToString(), true); } } } catch (Exception ex) { throw new Exception("Falha durante acesso ao arquivo de Resources.", ex); } finally { if (null != resourceSet) { resourceSet.Dispose(); } } }
public static void GetDataAccessRules(out Dictionary <int, string> dataAccessRuleIds, out Dictionary <string, string> dataAccessRuleDescriptions) { dataAccessRuleIds = new Dictionary <int, string>(); dataAccessRuleDescriptions = new Dictionary <string, string>(); var ruleId = 0; string ruleName; string ruleDescription; var resourceManager = ResourceProvider.GetResourceManager(ResourceNamespaces.DataAccessRules); ResourceSet resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); foreach (DictionaryEntry entry in resourceSet.OfType <DictionaryEntry>().OrderBy(i => i.Key)) { ruleId++; dataAccessRuleIds.Add(ruleId, entry.Key.ToString()); dataAccessRuleDescriptions.Add(entry.Key.ToString(), entry.Value.ToString()); } }
public SwatchesProvider(IEnumerable <Assembly> assemblies) { var regex = new Regex(@"^themes\/materialdesigncolor\.(?<name>[a-z]+)\.(?<type>primary|accent)\.baml$"); var swatches = new List <Swatch>(); foreach (var assembly in assemblies) { var resourcesName = assembly.GetName().Name + ".g"; var manager = new ResourceManager(resourcesName, assembly); ResourceSet resourceSet = null; try { resourceSet = manager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); } catch (MissingManifestResourceException) { } if (resourceSet != null) { var dictionaryEntries = resourceSet.OfType <DictionaryEntry>().ToList(); var assemblyName = assembly.GetName().Name; swatches.AddRange( dictionaryEntries .Select(x => new { key = x.Key.ToString(), match = regex.Match(x.Key.ToString()) }) .Where(x => x.match.Success && x.match.Groups["name"].Value != "black") .GroupBy(x => x.match.Groups["name"].Value) .Select(x => CreateSwatch ( x.Key, Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "primary")?.key), Read(assemblyName, x.SingleOrDefault(y => y.match.Groups["type"].Value == "accent")?.key) )) .ToList() ); } } Swatches = swatches; }
public SalesforceConnectedServiceProvider() { this.Category = Resources.ConnectedServiceProvider_Category; this.CreatedBy = Resources.ConnectedServiceProvider_CreatedBy; this.Description = Resources.ConnectedServiceProvider_Description; this.Icon = new BitmapImage(new Uri("pack://application:,,/" + Assembly.GetAssembly(this.GetType()).ToString() + ";component/ConnectedService/Views/Resources/ProviderIcon.png")); this.MoreInfoUri = new Uri(Constants.MoreInfoLink); this.Name = Resources.ConnectedServiceProvider_Name; this.Version = typeof(SalesforceConnectedServiceProvider).Assembly.GetName().Version; ResourceSet resourceSet = SupportedProjectTypeStrings.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); IEnumerable <string> supportedProjectTypes = resourceSet .OfType <DictionaryEntry>() .Select(e => e.Value) .OfType <string>() .OrderBy(v => v); foreach (string supportedProjectType in supportedProjectTypes) { this.SupportedProjectTypes.Add(supportedProjectType); } }
async Task InstallApp(string installRoot) { PreInstallTB.Visibility = Visibility.Visible; PreInstallTB.Text = "Идет установка ПО..."; InstallButton.IsEnabled = false; CancelButton.IsEnabled = false; ((Storyboard)InstallButtons.Resources["InstallButtonsDisappearStoryboard"]).Begin(); ((Storyboard)ComponentsLV.Resources["ComponentsLVDisappearStoryboard"]).Begin(); if (!Directory.Exists(CommonVariables.TMPDirPath)) { Directory.CreateDirectory(CommonVariables.TMPDirPath); } foreach (var currentComponent in InstallComponents) { if (currentComponent.Selected) { PreInstallTB.Text = $"Установка \"{currentComponent.DisplayName}\"..."; await Task.Run(() => { currentComponent.InstallLocation = currentComponent.InstallLocation .Replace("INSTALL_ROOT", installRoot); currentComponent.ExecutablePath = currentComponent.ExecutablePath .Replace("INSTALL_LOCATION", currentComponent.InstallLocation); currentComponent.DisplayIcon = currentComponent.DisplayIcon .Replace("INSTALL_LOCATION", currentComponent.InstallLocation); currentComponent.UninstallString = currentComponent.UninstallString .Replace("INSTALL_LOCATION", currentComponent.InstallLocation); var tmpFilename = Path.Combine(CommonVariables.TMPDirPath, currentComponent.ID); File.WriteAllBytes(tmpFilename, (byte[])ResourceSet.GetObject(currentComponent.ID.Replace('.', '_'))); if (!Directory.Exists(currentComponent.InstallLocation)) { Directory.CreateDirectory(currentComponent.InstallLocation); } var zip = ZipStorer.Open(tmpFilename, FileAccess.Read); foreach (var current in zip.ReadCentralDir()) { if (!current.FilenameInZip.EndsWith("\\") && !current.FilenameInZip.EndsWith("/")) { zip.ExtractFile(current, Path.Combine(currentComponent.InstallLocation, current.FilenameInZip)); } } zip.Close(); var componentMarkupResourceName = $"{currentComponent.ID.Replace('.', '_')}_APM"; File.WriteAllBytes(Path.Combine(Directory.GetParent(currentComponent.UninstallString).FullName, componentMarkupResourceName), (byte[])((DictionaryEntry)ResourceSet.OfType <object>().FirstOrDefault(c => ((DictionaryEntry)c).Key.ToString() == componentMarkupResourceName)).Value); File.Copy(MyFileName, currentComponent.UninstallString, true); RegistryManager.CreateApplicationEntry(currentComponent); LNKManager.CreateLinks(currentComponent, Path.Combine(CommonVariables.DesktopPath, $"{currentComponent.DisplayName}.lnk")); }); } } PreInstallTB.Text = "Удаление временных файлов..."; await Task.Run(() => { while (true) { try { Directory.Delete(CommonVariables.TMPDirPath, true); break; } catch (IOException) { Thread.Sleep(100); } } }); PreInstallTB.Text = "Установка успешно завершена!"; await Task.Run(() => Thread.Sleep(2000)); }