示例#1
0
        private void EditEntryFormLoad(object sender, EventArgs e)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            for (int l = 0; l < Data.Count; l++)
            {
                ProcessDataObject dataObject1;
                if (IsStudent)
                {
                    dataObject1 = serializer.Deserialize <ProcessStudentSalaryDataObject>(Data[l]);
                }
                else
                {
                    dataObject1 = serializer.Deserialize <ProcessLecturerSalaryDataObject>(Data[l]);
                }
                _dataObjects.Add(dataObject1);
            }

            if (_dataObjects.Count == 0)
            {
                return;
            }

            ProcessDataObject dataObject = _dataObjects[0];

            List <PropertyInfo> propertyInfos = dataObject.GetType().GetProperties().ToList();

            for (int l = 0; l < propertyInfos.Count; l++)
            {
                _table.Columns.Add(propertyInfos[l].Name);
            }

            PopulateGrid();
            DisableEditing();
        }
示例#2
0
        private void PopulateGrid()
        {
            for (int l = 0; l < _dataObjects.Count; l++)
            {
                DataRow             dataRow       = _table.NewRow();
                ProcessDataObject   dataObject    = _dataObjects[l];
                List <PropertyInfo> propertyInfos = dataObject.GetType().GetProperties().ToList();

                for (int i = 0; i < propertyInfos.Count; i++)
                {
                    dataRow[propertyInfos[i].Name] = propertyInfos[i].GetValue(_dataObjects[l]).ToString();
                }
                _table.Rows.Add(dataRow);
            }
            _grid.DataSource = _table;
        }
示例#3
0
 public void SaveData(ProcessDataObject data)
 {
     // Save some data to the database
 }
示例#4
0
        static void Main(string[] args)
        {
            var fakeRepository  = new ExampleRepository();
            var smoulderFactory = new SmoulderFactory();

            //Object oriented methodology
            var firstSmoulder = smoulderFactory.Build(new ExampleLoader(), new ExampleProcessor(fakeRepository), new ExampleDistributor(), 50000);

            //Run Demo with first Smoulder
            RunDemo(firstSmoulder);


            //Functional methodology
            //Create second smoulder by passing methods to factory, thus removing the requirement to instantiate any worker units
            var secondSmoulder = smoulderFactory.Build <ProcessDataObject, DistributeDataObject>(null, null, null, 50000)
                                 .SetLoaderAction(token =>
            {
                var rng  = new Random();
                var data = new ProcessDataObject {
                    DataValue = rng.Next()
                };
                Thread.Sleep(rng.Next(1, 50));
                return(data);
            })
                                 .SetProcessorAction((data, token) =>
            {
                fakeRepository.SaveData(data);
                var result = new DistributeDataObject
                {
                    DataValue1 = data.DataValue,
                    DataValue2 = data.DataValue / 2
                };

                Random rng = new Random();
                Thread.Sleep(rng.Next(1, 100));

                return(result);
            })
                                 .SetDistributorAction((data, token) =>
            {
                Random rng = new Random();
                Thread.Sleep(rng.Next(1, 25));
            })
                                 .SetLoaderOnError(e => throw new Exception("Throw loader exception with inner exception attached", e))
                                 .SetProcessorOnError(e => throw new Exception("Throw processor exception with inner exception attached", e))
                                 .SetDistributorOnError(e => throw new Exception("Throw distributor exception with inner exception attached", e));

            //Run Demo with second Smoulder
            RunDemo(secondSmoulder);


            //Object oriented methodology with some functional stuff to save having to create oversimple worker units
            //Create third smoulder by mixing the two previous methods
            var thirdSmoulder = smoulderFactory.Build(new ExampleLoader(), new ExampleProcessor(fakeRepository), null, 50000)
                                .SetDistributorAction((data, token) =>
            {
                Random rng = new Random();
                Thread.Sleep(rng.Next(1, 25));
            });

            //Run Demo with third Smoulder
            RunDemo(thirdSmoulder);

            Console.WriteLine("Press enter to finish the Smoulder demonstration process");
            Console.ReadLine();
        }
示例#5
0
 public SalaryProcess(ProcessDataObject data) : base(data)
 {
 }
示例#6
0
 public Process(ProcessDataObject dataObject)
 {
     _data = dataObject;
 }
示例#7
0
 public LecturerSalaryProcess(ProcessDataObject data) : base(data)
 {
 }