当前位置: 首页>>代码示例>>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;未经允许,请勿转载。