本文整理汇总了C#中System.Globalization.CultureInfo类的典型用法代码示例。如果您正苦于以下问题:C# System.Globalization.CultureInfo类的具体用法?C# System.Globalization.CultureInfo怎么用?C# System.Globalization.CultureInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Globalization.CultureInfo类属于命名空间,在下文中一共展示了System.Globalization.CultureInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportTxt
/// <summary>
/// 导出文件为txt
/// </summary>
/// <param name="isdelete">是否删除数据</param>
protected void ExportTxt(bool isdelete)
{
Page.Response.Clear();
Page.Response.Buffer = true;
Page.Response.Charset = "GB2312";
Page.Response.AppendHeader("Content-Disposition", string.Format("attachment;filename=sys_EventLog{0}.csv",DateTime.Now.ToShortDateString()));
Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "text/plain";//设置输出文件类型为txt文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("EventID,E_U_LoginName,E_UserID,E_DateTime,E_ApplicationID,E_A_AppName,E_M_Name,E_M_PageCode,E_From,E_Type,E_IP,E_Record");
sb.Append("\n");
int rCount = 0;
ArrayList lst = BusinessFacade.sys_EventList(new QueryParam(1, int.MaxValue),out rCount);
foreach (sys_EventTable var in lst)
{
sb.AppendFormat("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},\"{11}\"\n", var.EventID,
var.E_U_LoginName,var.E_UserID,var.E_DateTime,var.E_ApplicationID,
var.E_A_AppName,var.E_M_Name,var.E_M_PageCode,var.E_From,
var.E_Type,var.E_IP,var.E_Record
);
}
Page.Response.Write(sb.ToString());
if (isdelete)
{
ClearData();
}
EventMessage.EventWriteDB(2, "导出操作日志!");
Page.Response.End();
}
示例2: ReturnDayOfWeekOnBulgarian
public string ReturnDayOfWeekOnBulgarian(DateTime date)
{
var culture = new System.Globalization.CultureInfo("bg-BG");
var day = culture.DateTimeFormat.GetDayName(date.DayOfWeek);
return day;
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("es-ES");
spanFecha.InnerText = "Garage Nadia - " + DateTime.Now.ToString("dd/MM/yyyy hh:mm");
string tipo = Request.QueryString["tipo"];
if (tipo == "mensual")
{
string mes = Request.QueryString["mes"];
string ano = Request.QueryString["ano"];
string texto = Request.QueryString["texto"];
string detalle = Request.QueryString["detalle"];
spanFiltros.InnerText = "Mes: "+texto+" - Año: "+ano;
divCode.InnerHtml = CONTROLADORA.ControladoraReporteHTML.ReporteGananciasMensual(mes, ano, detalle);
}
if (tipo == "periodo")
{
string desde = Request.QueryString["desde"];
string hasta = Request.QueryString["hasta"];
string detalle = Request.QueryString["detalle"];
spanFiltros.InnerText = "Reporte Desde: " + desde + " - Hasta: " + hasta;
divCode.InnerHtml = CONTROLADORA.ControladoraReporteHTML.ReporteGananciasPeriodo(desde, hasta, detalle);
}
}
示例4: Import
public static Person Import(String input)
{
var parameters = new Dictionary<string, string>();
var data = input.Split(';');
foreach (string item in data)
{
var specyficData = item.Split(':');
parameters[specyficData[0]] = specyficData[1];
}
var person = new Person();
person.NameSurname = parameters["NS"];
IFormatProvider culture = new System.Globalization.CultureInfo("pl-PL", true);
if (parameters.ContainsKey("BD"))
{
person.Birthdate = DateTime.Parse(parameters["BD"], culture);
}
if (parameters.ContainsKey("DD"))
{
person.Deathdate = DateTime.Parse(parameters["DD"], culture);
}
if (parameters.ContainsKey("S"))
{
switch (parameters["S"])
{
case "M": person.Sex = PersonSex.Male; break;
case "F": person.Sex = PersonSex.Female; break;
}
}
return person;
}
示例5: cleanUpPhotos
/// <summary>
/// Remove all photos not referenced by any album
/// David
/// </summary>
/// <returns>Number of photos removed</returns>
public static int cleanUpPhotos()
{
int totalRemoved = 0;
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
List<AllImagesInfo> _allImageInfo = getAllImageInfo();
foreach(string photoPath in Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Photos","*.*",SearchOption.AllDirectories).Where(s=>s.EndsWith(".jpg",true,ci) || s.EndsWith(".png",true,ci) || s.EndsWith(".jpeg",true,ci) || s.EndsWith(".gif",true,ci) || s.EndsWith(".bmp",true,ci)))
{
if (!_allImageInfo.Exists(x => x.path == photoPath))
{
try
{
if (File.Exists(photoPath))
{
File.Delete(photoPath);
totalRemoved++;
}
else
{
throw new Exception("File path does not exist!!");
}
}catch(Exception e){
System.Windows.Forms.MessageBox.Show("An error has occurred trying to remove photos. " + e.Message,"Error",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
}
}
}
return totalRemoved;
}
示例6: GetDayOfTheWeek
// funktions som kontrolerar om väder prognonsernas dag
public string GetDayOfTheWeek(DateTime dateTime, int period)
{
var culture = new System.Globalization.CultureInfo("sv-SE");
if (dateTime.DayOfWeek == DateTime.Now.DayOfWeek && counter != 1)
{
//counter = 1; test
/*
if (dateTime.DayOfWeek == DateTime.Now.AddDays(1).DayOfWeek && period == 0)
{
return "Imorgon";
}*/
counter = 1;
return "Idag";
}
if (dateTime.DayOfWeek == DateTime.Now.AddDays(1).DayOfWeek && period == 0)
{
return "Imorgon";
}
if (period == 0)
{
return culture.DateTimeFormat.GetDayName(dateTime.DayOfWeek).ToString();
}
else
{
return null;
}
}
示例7: Create
public ActionResult Create(Customer cs, FormCollection collection)
{
IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);
cs.CreateDate = DateTime.Parse(collection["CreateDate"], iFP);
var result = CustomerBusiness.Insert(cs);
return PartialView(cs);
}
示例8: NifParser
public NifParser()
{
// Language settings
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
}
示例9: RunBare
// @Override
public override void RunBare()
{
// Do the test with the default Locale (default)
try
{
locale = defaultLocale;
base.RunBare();
}
catch (System.Exception e)
{
System.Console.Out.WriteLine("Test failure of '" + Lucene.Net.TestCase.GetName() + "' occurred with the default Locale " + locale);
throw e;
}
if (testWithDifferentLocales == null || testWithDifferentLocales.Contains(Lucene.Net.TestCase.GetName()))
{
// Do the test again under different Locales
System.Globalization.CultureInfo[] systemLocales = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.InstalledWin32Cultures);
for (int i = 0; i < systemLocales.Length; i++)
{
try
{
locale = systemLocales[i];
base.RunBare();
}
catch (System.Exception e)
{
System.Console.Out.WriteLine("Test failure of '" + Lucene.Net.TestCase.GetName() + "' occurred under a different Locale " + locale); // {{Aroush-2.9}} String junit.framework.TestCase.getName()
throw e;
}
}
}
}
示例10: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
dat = new DataHandler();
// Set the data context of the listbox control to the sample data
DataContext = App.ViewModel;
GoogleAnalytics.EasyTracker.GetTracker().SendView("MainPanaroma");
App.ViewModel.Items.Clear();
txt_REG.Text = (string) dat.getReg();
if (txt_REG.Text == "" || dat.getDob().Equals(""))
{
newUser = true;
}
else {
DateTime dater;
IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR");
String date = (dat.getDob().Insert(2, "/")).Insert(5,"/");
dater = DateTime.Parse(date, culture);
datePicker.Value = dater;
if (dat.isVellore())
chk_Vellore.IsChecked = true;
else
chk_Chennai.IsChecked = true;
//App.ViewModel.isCache = true;
//App.ViewModel.LoadData();
}
}
示例11: getSystemCultureInfo
protected override System.Globalization.CultureInfo getSystemCultureInfo()
{
var netLanguage = "en";
var prefLanguageOnly = "en";
if (NSLocale.PreferredLanguages.Length > 0)
{
var pref = NSLocale.PreferredLanguages[0];
prefLanguageOnly = pref.Substring(0, 2);
if (prefLanguageOnly == "pt")
{
if (pref == "pt")
pref = "pt-BR"; // get the correct Brazilian language strings from the PCL RESX (note the local iOS folder is still "pt")
else
pref = "pt-PT"; // Portugal
}
netLanguage = pref.Replace("_", "-");
Console.WriteLine("preferred language:" + netLanguage);
}
System.Globalization.CultureInfo ci = null;
try
{
ci = new System.Globalization.CultureInfo(netLanguage);
}
catch
{
// iOS locale not valid .NET culture (eg. "en-ES" : English in Spain)
// fallback to first characters, in this case "en"
ci = new System.Globalization.CultureInfo(prefLanguageOnly);
}
return ci;
}
示例12: GetSatelliteAssembly
public Assembly GetSatelliteAssembly(CultureInfo culture)
{
if (culture == null)
{
throw new ArgumentNullException("culture");
}
Assembly assm = null;
string baseName = this.FullName;
string cultureName;
while (assm == null && (cultureName = culture.Name) != "")
{
string assmName = baseName + "." + cultureName;
assm = Assembly.Load(assmName, false);
culture = culture.Parent;
}
if (assm == null)
{
throw new ArgumentException();
// FIXME -- throw new FileNotFoundException();
}
return assm;
}
示例13: RoundFloatToString
public static string RoundFloatToString(float floatToRound)
{
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
cultureInfo.NumberFormat.CurrencyDecimalDigits = 2;
cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";
return floatToRound.ToString("F", cultureInfo);
}
示例14: GetDataValueRangeFilderString
internal static string GetDataValueRangeFilderString(DataValueFilter dataValueFilter)
{
string WhereClause = " WHERE NOT (";
string CurrentThreadDecimalChar = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
string InvariantCultureDecimalChar = new System.Globalization.CultureInfo("en-US").NumberFormat.NumberDecimalSeparator;
switch (dataValueFilter.OpertorType)
{
case OpertorType.EqualTo:
WhereClause += " VAL([" + Data.DataValue + "]) = " + dataValueFilter.FromDataValue.ToString().Replace(CurrentThreadDecimalChar, InvariantCultureDecimalChar);
break;
case OpertorType.Between:
//Inclusive of min & max values as per ANSI SQL
WhereClause += "(VAL([" + Data.DataValue + "]) >= " + dataValueFilter.FromDataValue.ToString().Replace(CurrentThreadDecimalChar, InvariantCultureDecimalChar) + " AND VAL([" + Data.DataValue + "]) <= " + dataValueFilter.ToDataValue.ToString().Replace(CurrentThreadDecimalChar, InvariantCultureDecimalChar) + ")";
break;
case OpertorType.GreaterThan:
WhereClause += "(VAL([" + Data.DataValue + "]) > " + dataValueFilter.FromDataValue.ToString().Replace(CurrentThreadDecimalChar, InvariantCultureDecimalChar) + ")";
break;
case OpertorType.LessThan:
WhereClause += "(VAL([" + Data.DataValue + "]) < " + dataValueFilter.ToDataValue.ToString().Replace(CurrentThreadDecimalChar, InvariantCultureDecimalChar) + ")";
break;
}
WhereClause += " )";
return WhereClause;
}
示例15: GetJQueryDateFormatFor
static string GetJQueryDateFormatFor(string language)
{
var culture = new System.Globalization.CultureInfo(language);
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
return DateFormatter.CurrentJQuery;
}