Пример #1
0
 public static void loadAll(SkillFile skillFile)
 {
     foreach (IAccess t in skillFile.allTypes())
     {
         StaticFieldIterator fs = t.fields();
         while (fs.hasNext())
         {
             AbstractFieldDeclaration f = fs.next();
             if (f is ILazyField)
             {
                 ((ILazyField)f).ensureLoaded();
             }
         }
     }
 }
Пример #2
0
        /**
         * unchecked, because the insane amount of casts is necessary to reflect the
         * implicit value based type system
         */
        private static T value <T>(SkillFile sf, [email protected] type)
        {
            if (type is IGeneralAccess)
            {
                // get a random object
                IEnumerator @is = ((IGeneralAccess)type).GetEnumerator();
                for (int i = new Random().Next(reflectiveInitSize) % 200; i != 0; i--)
                {
                    @is.MoveNext();
                }
                return((T)@is.Current);
            }

            switch (type.TypeID)
            {
            case 5:
                // random type
                IEnumerator ts = sf.allTypes().GetEnumerator();
                ts.MoveNext();
                IAccess t = (IAccess)ts.Current;
                for (int i = new Random().Next(200); i != 0 && ts.MoveNext(); i--)
                {
                    t = (IAccess)ts.Current;
                }

                // random object
                IEnumerator @is = t.GetEnumerator();
                for (int i = new Random().Next(Math.Min(200, reflectiveInitSize)); i != 0; i--)
                {
                    @is.MoveNext();
                }
                @is.MoveNext();
                return((T)@is.Current);

            case 6:
                return((T)(object)(Boolean)(new Random().Next(1) != 0));

            case 7:
                return((T)(object)(SByte) new Random().Next(reflectiveInitSize));

            case 8:
                return((T)(object)(Int16) new Random().Next(reflectiveInitSize));

            case 9:
                return((T)(object)(Int32) new Random().Next(reflectiveInitSize));

            case 10:
            case 11:
                return((T)(object)(Int64)(new Random().Next() % reflectiveInitSize));

            case 12:
                return((T)(object)(Single) new Random().NextDouble());

            case 13:
                return((T)(object)(Double) new Random().NextDouble());

            case 14:
                return((T)(object)"☢☢☢");

            case 15:
            {
                IConstantLengthArray cla  = (IConstantLengthArray)type;
                ArrayList            rval = new ArrayList(cla.GetLength());
                for (int i = cla.GetLength(); i != 0; i--)
                {
                    rval.Add(value <object>(sf, cla.GetGroundType()));
                }
                return((T)(object)rval);
            }

            case 17:
            {
                ISingleArgumentType cla = (ISingleArgumentType)type;
                int       length        = (int)Math.Sqrt(reflectiveInitSize);
                ArrayList rval          = new ArrayList(length);
                while (0 != length--)
                {
                    rval.Add(value <object>(sf, cla.GetGroundType()));
                }
                return((T)(object)rval);
            }

            case 18:
            {
                ISingleArgumentType cla = (ISingleArgumentType)type;
                int           length    = (int)Math.Sqrt(reflectiveInitSize);
                List <Object> rval      = new List <Object>();
                while (0 != length--)
                {
                    rval.Add(value <object>(sf, cla.GetGroundType()));
                }
                return((T)(object)rval);
            }

            case 19:
            {
                ISingleArgumentType cla = (ISingleArgumentType)type;
                int length            = (int)Math.Sqrt(reflectiveInitSize);
                HashSet <Object> rval = new HashSet <Object>();
                while (0 != length--)
                {
                    rval.Add(value <object>(sf, cla.GetGroundType()));
                }
                return((T)(object)rval);
            }

            case 20:
                return((T)(object)new Dictionary <Object, Object>());

            default:
                throw new Exception();
            }
        }