/// <summary>
        ///     Adds the item.
        /// </summary>
        /// <param name="index">
        ///     The index.
        /// </param>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="sourceToTarget">
        ///     if set to <c>true</c> from source to target.
        /// </param>
        private void AddItem(int index, object item, bool sourceToTarget = true)
        {
            ICollectionHandler handler     = sourceToTarget ? this.TargetHandler : this.SourceHandler;
            BindContext        bindContext = sourceToTarget ? this.BindTarget : this.BindSource;
            var list = bindContext.Value as IList;

            bool handled = false;

            if (handler != null)
            {
                handled = handler.AddItem(index, item, bindContext.Source, bindContext.Value);
            }

            if (!handled && list != null)
            {
                IDataGenerator dataGenerator            = sourceToTarget ? this.TargetDataGenerator : this.SourceDataGenerator;
                object         parameter                = sourceToTarget ? this.TargetDataParameter : this.SourceDataParameter;
                Func <object, object, object> generator = sourceToTarget ? this.TargetGenerator : this.SourceGenerator;

                if (dataGenerator != null)
                {
                    list.Insert(index, dataGenerator.Generate(item, parameter));
                }
                else if (generator != null)
                {
                    list.Insert(index, generator(item, parameter));
                }
                else
                {
                    list.Insert(index, item);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Overriden GetFrames
 /// </summary>
 /// <returns>The enumeration of frames</returns>
 protected sealed override IEnumerable <DataFrame> GetFrames()
 {
     foreach (object obj in _generator.Generate(_inputQueue))
     {
         if (obj is DataFrame)
         {
             yield return((DataFrame)obj);
         }
         else if (obj is string)
         {
             yield return(new DataFrame((string)obj));
         }
         else if (obj is byte[])
         {
             yield return(new DataFrame((byte[])obj));
         }
         else if (obj is IDictionary)
         {
             yield return(new DataFrame((IDictionary)obj));
         }
         else if (obj is DataKey)
         {
             yield return(new DataFrame((DataKey)obj));
         }
     }
 }
예제 #3
0
        public void Case3()
        {
            _dataGenerator = new AddressInfoXmlGenerator();
            var data = _dataGenerator.Generate(xmlPath, x => x.Name == "Ankara", c => c.Districts.OrderBy(v => v.Zips.OrderByDescending(y => y.Code)));

            _dataGenerator = new AddressInfoCsvGenerator();
            Assert.IsNotNull(_dataGenerator.Save(data), "baþarýlý bir þekilde kaydedildi");
        }
예제 #4
0
        public void Case2()
        {
            _dataGenerator = new AddressInfoCsvGenerator();
            var data = _dataGenerator.Generate(csvPath);

            data.Cities = data.Cities.OrderBy(x => x.Name).ThenBy(x => x.Districts.OrderBy(c => c.Name)).ToList();
            Assert.IsNotNull(_dataGenerator.Save(data), "baþarýlý");
        }
예제 #5
0
        public void Case1()
        {
            _dataGenerator = new AddressInfoCsvGenerator();
            var data = _dataGenerator.Generate <API.Model.AddressInfo>(csvPath, query: x => x.Name == "Antalya");

            _dataGenerator = new AddressInfoXmlGenerator();
            Assert.IsNotNull(_dataGenerator.Save(data), "baþarýlý bir þekilde kaydedildi");
        }
예제 #6
0
파일: Program.cs 프로젝트: StasPI/otus.ru
        static void Main(string[] args)
        {
            ISettings settings = new Settings();
            if (!TryValidateAndParseArgs(args))
                return;

            settings.DataFilePath = _dataFilePath;
            settings.DataFileFormat = _dataFileFormat;
            settings.DataCount = _dataCount;
            
            Console.WriteLine("Generating data...");
            IDataGenerator dataGenerator = GeneratorFactory.GetGenerator(settings);
            dataGenerator.Generate();
            Console.WriteLine($"Generated data in {_dataFilePath}...");
        }
예제 #7
0
        /// <summary>
        /// Creates information system using specific generator type.
        /// </summary>
        /// <param name="type">Type of generator. </param>
        /// <param name="numberOfAttributes">Number of arguments to generate for each row.</param>
        /// <param name="numberOfObjects">Number of rows to generate.</param>
        /// <returns>Information system.</returns>
        public static InformationSystem CreateFromGenerator(IDataGenerator generator, int numberOfAttributes,
                                                            int numberOfObjects)
        {
            IDataGenerator gen = generator;

            gen.NumberOfAttributes = numberOfAttributes;
            gen.NumberOfObjects    = numberOfObjects;

            InformationSystem result = new InformationSystem()
            {
                Confidence = 0.0m,
                Support    = 0.0m,
                Rows       = generator.Generate()
            };

            return(result);
        }
예제 #8
0
        public async Task <IActionResult> Create(GenerationRequest request)
        {
            var result = await _generator.Generate(request.Data.SpeciesCount, request.Data.DinosaursCount);

            return(Ok(result));
        }