public static string GetDescription <T>(this System.Enum enumVal)
        {
            var type       = enumVal?.GetType();
            var memInfo    = type?.GetMember(enumVal?.ToString());
            var attributes = memInfo[0]?.GetCustomAttributes(typeof(EnumValueAsText), false);

            return((attributes?.Length > 0) ? ((EnumValueAsText)attributes[0])?.Value : null);
        }
Beispiel #2
0
 public TypeNamePair(System.Enum enumeration, string key)
 {
     this.type      = enumeration.GetType();
     this.fieldname = enumeration.ToString();
     this.key       = key;
 }
Beispiel #3
0
 public IStateBuilder <State, StateMachineBuilder> State(System.Enum stateName)
 {
     return(new StateBuilder <State, StateMachineBuilder>(this, rootState, stateName.ToString()));
 }
        public static string GetDescription(this System.Enum enumValue)
        {
            var value = enumValue.GetType().GetMember(enumValue.ToString())[0].GetCustomAttribute <DisplayAttribute>();

            return(value != null ? value.Name : string.Empty);
        }
        /// <summary>
        /// Save the specified enum value to settings.
        /// </summary>

        static public void SetEnum(string name, System.Enum val)
        {
            SetString(name, val.ToString());
        }
 public void SetEnum(System.Enum value)
 {
     TextElement.text = value.ToString();
 }
Beispiel #7
0
 public static string ToIntegerString(this System.Enum enumValue)
 {
     return(enumValue.ToString("D"));
 }
Beispiel #8
0
 public MyJson_Number(System.Enum value)
 {
     this.value = (int)System.Enum.Parse(value.GetType(), value.ToString());
 }
Beispiel #9
0
 ///Log Error
 public static void LogError(object message, System.Enum tag = null, object context = null)
 {
     Internal_Log(LogType.Error, message, tag.ToString(), context);
 }
Beispiel #10
0
 public static void SetEnum(string key, System.Enum value)
 {
     SetString(key, value.ToString());
 }
 public static string GetDescription(this System.Enum value)
 {
     System.ComponentModel.DescriptionAttribute [] attributes = (System.ComponentModel.DescriptionAttribute [])value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
     return(attributes != null && attributes.Length > 0 ? attributes [0].Description : value.ToString());
 }
        private static DataGridColumnAttribute[] GetAttributes(this System.Enum columnEnum)
        {
            FieldInfo fi = columnEnum.GetType().GetField(columnEnum.ToString());

            return((DataGridColumnAttribute[])fi.GetCustomAttributes(typeof(DataGridColumnAttribute), false));
        }
        public List <ItemData> GetItemsByCategory(System.Enum category)
        {
            var result = from item in _data.items where item.category == category.ToString() select item;

            return(result.ToList());
        }
Beispiel #14
0
 private void Set(string elementKey, System.Enum elementType, string xmlData)
 {
     SetPropertyValue(Constants.Exceptions.ElementKey, elementKey == null ? "<null>" : elementKey);
     SetPropertyValue(Constants.Exceptions.ElementType, elementType.ToString());
     SetPropertyValue(Constants.Exceptions.XmlData, xmlData == null ? "<null>" : xmlData);
 }
Beispiel #15
0
 private void Set(string elementReference, System.Enum elementType)
 {
     SetPropertyValue(Constants.Exceptions.ElementReference, elementReference == null ? string.Empty : elementReference);
     SetPropertyValue(Constants.Exceptions.ElementType, elementType.ToString());
 }
Beispiel #16
0
 ///Log Exception
 public static void LogException(System.Exception exception, System.Enum tag = null, object context = null)
 {
     Internal_Log(LogType.Exception, exception, tag.ToString(), context);
 }
Beispiel #17
0
        public static string Name(this System.Enum e)
        {
            var attributes = (DisplayAttribute[])e.GetType().GetField(e.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Name : string.Empty);
        }
Beispiel #18
0
 public int GetCurrencyAmount(System.Enum key)
 {
     return(GetCurrencyAmount(key.ToString()));
 }
Beispiel #19
0
 public MyJson_String(System.Enum value)
 {
     this.value = value.ToString();
 }
