• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.Enum类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Enum的典型用法代码示例。如果您正苦于以下问题:C# Enum类的具体用法?C# Enum怎么用?C# Enum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Enum类属于System命名空间,在下文中一共展示了Enum类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ValuePair

		static KeyInfo ValuePair(Enum token, object value)
		{
			KeyInfo k=new KeyInfo();
			k.ki_key=(int)(object)token;
			k.ki_name=token.ToString();
			return k;
		}
开发者ID:LogoPhonix,项目名称:libgeotiff.net,代码行数:7,代码来源:geonames.cs


示例2: MapListener

		/*============================================================================*/
		/* Public Functions                                                           */
		/*============================================================================*/

		public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
		{
			if (eventClass == null)
			{	
				eventClass = typeof(Event);
			}

			List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;

			EventMapConfig config;

			int i = currentListeners.Count;

			while (i-- > 0) 
			{
				config = currentListeners [i];
				if (config.Equals (dispatcher, type, listener, eventClass))
					return;
			}

			Delegate callback = eventClass == typeof(Event) ? listener : (Action<IEvent>)delegate(IEvent evt){
				RouteEventToListener(evt, listener, eventClass);
			};

			config = new EventMapConfig (dispatcher, type, listener, eventClass, callback);

			currentListeners.Add (config);

			if (!_suspended) 
			{
				dispatcher.AddEventListener (type, callback);
			}
		}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:37,代码来源:EventMap.cs


示例3: GetStringValue

        public static string GetStringValue(Enum value)
        {
            string output;
            var type = value.GetType();

            if (StringValues.ContainsKey(value))
            {
                output = StringValues[value].Value;
            }
            else
            {
                var fi = type.GetField(value.ToString());
                var attrs = fi.GetCustomAttributes(typeof (StringValueAttribute), false)
                    as StringValueAttribute[];
                if (attrs != null && attrs.Length > 0)
                {
                    output = attrs[0].Value;
                    // Put it in the cache.
                    lock(StringValues)
                    {
                        // Double check
                        if (!StringValues.ContainsKey(value))
                        {
                            StringValues.Add(value, attrs[0]);
                        }
                    }
                }
                else
                {
                    return value.ToString();
                }
            }

            return output;
        }
开发者ID:niuxianghui,项目名称:SkinsModify,代码行数:35,代码来源:EnumUtils.cs


示例4: SelectConcept

 public override void SelectConcept(Enum concept)
 {
     base.SelectConcept(concept);
     if(concept.GetType().Equals(typeof(DataAccessConceptsList)))
     {
         switch((DataAccessConceptsList)concept)
         {
             case DataAccessConceptsList.WorkingWithFilesExamples:
                 conceptExecutionClass = new WorkingWithFilesExamples();
                 break;
             case DataAccessConceptsList.WorkingWithStreams:
                 conceptExecutionClass = new WorkingWithStreams();
                 break;
             case DataAccessConceptsList.WorkingWithADO_DOTNET_Concepts:
                 conceptExecutionClass = new WorkingWithADO_DOTNET_Concepts();
                 break;
             case DataAccessConceptsList.WorkingWithXMLConcepts:
                 conceptExecutionClass = new WorkingWithXMLExamples();
                 break;
             case DataAccessConceptsList.LINQExamples:
                 conceptExecutionClass = new LINQExamples();
                 break;
             case DataAccessConceptsList.SerializationAndDeserializationExamples:
                 conceptExecutionClass = new SerializationAndDeserializationExamples();
                 break;
             case DataAccessConceptsList.ImplementingClassHierarchy:
                 conceptExecutionClass = new ClassHierarchyExample();
                 break;
         }
     }
 }
开发者ID:mayankaggarwal,项目名称:MyConcepts,代码行数:31,代码来源:ConceptSelectionClass.cs


