本文整理汇总了C#中CultureInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.Clone方法的具体用法?C# CultureInfo.Clone怎么用?C# CultureInfo.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_TestData
public static IEnumerable<object[]> Equals_TestData()
{
CultureInfo frFRCulture = new CultureInfo("fr-FR");
yield return new object[] { frFRCulture, frFRCulture.Clone(), true };
yield return new object[] { frFRCulture, frFRCulture, true };
yield return new object[] { new CultureInfo("en"), new CultureInfo("en"), true };
yield return new object[] { new CultureInfo("en-US"), new CultureInfo("en-US"), true };
yield return new object[] { CultureInfo.InvariantCulture, CultureInfo.InvariantCulture, true };
yield return new object[] { CultureInfo.InvariantCulture, new CultureInfo(""), true };
yield return new object[] { new CultureInfo("en"), new CultureInfo("en-US"), false };
yield return new object[] { new CultureInfo("en-US"), new CultureInfo("fr-FR"), false };
yield return new object[] { new CultureInfo("en-US"), null, false };
}
示例2: PosTest2
public bool PosTest2()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest2: Call Clone method on a instance created from several cultures");
try
{
DateTimeFormatInfo expected = new CultureInfo("en-us").DateTimeFormat;
retVal = VerificationHelper(expected, expected.Clone(), "002.1") && retVal;
expected = new CultureInfo("fr-FR").DateTimeFormat;
retVal = VerificationHelper(expected, expected.Clone(), "002.2") && retVal;
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例3: PosTest1
// Returns true if the expected result is right
// Returns false if the expected result is wrong
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: Other CultureInfo comes from Clone method is the same CultureInfo as the original");
try
{
CultureInfo myCultureInfo = new CultureInfo("fr-FR");
CultureInfo myClone = myCultureInfo.Clone() as CultureInfo;
if (!myClone.Equals(myCultureInfo))
{
TestLibrary.TestFramework.LogError("001", "Other CultureInfo comes from Clone method should be the same CultureInfo as the original.");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例4: MakeRows
public void MakeRows() {
float totalscreenwidth = RectTransformExtensions.GetWidth(breakdowntable.GetComponent<RectTransform>());
float preferredwidth1 = totalscreenwidth * 0.20F;
float preferredwidth2 = totalscreenwidth * 0.20F;
float preferredwidth3 = totalscreenwidth * 0.20F;
float preferredwidth4 = totalscreenwidth * 0.20F;
float preferredwidth5 = totalscreenwidth * 0.20F;
var children = new List<GameObject>();
foreach (Transform child in breakdowntable.transform) children.Add(child.gameObject);
children.ForEach(child => Destroy(child));
GameObject firstrow = Instantiate (rowski);
firstrow.transform.parent = breakdowntable.transform;
GameObject firstcol = Instantiate (colski);
firstcol.GetComponent<Text> ().text = "Name";
firstcol.transform.parent = firstrow.transform;
GameObject firstseccol = Instantiate(colski);
firstseccol.GetComponent<Text>().text = "Campaign Region";
firstseccol.transform.parent = firstrow.transform;
GameObject secondcol = Instantiate (colski);
secondcol.GetComponent<Text> ().text = "Campaign Type";
secondcol.transform.parent = firstrow.transform;
GameObject thirdcol = Instantiate (colski);
thirdcol.GetComponent<Text> ().text = "Votes Earned";
thirdcol.transform.parent = firstrow.transform;
GameObject fourthcol = Instantiate (colski);
fourthcol.GetComponent<Text> ().text = "Money Spent";
fourthcol.transform.parent = firstrow.transform;
firstcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth1;
firstseccol.GetComponent<LayoutElement>().preferredWidth = preferredwidth5;
secondcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth2;
thirdcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth3;
fourthcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth4;
foreach(KeyValuePair<string, Region> entry in popup.GetComponent<PopupScript>().regions)
{
List<Campaign> curcamps = new List<Campaign> ();
curcamps = popup.GetComponent<PopupScript> ().activecampaigns [entry.Key];
foreach (Campaign camp in curcamps) {
if (camp != null) {
firstrow = Instantiate (rowski);
firstrow.transform.parent = breakdowntable.transform;
firstcol = Instantiate (colski);
firstcol.GetComponent<Text> ().text = camp.name;
firstcol.transform.parent = firstrow.transform;
firstseccol = Instantiate(colski);
firstseccol.GetComponent<Text>().text = camp.region;
firstseccol.transform.parent = firstrow.transform;
secondcol = Instantiate (colski);
secondcol.GetComponent<Text> ().text = camp.type;
secondcol.transform.parent = firstrow.transform;
thirdcol = Instantiate (colski);
Debug.Log ("votesMINUS1" + camp.costovertimecamp [camp.votesovertimecamp.Count - 1]);
Debug.Log ("votesMINUS2" + camp.costovertimecamp [camp.votesovertimecamp.Count - 2]);
thirdcol.GetComponent<Text> ().text = String.Format("{0:n0}", camp.votesovertimecamp[camp.votesovertimecamp.Count-1] - camp.votesovertimecamp[camp.votesovertimecamp.Count-2]);
thirdcol.transform.parent = firstrow.transform;
fourthcol = Instantiate (colski);
var original = new CultureInfo("en-us");
var modified = (CultureInfo) original.Clone();
modified.NumberFormat.CurrencyNegativePattern = 1;
float costdiff = camp.costovertimecamp [camp.costovertimecamp.Count - 1] - camp.costovertimecamp [camp.costovertimecamp.Count - 2];
// string moneystring = costdiff.ToString(modified, "{0:}", );
// if (costdiff < 0)
// moneystring = moneystring.Substring(1);
String cst = String.Format(modified, "{0:C2}", costdiff);
if (cst [0] == '-') {
cst = cst.Substring (1);
}
fourthcol.GetComponent<Text> ().text = cst;
fourthcol.transform.parent = firstrow.transform;
firstcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth1;
firstseccol.GetComponent<LayoutElement>().preferredWidth = preferredwidth5;
secondcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth2;
thirdcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth3;
fourthcol.GetComponent<LayoutElement>().preferredWidth = preferredwidth4;
// do something with entry.Value or entry.Key
}
}
}
}
示例5: Clone
public void Clone(CultureInfo culture)
{
CultureInfo clone = (CultureInfo)culture.Clone();
Assert.Equal(culture, clone);
Assert.NotSame(clone, culture);
}