当前位置: 首页>>代码示例>>C#>>正文


C# System.Enum类代码示例

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


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


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