本文整理匯總了C#中System.Enum.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Enum.Equals方法的具體用法?C# Enum.Equals怎麽用?C# Enum.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Enum
的用法示例。
在下文中一共展示了Enum.Equals方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: selectService
public void selectService(Enum id)
{
if (id.Equals(SocialServices.FACEBOOK))
{
selectedService = facebook;
}
else if (id.Equals(SocialServices.GOOGLE_PLUS))
{
selectedService = googlePlus;
}
else
{
throw new Exception ("MultiSocialService received unrecognized service id.");
}
}
示例2: ReadConfig
private void ReadConfig(Enum choice)
{
// read the XML file from v here
path = Directory.GetCurrentDirectory() + @"\Dependency\ProfileConfig\ProfileConfig.xml";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(new StreamReader(path));
if (xmldoc.DocumentElement == null)
{
return;
}
var nodeList = xmldoc.DocumentElement.SelectNodes("Server"); // <- This gets the stuff related to servers, all of it
try
{
if (choice.Equals(ConfigType.Students)) // if you want to find a students RF data, do this
{
ConfStrings[0] = nodeList[0].SelectSingleNode("address").InnerText;
ConfStrings[1] = nodeList[0].SelectSingleNode("sqldirectory").InnerText;
ConfStrings[2] = nodeList[0].SelectSingleNode("table").InnerText;
ConfStrings[3] = nodeList[0].SelectSingleNode("dbuser").InnerText;
ConfStrings[4] = nodeList[0].SelectSingleNode("dbpass").InnerText;
}
else
{
// this is teacher data
ConfStrings[0] = nodeList[0].NextSibling.SelectSingleNode("address").InnerText;
ConfStrings[1] = nodeList[0].NextSibling.SelectSingleNode("sqldirectory").InnerText;
ConfStrings[2] = nodeList[0].NextSibling.SelectSingleNode("table").InnerText;
ConfStrings[3] = nodeList[0].NextSibling.SelectSingleNode("dbuser").InnerText;
ConfStrings[4] = nodeList[0].NextSibling.SelectSingleNode("dbpass").InnerText;
}
if (DiagXML)
{
var str = "XML status: filtilgang og lesning OK";
}
}
catch (NullReferenceException e)
{
//TODO Handle exception
// okay
LogThis.Report("ConfigReader",e.StackTrace); // write the error down in the logfile
}
}
示例3: ReadConfig
private void ReadConfig(Enum choice)
{
// read the XML file from v here
_path = Directory.GetCurrentDirectory() + @"\Dependency\Config\Config.xml";
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(new StreamReader(_path));
if (xmldoc.DocumentElement == null)
{
return;
}
var nodeList = xmldoc.DocumentElement.SelectNodes("Server"); // <- This gets the stuff related to servers, all of it
//Console.WriteLine(nodeList[0].NextSibling.SelectSingleNode("table").InnerText);
try
{
if (choice.Equals(ConfigType.Students)) // if you want to find a students RF data, do this
{
ConfStrings[0] = nodeList[0].SelectSingleNode("address").InnerText;
ConfStrings[1] = nodeList[0].SelectSingleNode("sqldirectory").InnerText;
ConfStrings[2] = nodeList[0].SelectSingleNode("table").InnerText;
ConfStrings[3] = nodeList[0].SelectSingleNode("dbuser").InnerText;
ConfStrings[4] = nodeList[0].SelectSingleNode("dbpass").InnerText;
}
else
{
// this is teacher data
ConfStrings[0] = nodeList[0].NextSibling.SelectSingleNode("address").InnerText;
ConfStrings[1] = nodeList[0].NextSibling.SelectSingleNode("sqldirectory").InnerText;
ConfStrings[2] = nodeList[0].NextSibling.SelectSingleNode("table").InnerText;
ConfStrings[3] = nodeList[0].NextSibling.SelectSingleNode("dbuser").InnerText;
ConfStrings[4] = nodeList[0].NextSibling.SelectSingleNode("dbpass").InnerText;
}
if (DiagXML)
{
Speaker sp = new Speaker(Language.Norwegian);
var str = "XML status: filtilgang og lesning OK";
sp.Speak(str, 0);
}
}
catch (Exception e)
{
Console.WriteLine(e); // you done fucked up.
}
}
示例4: WriteAttribute
/// <summary>
/// Writes the attribute.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <param name="defaultValue">The default value.</param>
protected void WriteAttribute(string name, Enum value, Enum defaultValue)
{
if (this.settings.WriteDefaultValues || !value.Equals(defaultValue)) {
this.writer.WriteAttributeString(name, value.Format());
}
}
示例5: Equals
public static void Equals(Enum e, object obj, bool expected, bool hashExpected)
{
Assert.Equal(expected, e.Equals(obj));
Assert.Equal(e.GetHashCode(), e.GetHashCode());
if (obj != null)
{
Assert.Equal(hashExpected, e.GetHashCode().Equals(obj.GetHashCode()));
}
}
示例6: SetEnumAttribute
protected internal void SetEnumAttribute(string attribute, Enum value, Enum defaultValue)
{
Debug.Assert(value.GetType().Equals(defaultValue.GetType()));
if (value.Equals(defaultValue))
{
RemoveAttribute(attribute);
}
else
{
SetAttribute(attribute, value.ToString());
}
}
示例7: DirectlyMapsToEnumConstant
/// <summary>
/// Returns true if the given enum instance can map exactly to one of the enum's constants.
/// This doesn't always happen when using BitField enums.
/// </summary>
/// <param name="input">An instance of an enum.</param>
/// <returns>True, if the instance maps directly to a single enum property, false if otherwise.</returns>
private static bool DirectlyMapsToEnumConstant(Enum input)
{
bool exactMatch = false;
foreach (var raw in Enum.GetValues(input.GetType()))
{
if (input.Equals(raw))
{
exactMatch = true;
break;
}
}
return exactMatch;
}
示例8: SetEnumAttribute
protected internal void SetEnumAttribute(string attribute, Enum value, Enum defaultValue)
{
if (value.Equals(defaultValue))
{
this.RemoveAttribute(attribute);
}
else
{
this.SetAttribute(attribute, value.ToString(CultureInfo.InvariantCulture));
}
}