Beispiel #20
0
 public override string ToString()
 {
     return(value == null ? "" : value.ToString());
 }
    public static string ToDescription(this System.Enum value)
    {
        var attributes = (DescriptionAttribute[])value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);

        return(attributes.Length > 0 ? attributes[0].Description : value.ToString());
    }
Beispiel #22
0
        /// <summary>
        /// The custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            // Update serialized node data
            if (Event.current.type == EventType.Layout)
            {
                this.serializedNode.Update();
            }

            // Cache the indent level
            int indentLevel = EditorGUI.indentLevel;

            // Get an iterator
            var iterator = this.serializedNode.GetIterator();

            // Draw the target object
            if (iterator.Find("targetObject"))
            {
                EditorGUI.indentLevel = indentLevel + iterator.depth;
                GUILayoutHelper.DrawNodeProperty(new GUIContent(iterator.current.label, iterator.current.tooltip), iterator.current, this.target);
            }

            // Draw the propertyName
            if (iterator.Find("propertyName"))
            {
                EditorGUI.indentLevel = indentLevel + iterator.depth;
                GUILayoutHelper.DrawNodeProperty(new GUIContent(iterator.current.label, iterator.current.tooltip), iterator.current, this.target);
            }

            // Draw the property value
            var propertyOrField = target as PropertyOrField;

            if (propertyOrField != null)
            {
                if (Event.current.type == EventType.Layout)
                {
                    propertyType = propertyOrField.propertyType;
                }

                if (propertyType != null)
                {
                    if (iterator.Find(propertyType.Name + "Value"))
                    {
                        EditorGUI.indentLevel = indentLevel + iterator.depth;
                        GUILayoutHelper.DrawNodeProperty(new GUIContent(propertyOrField.propertyName, iterator.current.tooltip), iterator.current, this.target);
                    }
                    else if (propertyType == typeof(GameObject) && iterator.Find("GameObjectValue"))
                    {
                        EditorGUI.indentLevel = indentLevel + iterator.depth;
                        GUILayoutHelper.DrawNodeProperty(new GUIContent(propertyOrField.propertyName, iterator.current.tooltip), iterator.current, this.target);
                    }
                    else if (typeof(UnityEngine.Object).IsAssignableFrom(propertyType) && iterator.Find("ObjectValue"))
                    {
                        EditorGUI.indentLevel = indentLevel + iterator.depth;
                        GUILayoutHelper.DrawNodeProperty(new GUIContent(propertyOrField.propertyName, iterator.current.tooltip), iterator.current, this.target);
                    }
                    else if (target is SetProperty && propertyType.IsEnum && iterator.Find("StringValue.value"))
                    {
                        string value = (string)iterator.current.value;

                        // The enum is defined?
                        if (!System.Enum.IsDefined(propertyType, value))
                        {
                            iterator.current.value = value = "0";
                        }

                        // Used to check if the gui was changed in editor
                        EditorGUI.BeginChangeCheck();
                        // Draw an enum popup field
                        System.Enum newValue = EditorGUILayout.EnumPopup(new GUIContent(propertyOrField.propertyName, iterator.current.tooltip), (System.Enum)System.Enum.Parse(propertyType, value));
                        // Value changed?
                        if (EditorGUI.EndChangeCheck())
                        {
                            iterator.current.value = newValue.ToString();
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(propertyType.Name, "not supported.");
                    }
                }
            }

            // Restore the indent level
            EditorGUI.indentLevel = indentLevel;

            // Apply modified properties
            this.serializedNode.ApplyModifiedProperties();
        }
Beispiel #23
0
    public override string ToString()
    {
        string result = baseType.ToString() + "." + subType.ToString();

        return(result);
    }
Beispiel #24
0
 public IStateBuilder <T, StateMachineBuilder> State <T>(System.Enum stateName) where T : AbstractState, new()
 {
     return(new StateBuilder <T, StateMachineBuilder>(this, rootState, stateName.ToString()));
 }
Beispiel #25
0
 public static string EnumToString(System.Enum value)
 {
     return(value.ToString());
 }
Beispiel #26
0
        private static string _GetActionSet(System.Enum i)
        {
            var actionSet = ((System.ComponentModel.DescriptionAttribute)i.GetType().GetMember(i.ToString())[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false)[0]).Description;

            //return string.Format("/actions/{0}/in/{1}",actionSet,i.ToString().ToLower());
            return(actionSet);
        }