示例5: SetEnumEvent

 private SetEnumEvent(CtorType ctorType, int position, Enum val, String name)
 {
     this.ctorType = ctorType;
     this.position = position;
     this.val = val;
     this.name = name;
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:7,代码来源:SetEnumEvent.cs


示例6: BunnyMask

 public int BunnyMask(GUIContent content, Enum enumValue)
 {
     var enumType = enumValue.GetType();
     var enumNames = Enum.GetNames(enumType);
     var enumValues = Enum.GetValues(enumType) as int[];
     return BunnyMask(content, Convert.ToInt32(enumValue), enumValues, enumNames);
 }
开发者ID:srndpty,项目名称:VFW,代码行数:7,代码来源:Masks.cs


示例7: Resource

        public Resource(ResourceManager resourceManager, Enum stringResource)
        {
            ResourceManager = resourceManager;
            StringResource = stringResource;

            LastModified = DateTime.UtcNow;
        }
开发者ID:ducas,项目名称:MicroWebServer,代码行数:7,代码来源:Resource.cs


示例8: getPrev

 public FingerName getPrev(Enum current)
 {
     //set current index to last
     int currentIdx = 5;
     //initialize a Enum FingerName
     FingerName f = FingerName.UNKNOWN;
     //loop to find the current Enum index and value
     foreach (var value in Enum.GetValues(typeof(FingerName)))
     {
         if (current == value)
         {
             f = (FingerName)value;
             break;
         }
         else
         {
             currentIdx--;
         }
     }
     //minus 1 to get previous index of Enum
     int prevIdx = currentIdx - 1;
     //check if previous index is more than 0
     if (prevIdx < 0)
     {
         prevIdx = (FingerName.GetValues(typeof(FingerName)).Length) - 1;
     }
     //return the value of previous Enum
     return f;
 }
开发者ID:hzhiguang,项目名称:AbuseAnalysis,代码行数:29,代码来源:FingerName.cs


示例9: getEnumHttpResponse

        /// <summary>
        /// Returns the string version of a http status response code
        /// </summary>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public static string getEnumHttpResponse(Enum statusCode)
        {
            string _httpResponse = "";

            switch (getEnumValue(statusCode))
            {
                case 200:
                    _httpResponse = "HTTP/1.1 200 OK";
                    break;

                case 404:
                    _httpResponse = "HTTP/1.1 404 Not Found";
                    break;

                case 423:
                    _httpResponse = "HTTP/1.1 423 Locked";
                    break;

                case 424:
                    _httpResponse = "HTTP/1.1 424 Failed Dependency";
                    break;

                case 507:
                    _httpResponse = "HTTP/1.1 507 Insufficient Storage";
                    break;

                default:
                    break;
            }

            return _httpResponse;
        }
开发者ID:tiernano,项目名称:HojuWebDisk,代码行数:37,代码来源:WebDavHelper.cs


示例10: HasFlag

        public static bool HasFlag(this Enum enumRef, Enum flag)
        {
            long value = Convert.ToInt64(enumRef);
            long flagVal = Convert.ToInt64(flag);

            return (value & flagVal) == flagVal;
        }
开发者ID:kouseki926,项目名称:sharpcompress,代码行数:7,代码来源:EnumExtensions.cs


示例11: getNext

 public FingerName getNext(Enum current)
 {
     //set current index to 0
     int currentIdx = 0;
     //initialize a Enum FingerName
     FingerName f = FingerName.UNKNOWN;
     //loop to find the current Enum index and value
     foreach (var value in Enum.GetValues(typeof(FingerName)))
     {
         if (current == value)
         {
             f = (FingerName)value;
             break;
         }
         else
         {
             currentIdx++;
         }
     }
     //add 1 to get next index of Enum
     int nextIdx = currentIdx + 1;
     //check if next index value is UNKNOWN
     if (nextIdx == Enum.GetValues(typeof(FingerName)).Length)
     {
         nextIdx = 0;
     }
     //return the value of next Enum
     return f;
 }
开发者ID:hzhiguang,项目名称:AbuseAnalysis,代码行数:29,代码来源:FingerName.cs


示例12: GetStringValue

        public static string GetStringValue(Enum value)
        {
            string output = null;
            Type type = value.GetType();

            //Check first in our cached results...
            if (_stringValues.ContainsKey(value))
                output = (_stringValues[value] as StringValueAttribute).Value;
            else
            {
                //Look for our 'StringValueAttribute' 
                //in the field's custom attributes
                FieldInfo fi = type.GetField(value.ToString());
                StringValueAttribute[] attrs =
                   fi.GetCustomAttributes(typeof(StringValueAttribute),
                                           false) as StringValueAttribute[];
                if (attrs.Length > 0)
                {
                    _stringValues.Add(value, attrs[0]);
                    output = attrs[0].Value;
                }
            }

            return output;
        }
开发者ID:ikeough,项目名称:GRegClientNET,代码行数:25,代码来源:Utilities.cs


示例13: GetFlags

 private static IEnumerable<Enum> GetFlags(Enum value, Enum[] values)
 {
     ulong bits = Convert.ToUInt64(value);
     List<Enum> results = new List<Enum>();
     for (int i = values.Length - 1; i >= 0; i--)
     {
         ulong mask = Convert.ToUInt64(values[i]);
         if (i == 0 && mask == 0L)
         {
             break;
         }
         if ((bits & mask) == mask)
         {
             results.Add(values[i]);
             bits -= mask;
         }
     }
     if (bits != 0L)
     {
         return Enumerable.Empty<Enum>();
     }
     if (Convert.ToUInt64(value) != 0L)
     {
         return results.Reverse<Enum>();
     }
     if (bits == Convert.ToUInt64(value) && values.Length > 0 && Convert.ToUInt64(values[0]) == 0L)
     {
         return values.Take(1);
     }
     return Enumerable.Empty<Enum>();
 }
开发者ID:jandppw,项目名称:ppwcode-recovered-from-google-code,代码行数:31,代码来源:EnumExtensions.cs


示例14: HasFlag

        public static bool HasFlag(this Enum thisInstance, Enum flag)
        {
            ulong instanceVal = Convert.ToUInt64(thisInstance);
            ulong flagVal = Convert.ToUInt64(flag);

            return (instanceVal & flagVal) == flagVal;
        }
开发者ID:Chavjoh,项目名称:RssSimpleStream,代码行数:7,代码来源:FrameworkHelper.cs


示例15: AddRoom

        public Room AddRoom(Enum id)
        {
            var room = new Room(this, id.ToString());
            _rooms.Add(id, room);

            return room;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:7,代码来源:Home.cs


示例16: GiveMeStateFromEnum

 public static string GiveMeStateFromEnum(Enum stateFromCore)
 {
     string res = "";
     switch (stateFromCore.ToString())
     {
         case "queued_for_checking":
             res = "Queued For Checking";
             break;
         case "checking_files":
             res = "Checking Files";
             break;
         case "downloading_metadata":
             res = "Downloading Metadata";
             break;
         case "downloading":
             res = "Downloading";
             break;
         case "finished":
             res = "Finished";
             break;
         case "seeding":
             res = "Seeding";
             break;
         case "allocating":
             res = "Allocating";
             break;
         case "checking_resume_data":
             res = "Checking Resume Data";
             break;
         default:
             res = "Error";
             break;
     }
     return res;
 }
开发者ID:ChristianSacramento,项目名称:Tsunami,代码行数:35,代码来源:Utils.cs


示例17: FieldEnum

		/// <summary>
		/// Enumeration valued field.
		/// </summary>
		/// <param name="Node">Node</param>
		/// <param name="FieldName">Name of field</param>
		/// <param name="StringIds">Corresponding String IDs</param>
		/// <param name="Timepoint">Timepoint of field value.</param>
		/// <param name="Value">Value</param>
		/// <param name="Type">Type of value.</param>
		public FieldEnum(string NodeId, string FieldName, FieldLanguageStep[] StringIds, DateTime Timepoint,
			Enum Value, ReadoutType Type)
			: base(NodeId, FieldName, StringIds, Timepoint, Type)
		{
			this.value = Value.ToString();
			this.dataType = Value.GetType ().FullName;
		}
开发者ID:mukira,项目名称:Learning-IoT-HTTP,代码行数:16,代码来源:FieldEnum.cs


示例18: Publish

 public static void Publish(Enum message, params object[] parameters)
 {
     object parameter = null;
     if (parameters.Length == 1) parameter = parameters[0];
     else if (parameters.Length > 1) parameter = parameters;
     Publish(message.ToString(), parameter);
 }
开发者ID:silky,项目名称:sledge,代码行数:7,代码来源:Mediator.cs


示例19: GetDescription

        public static string GetDescription(this Type type, Enum value)
        {
            if (!EnumTypeCaches.ContainsKey(type))
            {
                EnumTypeCaches[type] = new Dictionary<Enum, string>();
            }

            if(!EnumTypeCaches[type].ContainsKey(value))
            {
                var name = Enum.GetName(type, value);
                if (!string.IsNullOrEmpty(name))
                {
                    var field = type.GetField(name);
                    if (field != null)
                    {
                        var attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
                        if (attr != null)
                        {
                            EnumTypeCaches[type][value] = attr.Description;
                            return attr.Description;
                        }
                           
                    }
                }
            }

            return EnumTypeCaches[type][value];
        }
开发者ID:Mrding,项目名称:Ribbon,代码行数:28,代码来源:EnumExtensions.cs


示例20: Dispatch

		public void Dispatch(Enum eventType, GameEvent gameEvent)
		{
			gameEvent.EventIndex = ++LastEventIndex;

			if (Parent != null)
			{
				Parent.Dispatch(eventType, gameEvent);
			}
			else
			{
				if (Handlers.ContainsKey(eventType))
				{
					List<EventHandler> handlersForEventType = Handlers[eventType];

					if (handlersForEventType != null && handlersForEventType.Count > 0)
					{
						handlersForEventType.ForEach(
							h =>
							{
								if (!gameEvent.StopPropagation)
								{
									h(gameEvent);
								}
							});
					}
				}
			}
		}
开发者ID:Synestry,项目名称:Unity-Framework,代码行数:28,代码来源:EventDispatcher.cs



注:本文中的System.Enum类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.Enums类代码示例发布时间:2022-05-26
下一篇:
C# System.Entity类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap