當前位置: 首頁>>代碼示例>>C#>>正文


C# Enum.Equals方法代碼示例

本文整理匯總了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.");
     }
 }
開發者ID:srimarc,項目名稱:strange-demos,代碼行數:15,代碼來源:MultiSocialService.cs

示例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
                    }
        }
開發者ID:TommyAGK,項目名稱:Flex3,代碼行數:45,代碼來源:ConfigReader.cs

示例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.
                                    }
        }
開發者ID:TommyAGK,項目名稱:Flex,代碼行數:48,代碼來源:XmlDataReader.cs

示例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());
     }
 }
開發者ID:modulexcite,項目名稱:SilverlightWpfContrib,代碼行數:12,代碼來源:XamlWriter.cs

示例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()));
     }
 }
開發者ID:AndreGleichner,項目名稱:corefx,代碼行數:9,代碼來源:EnumTests.cs

示例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());
            }
        }
開發者ID:NickCorn,項目名稱:Writer,代碼行數:13,代碼來源:HtmlElement.cs

示例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;
        }
開發者ID:gabrielrainha,項目名稱:Humanizer,代碼行數:21,代碼來源:EnumHumanizeExtensions.cs

示例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));
     }
 }
開發者ID:ikvm,項目名稱:webmatrix,代碼行數:11,代碼來源:Element.cs


注:本文中的System.Enum.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。