public ResXViewForm(string fileName) { const int BASEWIDTH = 1000; const int BASEHEIGHT = 250; ClientSize = new Size((BASEWIDTH + 20), BASEHEIGHT + 100); resxFile = new FileInfo(fileName); using (var resxSet = new ResXResourceSet(resxFile.FullName)) { Text = resxSet.GetString("FormTitle"); Icon = (Icon)resxSet.GetObject("ShieldIcon"); } const int margin = 10; var resList = new ListView { Bounds = new Rectangle(new Point(margin, margin), new Size(BASEWIDTH, BASEHEIGHT)), View = View.Details, GridLines = true, }; var columnWidth = (resList.ClientSize.Width / 3); resList.Columns.Add("Resource Name", columnWidth); resList.Columns.Add("Type", columnWidth); resList.Columns.Add("Value", columnWidth); using (var resxReader = new ResXResourceReader(resxFile.FullName)) { foreach (DictionaryEntry entry in resxReader) { var resItem = new ListViewItem((string)entry.Key); resItem.SubItems.Add(entry.Value.GetType().FullName); resItem.SubItems.Add(entry.Value.ToString()); resList.Items.Add(resItem); } } var resxButton = new Button { Text = "Show ResX", Location = new Point(resList.Bounds.Left, resList.Bounds.Bottom + margin) }; resxButton.Click += (sender, args) => Process.Start("Notepad.exe", resxFile.FullName); var exitButton = new Button { Text = "Exit" }; exitButton.Location = new Point(resList.Bounds.Right - exitButton.Width, resList.Bounds.Bottom + margin); exitButton.Click += (sender, args) => Application.Exit(); FormBorderStyle = FormBorderStyle.Sizable; MaximizeBox = true; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Controls.Add(resList); Controls.Add(resxButton); Controls.Add(exitButton); InitializeComponent(); }
/// <summary> /// function to get the value from the resource for a key in Views /// </summary> /// <param name="currentContext"></param> /// <param name="resourceFileName"></param> /// <param name="keyName"></param> /// <returns></returns> public static string GetKeyValue(HttpContext currentContext, string resourceFileName, string keyName) { string keyValue = ""; string sResxPath = GetResourceFilePath(resourceFileName, CultureInfo.CurrentCulture.Name); if (!File.Exists(sResxPath)) { sResxPath = sResxPath.Replace(CultureInfo.CurrentCulture.Name, "en-IN"); } using (ResXResourceSet resxSet = new ResXResourceSet(sResxPath)) { keyValue = resxSet.GetString(keyName); } return keyValue; }
public string getObjectSearchPath(string objectPath) { string objectID = ""; string pageName = getResourceFileName(objectPath); if (pageName != null) { string objectName = getPageObjectName(objectPath); try { ResXResourceSet resxSet = new ResXResourceSet(pageName); objectID = resxSet.GetString(objectName); } catch (Exception e) { //Reporter.Log(ReportLevel.Warn, "Object not found in the given file location : " + pageName + ". <br/> Actual Error : " + e.Message); } } return objectID; }
protected void Page_Load(object sender, EventArgs e) { Ent.Ident = (int)(Session["prestador"]); if (!IsPostBack) // es la primera vez que cargo la pagina // agrego esto porque sino en cada seleccion del combo se recarga la pagina // y vuelve a selected value = 0 { centro.DataSource = ObtenerCentro(); centro.DataValueField = "IdentCentro"; centro.DataTextField = "Nombrecentro"; centro.DataBind(); centro.Items.Insert(0, new ListItem("seleccione el Centro", "")); centro.SelectedIndex = 0; } // recupero el nombre de session prestador Label1.Text = Convert.ToString(Session["nombreprestador"]); using (ResXResourceSet resx = new ResXResourceSet("C:\\punto.net\\logeo\\logeo\\App_GlobalResources\\Resources ar-ES.resx")) { this.Label2.Text = resx.GetString("InicioLabel"); } // obtener parametro 21 SqlConnection dbconn21 = ConexionBd_Operaciones.ObtenerConexion(); SqlCommand msc21 = new SqlCommand("dbo.ObtenerParametro", dbconn21); //parametros de entrada msc21.Parameters.AddWithValue("@parametro", 21); //parametros de salida msc21.Parameters.Add("@valor", SqlDbType.VarChar, 120); msc21.Parameters["@valor"].Direction = ParameterDirection.Output; try { if (dbconn21.State == ConnectionState.Closed) dbconn21.Open(); msc21.CommandType = CommandType.StoredProcedure; msc21.ExecuteNonQuery(); string valorfila21 = msc21.Parameters["@valor"].Value.ToString(); if (valorfila21 == "SI") { si.Visible = true; no.Visible = true; } } catch (Exception exp) { throw (exp); } finally { if (dbconn21.State == ConnectionState.Open) dbconn21.Close(); } }
static IEnumerable<Tuple<string, string>> GetValues(string resxFilePath) { var values = new List<Tuple<string, string>>(); using (var resx = new ResXResourceSet(resxFilePath)) { var en = resx.GetEnumerator(); while (en.MoveNext()) { var name = (string) en.Key; var value = resx .GetString(name) .Replace(Environment.NewLine, " ") .Replace("&", "-"); values.Add(new Tuple<string, string>(name, value)); } } return values.OrderBy(x => x.Item1).ToList(); }
private string GetResourceString(string key) { try { using (var resxSet = new ResXResourceSet(@"SpecificResources\SpecificResource.resx")) { return resxSet.GetString(key); } } catch { return null; } }