//
        // Used to disable automatic generation of ParserTestData from FormatterTestData
        //
        public static bool IsParsingImplemented(this SupportedFormat f, Type t)
        {
            if (IntegerTypes.Contains(t) && (f.Symbol == 'N' || f.Symbol == 'n'))
            {
                return(false);
            }

            return(true);
        }
 public void CreateValidators(ClientValidatorProviderContext context)
 {
     if (context.ModelMetadata.UnderlyingOrModelType == typeof(DateTime))
     {
         context.Results.Add(new ClientValidatorItem {
             Validator = new DateValidator(), IsReusable = true
         });
     }
     else if (DecimalTypes.Contains(context.ModelMetadata.UnderlyingOrModelType))
     {
         context.Results.Add(new ClientValidatorItem {
             Validator = new NumberValidator(), IsReusable = true
         });
     }
     else if (IntegerTypes.Contains(context.ModelMetadata.UnderlyingOrModelType))
     {
         context.Results.Add(new ClientValidatorItem {
             Validator = new IntegerValidator(), IsReusable = true
         });
     }
 }
        public static void InspectProperty(PropertyInfo info, object value)
        {
            var type = info.PropertyType;

            if (IntegerTypes.Contains(type))
            {
                var v = Convert.ToInt32(info.GetValue(value));

                var n = EditorGUILayout.IntField(v);

                if (type == typeof(uint))
                {
                    info.SetValue(value, (uint)n);
                }

                if (type == typeof(ushort))
                {
                    info.SetValue(value, (ushort)n);
                }

                if (type == typeof(short))
                {
                    info.SetValue(value, (short)n);
                }

                if (type == typeof(byte))
                {
                    info.SetValue(value, (byte)n);
                }

                if (type == typeof(int))
                {
                    info.SetValue(value, n);
                }

                return;
            }

            if (LongTypes.Contains(type))
            {
                info.SetValue(value, EditorGUILayout.LongField((long)info.GetValue(value)));

                return;
            }

            if (FloatTypes.Contains(type))
            {
                info.SetValue(value, EditorGUILayout.FloatField((float)info.GetValue(value)));

                return;
            }

            if (DoubleTypes.Contains(type))
            {
                info.SetValue(value, EditorGUILayout.DoubleField((double)info.GetValue(value)));

                return;
            }

            if (type == typeof(bool))
            {
                info.SetValue(value, EditorGUILayout.Toggle((bool)info.GetValue(value)));

                return;
            }

            if (type == typeof(NiString))
            {
                var niString = (NiString)info.GetValue(value);

                var index = niString.Index;

                EditorGUILayout.LabelField($"Index: {(index == uint.MaxValue ? "Null" : index.ToString())}");

                return;
            }

            if (type.Name.StartsWith("Ptr"))
            {
                var ptr = info.GetValue(value);

                var indexInfo = ptr.GetType().GetField("Index");

                if (indexInfo == null)
                {
                    EditorGUILayout.LabelField($"Failed to load ptr");

                    return;
                }

                var index = (int)indexInfo.GetValue(ptr);

                EditorGUILayout.LabelField($"Index: {(index == -1 ? "Null" : index.ToString())}");

                return;
            }

            if (type == typeof(Vector3))
            {
                var v = (Vector3)info.GetValue(value);
                v.x = EditorGUILayout.FloatField(v.x);
                v.y = EditorGUILayout.FloatField(v.y);
                v.z = EditorGUILayout.FloatField(v.z);
                info.SetValue(value, v);

                return;
            }

            if (type == typeof(Color3))
            {
                var v = (Color3)info.GetValue(value);
                v.r = EditorGUILayout.FloatField(v.r);
                v.g = EditorGUILayout.FloatField(v.g);
                v.b = EditorGUILayout.FloatField(v.b);
                info.SetValue(value, v);

                return;
            }

            if (type == typeof(Vector4))
            {
                var v = (Vector4)info.GetValue(value);
                v.x = EditorGUILayout.FloatField(v.x);
                v.y = EditorGUILayout.FloatField(v.y);
                v.z = EditorGUILayout.FloatField(v.z);
                v.w = EditorGUILayout.FloatField(v.w);
                info.SetValue(value, v);

                return;
            }

            EditorGUILayout.LabelField("Unsupported type!");
        }
        public static bool IsInteger(this Type type)
        {
            Contract.Requires(type != null);

            return(IntegerTypes.Contains(type));
        }
Exemple #5
0
 public IntegerMsSqlColumnType(IntegerTypes integerType)
 {
     IntegerType = integerType;
 }
Exemple #6
0
 public static bool IsIntegerType(Type?type)
 {
     return(!(type is null) && IntegerTypes.Contains(type));
 }
Exemple #7
0
 /// <summary>
 /// Check if the type is an integer type.
 /// </summary>
 public static bool IsInteger(Type type)
 {
     return(IntegerTypes.Contains(type));
 }