本文整理汇总了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));
}
}