예제 #1
0
        public Faker()
        {
            List <Assembly> Plugins = Plugin.LoadPlugin(_path + Plugin.path + "IntegerGenerator.dll", _path + Plugin.path + "StringGenerator.dll");

            Generators = Plugin.GetGenerators(Plugins);
            Generators.Add(typeof(bool), new BooleanGenerator());
            Generators.Add(typeof(byte), new ByteGenerator());
            Generators.Add(typeof(long), new LongGenerator());
            Generators.Add(typeof(float), new FloatGenerator());
            Generators.Add(typeof(double), new DoubleGenerator());
            Generators.Add(typeof(char), new CharGenerator());
            listGenerator = new ListGenerator(this);
        }
예제 #2
0
        public Faker()
        {
            List <Assembly> Plugins = Plugin.LoadPlugin(Path.GetDirectoryName(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName) + Plugin.path + "ByteGenerator.dll", Path.GetDirectoryName(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName) + Plugin.path + "FloatGenerator.dll");

            Generators = Plugin.GetGenerators(Plugins);
            Generators.Add(typeof(int), new IntGenerator());
            Generators.Add(typeof(bool), new BoolGenerator());
            Generators.Add(typeof(DateTime), new DateTimeGenerator());
            Generators.Add(typeof(char), new CharGenerator());
            Generators.Add(typeof(double), new DoubleGenerator());
            Generators.Add(typeof(long), new LongGenerator());
            Generators.Add(typeof(string), new StringGenerator());
            listGenerator = new ListGenerator(this);
        }
예제 #3
0
파일: Faker.cs 프로젝트: JenyaKuzya/Faker
        public Faker()
        {
            generatedTypes = new List <Type>();

            asm = Assembly.LoadFrom("Plugins\\Plugins.dll");

            baseTypesGenerators = new Dictionary <Type, IValueGenerator>
            {
                { typeof(object), new ObjectGenerator() },
                { typeof(char), new CharGenerator() },
                { typeof(bool), new BoolGenerator() },
                { typeof(byte), new ByteGenerator() },
                { typeof(sbyte), new SByteGenerator() },
                { typeof(int), new IntGenerator() },
                { typeof(uint), new UIntGenerator() },
                { typeof(short), new ShortGenerator() },
                { typeof(ushort), new UShortGenerator() },
                { typeof(long), new LongGenerator() },
                { typeof(ulong), new ULongGenerator() },
                { typeof(decimal), new DecimalGenerator() },
                { typeof(float), new FloatGenerator() },
                { typeof(double), new DoubleGenerator() },
                { typeof(DateTime), new DateGenerator() },
                { typeof(string), new StringGenerator() }
            };

            listGenerator = new ListGenerator(baseTypesGenerators);

            // плагины
            var types = asm.GetTypes().Where(t => t.GetInterfaces().Where(i => i == typeof(IPlugin)).Any());

            foreach (var type in types)
            {
                var plugin = asm.CreateInstance(type.FullName) as IPlugin;
                if (!baseTypesGenerators.ContainsKey(plugin.GeneratedType))
                {
                    baseTypesGenerators.Add(plugin.GeneratedType, plugin);
                }
            }
        }