/// <summary>
 /// Creates a new dependent checked list box.
 /// </summary>
 public UpdateCheckedListBox()
 {
     // Create all dependent sentries.
     _depEnabled = Dependent.New("UpdateCheckedListBox.Enabled", UpdateEnabled);
     _depItems = Dependent.New("UpdateCheckedListBox.Items", UpdateItems);
     _depItemCheckState = Dependent.New("UpdateCheckedListBox.ItemCheckState", UpdateItemCheckState);
 }
 /// <summary>
 /// Creates a new dependent list box.
 /// </summary>
 public UpdateListBox()
 {
     // Create all dependent sentries.
     _depEnabled = Dependent.New("UpdateListBox.Enabled", UpdateEnabled );
     _depItems = Dependent.New("UpdateListBox.Items", UpdateItems );
     _depSelectedItem = Dependent.New("UpdateListBox.SelectedItem", UpdateSelectedItem );
 }
 /// <summary>
 /// Creates a new dependent trackbar.
 /// </summary>
 public UpdateNumericUpDown()
 {
     _depEnabled = Dependent.New("UpdateNumericUpDown.Enabled", UpdateEnabled);
     _depValueAndRange = Dependent.New("UpdateNumericUpDown.ValueAndRange", UpdateValueAndRange);
     _depIncrement = Dependent.New("UpdateNumericUpDown.Increment", UpdateIncrement);
     _helper = new GuiUpdateHelper(this, _depEnabled, _depValueAndRange, _depIncrement);
 }
        public ScheduleSlotViewModel(Slot slot, Schedule schedule, ImageCache imageCache)
        {
            _slot = slot;
            _schedule = schedule;
            _imageCache = imageCache;

            _sessionPlace = new Dependent<SessionPlace>(() => SessionPlace);
        }
Beispiel #5
0
 public Tree()
 {
     _depNodes = new Dependent(delegate
     {
         _root.UpdateNodes();
     });
     _depNodes.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
 }
        public UpdateErrorProvider(IContainer container)
        {
            _visErrorText = new Dependent(UpdateError);
            container.Add(this);

            InitializeComponent();
            Application.Idle += new EventHandler(Application_Idle);
        }
 /// <summary>
 /// Creates a new dependent tree view.
 /// </summary>
 public UpdateTreeView()
 {
     // Create all dependent sentries.
     _depEnabled = new Dependent( UpdateEnabled );
     _depNodes = new Dependent( UpdateNodes );
     _depRecursive = new Dependent( UpdateRecursive );
     _depSelectedNode = new Dependent( UpdateSelectedNode );
 }
 /// <summary>
 /// Creates a new dependent month calendar.
 /// </summary>
 public UpdateMonthCalendar()
 {
     // Create all dependent sentries.
     _depEnabled = Dependent.New("UpdateMonthCalendar.Enabled", UpdateEnabled);
     _depSelection = Dependent.New("UpdateMonthCalendar.Selection", UpdateSelection);
     _depAnnuallyBoldedDates = Dependent.New("UpdateMonthCalendar.AnuallyBoldedDates", UpdateAnnuallyBoldedDates);
     _depMonthlyBoldedDates = Dependent.New("UpdateMonthCalendar.MonthlyBoldedDates", UpdateMonthlyBoldedDates);
     _depBoldedDates = Dependent.New("UpdateMonthCalendar.BoldedDates", UpdateBoldedDates);
 }
 public void Initialize()
 {
     _gained = false;
     _independent = new NotifyingIndependent();
     _independent.OnGainDependent += () => { _gained = true; };
     _independent.OnLoseDependent += () => { _lost = true; };
     _dependent = new Dependent(() => { _independent.OnGet(); });
     _secondDependent = new Dependent(() => { _independent.OnGet(); });
 }
        public ScheduleSlotViewModel(Time time, Individual individual, Schedule schedule, SelectionModel selection)
        {
            _time = time;
            _individual = individual;
            _schedule = schedule;
            _selection = selection;

            _sessionPlace = new Dependent<SessionPlace>(() => SessionPlace);
        }
        /// <summary>
        /// Creates a new dependent radio button.
        /// </summary>
        public UpdateRadioButton()
        {
            // Create all dependent sentries.
            _depChecked = Dependent.New("UpdateRadioButton.Checked", UpdateChecked);
            _depEnabled = Dependent.New("UpdateRadioButton.Enabled", UpdateEnabled);

            // Turn off AutoCheck by default.
            base.AutoCheck = false;
        }
        /// <summary>
        /// Creates a new dependent form map without adding it to a container.
        /// </summary>
        public UpdateFormMap()
        {
            InitializeComponent();

            // Create all dependent sentries.
            _depForms = new Dependent( UpdateForms );

            // Register idle-time updates.
            Application.Idle += new EventHandler(Application_Idle);
        }
        /// <summary>
        /// Creates a new dependent form map inside a container.
        /// </summary>
        /// <param name="container">The container to which to add the dependent form map.</param>
        public UpdateFormMap(System.ComponentModel.IContainer container)
        {
            container.Add(this);
            InitializeComponent();

            // Create all dependent sentries.
            _depForms = new Dependent( UpdateForms );

            // Register idle-time updates.
            Application.Idle += new EventHandler(Application_Idle);
        }
        public ObjectPropertyCollection(IObjectInstance objectInstance, ClassProperty classProperty)
            : base(objectInstance, classProperty)
        {
            if (ClassProperty.CanRead)
            {
                // When the collection is out of date, update it from the wrapped object.
                _depCollection = new Dependent(OnUpdateCollection);

                // When the property becomes out of date, trigger an update.
                _depCollection.Invalidated += TriggerUpdate;
            }
        }
        public async Task <IEnumerable <string> > Query(Dependent dep)
        {
            var repoColl = new RepositoryCollection();

            repoColl.Add(dep.User, dep.Repository);
            SearchCodeResult?projs = null;

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    System.Console.WriteLine($"{dep} searching for project files");
                    projs = await _githubClientProvider.Client.Search.SearchCode(new SearchCodeRequest()
                    {
                        Extensions = new string[] { "csproj" },
                        Repos      = repoColl
                    });
                    await PrintAndWaitForReset();

                    if (projs.IncompleteResults)
                    {
                        System.Console.WriteLine($"{dep} failed to retrieve contained projects.  Trying again");
                    }
                    else if (projs.Items.Count == 0)
                    {
                        System.Console.WriteLine($"{dep} contained projects returned zero.  Trying again");
                    }
                    else
                    {
                        break;
                    }
                    await Task.Delay(5000);
                }
                catch (HttpRequestException)
                {
                    System.Console.WriteLine($"{dep} failed to retrieve patcher listings.  Trying again");
                }
            }

            if (projs?.IncompleteResults ?? true)
            {
                throw new ArgumentException($"{dep} failed to retrieve patcher listings");
            }

            var ret = projs.Items
                      .OrderBy(i => i.Name)
                      .Select(i => i.Path)
                      .ToArray();

            System.Console.WriteLine($"{dep} retrieved project files:{Environment.NewLine}   {string.Join($"{Environment.NewLine}   ", ret)}");
            return(ret);
        }
        private Task <CreateDependentResponse> CreateResponse(Dependent dependent, Employee employee)
        {
            var dependentResponse = Mapper.Map <DependentResponse>(dependent);
            var employeeResponse  = Mapper.Map <EmployeeResponse>(employee);

            var response = new CreateDependentResponse
            {
                Employee  = employeeResponse,
                Dependent = dependentResponse
            };

            return(Task.FromResult(response));
        }
        public async Task <ActionResult> ConfirmDelete(int id, bool?retry)
        {
            Dependent dependent = await GetDependentAsync(id);

            if (dependent == null)
            {
                return(View("NotFoundError"));
            }

            ViewBag.Retry = retry ?? false;

            return(View(dependent));
        }
Beispiel #18
0
        public async Task <SaveDependentResponse> SaveAsync(Dependent dependent)
        {
            try
            {
                await _dependentRepository.AddAsync(dependent);

                return(new SaveDependentResponse(dependent));
            }
            catch (Exception ex)
            {
                return(new SaveDependentResponse($"An error occurred when saving the category: {ex.Message}"));
            }
        }
Beispiel #19
0
        /// <summary>
        /// Creates a new dependent grid.
        /// </summary>
        public UpdateGrid()
        {
            // Create the data source.
            _table = new DataTable();
            _table.ColumnChanged += new DataColumnChangeEventHandler(OnColumnChanged);
            _table.RowDeleting   += new DataRowChangeEventHandler(OnRowDeleting);

            // Create all dependent sentries.
            _depEnabled   = Dependent.New("UpdateGrid.Enabled", UpdateEnabled);
            _depColumns   = Dependent.New("UpdateGrid.Columns", UpdateColumns);
            _depItems     = Dependent.New("UpdateGrid.Items", UpdateItems);
            _depItemValue = Dependent.New("UpdateGrid.ItemValue", UpdateItemValue);
        }
        //#region GetAllDependents...
        //public List<DependentModel> GetAllStaffDependents(int Id)
        //{
        //    RegisterRepository rp = new RegisterRepository();
        //    using (var deprepo = new DependentRepository())
        //    {
        //        var name = rp.GetAll().ToList().Find(x => x.Id == Id);

        //        var user = deprepo.GetAll().FindAll(x => x.PatientId == Id).ToList();

        //        return user.Select(x => new DependentModel()
        //        {
        //            DependentId = x.DependentId,
        //            IdentityNo = x.IdentityNo,
        //            DependentFname = x.DependentFname,
        //            DependentSname = x.DependentSname,
        //            DependentRole = x.DependentRole,
        //            DOB_Dependent = x.DOB_Dependent,
        //            Sex = x.Sex,
        //            Title = x.Title,
        //            Age = x.Age,
        //            DependentAllergy = x.DependentAllergy,
        //            patientName = name.FullName
        //        }).ToList();
        //    }
        //}
        //#endregion

        #region GetDependentId...
        public DependentModel GetDependentId(int?id)
        {
            DependentModel cv = new DependentModel();

            using (var deprepo = new DependentRepository())
            {
                Dependent _dep = deprepo.GetById(id.Value);

                cv.DependentId = _dep.DependentId;

                return(cv);
            }
        }
        public async Task <ActionResult> EditDependent(Dependent dependent)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dependent).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction($"Details/{dependent.EmployeeId}"));
            }

            ViewBag.RelationId = new SelectList(await this.GetRelations(), "RelationId", "Name", dependent.RelationId);
            return(View(dependent));
        }
Beispiel #22
0
        public override Equation <T> Derivative()
        {
            T[] newCoefficients = new T[Order - 1];
            for (int i = Order; i > 0; i--)
            {
                newCoefficients[Order - i] = Coefficients[Order - i] * (dynamic)i;
            }
            PolynomialEquation <T> newPoly = new PolynomialEquation <T>(newCoefficients);

            newPoly.SetGain(Gain);
            newPoly.SetDependent(Dependent);
            return(newPoly * Dependent.Derivative());
        }
        public DependentModel PostEditMethod(DependentModel cv)
        {
            //string date = cv.DOB_Dependent.ToString("d");
            string result      = cv.DOB_Dependent.Substring(6);
            int    currentyear = DateTime.Now.Year;

            int age = currentyear - Convert.ToInt32(result);

            using (var deprepo = new DependentRepository())
            {
                if (cv.DependentId == 0)
                {
                    Dependent _dependent = new Dependent
                    {
                        DependentId      = cv.DependentId,
                        IdentityNo       = cv.IdentityNo,
                        DependentFname   = cv.DependentFname,
                        DependentSname   = cv.DependentSname,
                        DependentRole    = cv.DependentRole,
                        DOB_Dependent    = cv.DOB_Dependent, //date,
                        Sex              = cv.Sex,
                        Title            = cv.Title,
                        Age              = Convert.ToString(age),
                        DependentAllergy = cv.DependentAllergy,
                    };

                    deprepo.Insert(_dependent);
                }

                else
                {
                    Dependent _dependent = deprepo.GetById(cv.DependentId);

                    _dependent.DependentId      = cv.DependentId;
                    _dependent.IdentityNo       = cv.IdentityNo;
                    _dependent.DependentFname   = cv.DependentFname;
                    _dependent.DependentSname   = cv.DependentSname;
                    _dependent.DependentRole    = cv.DependentRole;
                    _dependent.DOB_Dependent    = cv.DOB_Dependent;// date;
                    _dependent.Sex              = cv.Sex;
                    _dependent.Age              = Convert.ToString(age);
                    _dependent.Title            = cv.Title;
                    _dependent.DependentAllergy = cv.DependentAllergy;

                    deprepo.Update(_dependent);
                }

                return(cv);
            }
        }
Beispiel #24
0
 public Dependent Create(int organizationId, int employeeId, Dependent dependent)
 {
     if (_employeeLogic.Get(organizationId, employeeId) == null)
     {
         return(null);
     }
     else
     {
         dependent.EmployeeId = employeeId;
         _dataContext.Dependents.Add(dependent);
         _dataContext.SaveChanges();
         return(dependent);
     }
 }
Beispiel #25
0
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassMember classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Dependent(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     }
 }
Beispiel #26
0
        public void AddDependent(Person person)
        {
            if (Dependents.All(preexistingDependent => preexistingDependent.Person.Id != person.Id))
            {
                var dependent = new Dependent(Guid.NewGuid(), person);
                Dependents.Append(dependent);

                PublishDomainEvent(new AddEmployeeDependent
                {
                    Employee  = Id,
                    Dependent = dependent
                });
            }
        }
        /// <summary>
        /// Get a dependent
        /// </summary>
        /// <param name="empid">The employee id</param>
        /// <param name="id">The unique identifier</param>
        /// <returns>Returns the dependent data for the given id </returns>
        public Dependent Get(string empid, string id)
        {
            var response = new Dependent();

            try
            {
                response = Data.Dependent(empid, id);
            }
            catch (Exception e)
            {
                logger.Error(e);
            }
            return(response);
        }
Beispiel #28
0
        public ObjectPropertyCollection(IObjectInstance objectInstance, ClassProperty classProperty, bool hasChildObjects)
            : base(objectInstance, classProperty)
        {
            _hasChildObjects = hasChildObjects;

            if (ClassProperty.CanRead)
            {
                // Bind to the observable collection.
                ClassProperty.SetUserOutput(ObjectInstance, _collection);

                // When the collection is out of date, update it from the wrapped object.
                _depCollection = new Dependent(OnUpdateCollection);
            }
        }
Beispiel #29
0
        public override T GetValue(params T[] input)
        {
            if (input.Length != ParamsLength)
            {
                throw new InvalidParamsLength();
            }
            T aInput = input[0];

            if (Dependent != null)
            {
                aInput = Dependent.GetValue(input);
            }
            return(Gain * ((dynamic)a.GetValue(aInput) * b.GetValue(aInput)));
        }
        public ObjectPropertyCollection(IObjectInstance objectInstance, ClassProperty classProperty, bool hasChildObjects)
            : base(objectInstance, classProperty)
        {
            _hasChildObjects = hasChildObjects;

            if (ClassProperty.CanRead)
            {
                // Bind to the observable collection.
                ClassProperty.SetUserOutput(ObjectInstance, _collection);

                // When the collection is out of date, update it from the wrapped object.
                _depCollection = new Dependent(OnUpdateCollection);
            }
        }
Beispiel #31
0
        private Dependent FindDependent(ControlData cd, string name, string shortName)
        {
            Dependent dep = (from d in cd.Dependents where d.Prop == name select d).FirstOrDefault();

            if (dep == null)
            {
                dep = new Dependent {
                    Prop      = name,
                    PropShort = shortName
                };
                cd.Dependents.Add(dep);
            }
            return(dep);
        }
Beispiel #32
0
        public override T GetValue(params T[] input)
        {
            if (input.Length != ParamsLength)
            {
                throw new InvalidParamsLength();
            }
            T value = input[0];

            if (Dependent != null)
            {
                value = Dependent.GetValue(value);
            }
            return(Gain * (dynamic)ComputeOutput(value));
        }
        public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty, bool hasChildObject)
            : base(objectInstance, classProperty)
        {
            _hasChildObject = hasChildObject;

            if (ClassProperty.CanRead)
            {
                // When the property is out of date, update it from the wrapped object.
                _depProperty = new Dependent(delegate
                {
                    object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
                    if (_hasChildObject)
                    {
                        IObjectInstance oldChild = _child;
                        object oldValue          = oldChild == null ? null : oldChild.WrappedObject;

                        _child = null;
                        IObjectInstance wrapper;
                        if (value == null)
                        {
                            wrapper = null;
                        }
                        else if (value == oldValue)
                        {
                            wrapper = oldChild;
                            _child  = wrapper;
                        }
                        else
                        {
                            if (WrapObject(value, out wrapper))
                            {
                                _child = wrapper;
                            }
                        }
                        ClassProperty.SetUserOutput(ObjectInstance, wrapper);

                        if (oldChild != _child && oldChild != null)
                        {
                            ObjectInstance.Tree.RemoveKey(oldValue);
                            oldChild.Dispose();
                        }
                    }
                    else
                    {
                        ClassProperty.SetUserOutput(ObjectInstance, value);
                    }
                });
            }
        }
Beispiel #34
0
        public ActionResult Delete(string employeeFirstName, string employeeLastName, int id, int employeeId = 0)
        {
            EmployeeContext employeeContext = new EmployeeContext();

            ViewBag.EmployeeId        = employeeId;
            ViewBag.EmployeeFirstName = employeeFirstName;
            ViewBag.EmployeeLastName  = employeeLastName;
            Dependent dependent = employeeContext.Dependents.Find(id);

            if (dependent == null)
            {
                return(HttpNotFound());
            }
            return(View(dependent));
        }
        public Boolean Update(Dependent current)
        {
            IPayrollRepository repo = GetRepository();

            Dependent original = repo.GetDependentById(current.Id);

            if (original != null)
            {
                current.RelationshipId = original.RelationshipId;

                return(repo.Update(current, original));
            }

            return(false);
        }
        public void WhitespaceFirstName()
        {
            var exceptionOccurred = false;

            try
            {
                var dependent = new Dependent("   ");
            }
            catch (ArgumentException e)
            {
                exceptionOccurred = true;
            }

            Assert.IsTrue(exceptionOccurred);
        }
        public Decimal GetDependentCost(Int32 id)
        {
            IPayrollRepository repo = GetRepository();
            Decimal            cost = 0;

            Dependent dependent = repo.GetDependentById(id);

            if (dependent != null)
            {
                BenefitCalculator calc = new BenefitCalculator(dependent.Employee.BenefitPlan, dependent.Employee.PayCycle, new NameDiscount());
                cost = calc.CalculatePayPeriodCost(dependent);
            }

            return(cost);
        }
        public void EmptyFirstName()
        {
            var exceptionOccurred = false;

            try
            {
                var dependent = new Dependent(string.Empty);
            }
            catch (ArgumentException e)
            {
                exceptionOccurred = true;
            }

            Assert.IsTrue(exceptionOccurred);
        }
Beispiel #39
0
        public ActionResult Edit()
        {
            Dependent dependent = new Dependent();

            TryUpdateModel(dependent);
            if (ModelState.IsValid)
            {
                EmployeeContext employeeContext = new EmployeeContext();
                employeeContext.Entry(dependent).State = System.Data.Entity.EntityState.Modified;
                employeeContext.SaveChanges();
                var employee = employeeContext.Employees.Single(x => x.EmployeeId == dependent.EmployeeId);
                return(RedirectToAction("Index", new { employeeId = dependent.EmployeeId, employeeFirstName = employee.FirstName, employeeLastName = employee.LastName }));
            }
            return(View());
        }
Beispiel #40
0
        public async Task <IActionResult> AddEmployeeDependent([FromRoute] long id, [FromBody] Dependent dependent)
        {
            var employee = await _unitOfWork.Employees.GetByIdAsync(id);

            if (employee == null)
            {
                return(NotFound());
            }

            employee.Dependents.Add(dependent);

            await _unitOfWork.CompleteAsync();

            return(Ok(employee));
        }
Beispiel #41
0
        public ActionResult Create_Post()
        {
            Dependent dependent = new Dependent();

            TryUpdateModel(dependent);
            if (ModelState.IsValid)
            {
                EmployeeContext employeeContext = new EmployeeContext();
                employeeContext.Dependents.Add(dependent);
                employeeContext.SaveChanges();
                var employee = employeeContext.Employees.Single(x => x.EmployeeId == dependent.EmployeeId);
                return(RedirectToAction("Index", new { employeeId = dependent.EmployeeId, employeeFirstName = employee.FirstName, employeeLastName = employee.LastName }));
            }
            return(View());
        }
Beispiel #42
0
        static void DisplayDependent(TransmittalFile tf, JsonOutput output)
        {
            int numberOfDependents = tf.numberOfDependents;

            for (int i = 0; i < numberOfDependents; ++i)
            {
                TransmittalFile childTF       = tf.getDependent(i);
                FileType        ft            = childTF.FileType;
                var             jsondependent = new Dependent();
                jsondependent.Name = ft.ToString();
                jsondependent.Path = childTF.sourcePath;
                output.Dependents.Add(jsondependent);
                DisplayDependent(childTF, output);
            }
        }
        public async Task <IActionResult> Create([Bind("ID,fname,lname,dcode,employeeID")] Dependent dependent)
        {
            if (ModelState.IsValid)
            {
                int id = _context.Employee.FirstOrDefault().ID;
                dependent.employeeID = id;
                _context.Add(dependent);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), "Employees", new { ID = id }));
            }
            ViewData["employeeID"] = new SelectList(_context.Employee, "ID", "ID", dependent.employeeID);
            return(View(dependent));
        }
Beispiel #44
0
        public void CalculateDeductionDiscounted()
        {
            // Arrange
            EmployeeController employeeController = new EmployeeController();
            Employee           employee           = new Employee()
            {
                EmployeeId = 1,
                FirstName  = "Allene",
                LastName   = "Harvey"
            };

            Dependent dependent = new Dependent()
            {
                EmployeeId  = 1,
                FirstName   = "Alice",
                LastName    = "Harvey",
                Type        = "Child",
                DependentId = 1
            };

            Dependent spouse = new Dependent()
            {
                EmployeeId  = 1,
                FirstName   = "Alicia",
                LastName    = "Harvey",
                Type        = "Spouse",
                DependentId = 2
            };

            employee.Dependents.Add(dependent);
            employee.Dependents.Add(spouse);
            // Act
            decimal employeeResult  = employeeController.CalcDeduction(employee);
            decimal dependentResult = 0;

            foreach (var depend in employee.Dependents)
            {
                dependentResult += employeeController.CalcDeduction(depend);
            }
            decimal actualDeduction = employeeResult + dependentResult;

            // Assert
            decimal employeeDeduction  = 100 / 26;
            decimal dependentDeduction = 50 / 26;
            decimal estimatedDeduction = employeeDeduction + (dependentDeduction * 2);

            Assert.AreEqual(actualDeduction, estimatedDeduction);
        }
        public void ParseExcelFileTest()
        {
            string filePath = Path.Combine(this.TestContext.TestDeploymentDir, "Files\\1095_Import_WithData.xlsx");

            IExcelFileParser parser = new ExcelFileParser(filePath, "Employees", 1, 2);
            IDictionary <int, IList <string> > fileErrors = new Dictionary <int, IList <string> >();
            IObjectValidator validator = new ObjectValidator();

            int rowIndex = parser.RowStart;

            foreach (dynamic row in parser.ParseFile())
            {
                List <string> errors = new List <string>();

                Employee rowObj = new Employee();
                rowObj.MapValues(rowIndex, row, validator, ref errors);
                validator.TryValidate(rowObj, ref errors);

                if (errors.Count > 0)
                {
                    fileErrors.Add(rowIndex, errors);
                }
                rowIndex++;
            }

            Assert.IsTrue(fileErrors.Count >= 2);

            parser.SheetName = "Dependents";
            fileErrors       = new Dictionary <int, IList <string> >();
            rowIndex         = parser.RowStart;

            foreach (dynamic row in parser.ParseFile())
            {
                List <string> errors = new List <string>();

                Dependent rowObj = new Dependent();
                rowObj.MapValues(rowIndex, row, validator, ref errors);
                validator.TryValidate(rowObj, ref errors);

                if (errors.Count > 0)
                {
                    fileErrors.Add(rowIndex, errors);
                }
                rowIndex++;
            }

            Assert.IsTrue(fileErrors.Count == 0);
        }
        public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty, bool hasChildObject)
            : base(objectInstance, classProperty)
        {
            _hasChildObject = hasChildObject;

            if (ClassProperty.CanRead)
            {
                // When the property is out of date, update it from the wrapped object.
                _depProperty = new Dependent(delegate
                {
                    object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
                    if (_hasChildObject)
                    {
                        IObjectInstance oldChild = _child;
                        object oldValue = oldChild == null ? null : oldChild.WrappedObject;

                        _child = null;
                        IObjectInstance wrapper;
                        if (value == null)
                            wrapper = null;
                        else if (value == oldValue)
                        {
                            wrapper = oldChild;
                            _child = wrapper;
                        }
                        else
                        {
                            if (WrapObject(value, out wrapper))
                                _child = wrapper;
                        }
                        ClassProperty.SetUserOutput(ObjectInstance, wrapper);

                        if (oldChild != _child && oldChild != null)
                        {
                            ObjectInstance.Tree.RemoveKey(oldValue);
                            oldChild.Dispose();
                        }
                    }
                    else
                    {
                        ClassProperty.SetUserOutput(ObjectInstance, value);
                    }
                });
            }
        }
        public void DependentIsAsSmallAsPossible()
        {
            GC.Collect();
            long start = GC.GetTotalMemory(true);
            Dependent<int> newDependent = new Dependent<int>(() => 42);
            long end = GC.GetTotalMemory(true);

            // Started at 260.
            // Making Precedent a base class: 248.
            // Removing Gain/LoseDependent events: 232.
            // Making IsUpToDate no longer a precident: 192.
            // Custom linked list implementation for dependents: 152.
            // Custom linked list implementation for precedents: 112.
            // Other optimizations: 104.
            // Added WeakReferenceToSelf: 108.
            // Removed WeakReferenceToSelf: 104.
            Assert.AreEqual(104 + DependentPlatformOffset, end - start);

            int value = newDependent;
            Assert.AreEqual(42, value);
        }
        public void SingleDependencyBeforeUpdateIsAsSmallAsPossible()
        {
            GC.Collect();
            long start = GC.GetTotalMemory(true);
            Independent<int> newIndependent = new Independent<int>();
            Dependent<int> newDependent = new Dependent<int>(() => newIndependent);
            newIndependent.Value = 42;
            long end = GC.GetTotalMemory(true);

            // Started at 336.
            // Making Precedent a base class: 312.
            // Removing Gain/LoseDependent events: 288.
            // Making IsUpToDate no longer a precident: 248.
            // Custom linked list implementation for dependents: 200.
            // Custom linked list implementation for precedents: 160.
            // Other optimizations: 144.
            // Added WeakReferenceToSelf: 148.
            // Removed WeakReferenceToSelf: 124.
            Assert.AreEqual(124 + IndependentPlatformOffset, end - start);

            int value = newDependent;
            Assert.AreEqual(42, value);
        }
 public ViewModelContainer(Action firePropertyChanged, Func<object> constructor)
 {
     _firePropertyChanged = firePropertyChanged;
     _dependent = new Dependent(() => _viewModel = ForView.Wrap(constructor()));
     _dependent.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
 }
            public DependentListViewGroup(object tag, GroupDelegates groupDelegates, ListView listView)
            {
                _tag = tag;
                _groupDelegates = groupDelegates;
                _listView = listView;

                _depName = Dependent.New("DependentListViewGroup.Name", UpdateName);
                _depHeader = Dependent.New("DependentListViewGroup.Header", UpdateHeader);
                _depAlignment = Dependent.New("DependentListViewGroup.Alignment", UpdateAlignment);
            }
 /// <summary>Creates a new dependent list view.</summary>
 public UpdateListView()
 {
     // Create all dependent sentries.
     _depEnabled = Dependent.New("UpdateListView.Enabled", UpdateEnabled);
     _depGroups = Dependent.New("UpdateListView.Groups", UpdateGroups);
     _depGroupProperties = Dependent.New("UpdateListView.GroupProperties", UpdateGroupProperties);
     _depItems = Dependent.New("UpdateListView.Items", UpdateItems);
     _depItemGroups = Dependent.New("UpdateListView.ItemGroups", UpdateItemGroups);
     _depItemText = Dependent.New("UpdateListView.ItemText", UpdateItemText);
     _depItemSelected = Dependent.New("UpdateListView.ItemSelected", UpdateItemSelected);
     _depItemChecked = Dependent.New("UpdateListView.ItemChecked", UpdateItemChecked);
     _depItemImageIndex = Dependent.New("UpdateListView.ItemImageIndex", UpdateItemImageIndex);
     _depSubItems = Dependent.New("UpdateListView.SubItems", UpdateSubItems);
 }
 public DependentListViewItem(object tag, IDictionary<object, ListViewGroup> groupsByTag, ItemDelegates itemDelegates)
 {
     base.Tag = tag;
     _groupsByTag = groupsByTag;
     _itemDelegates = itemDelegates;
     _depGroup = Dependent.New("UpdateListViewItem.Group", UpdateGroup);
     _depText = Dependent.New("UpdateListViewItem.Text", UpdateText);
     _depSelected = Dependent.New("UpdateListViewItem.Selected", UpdateSelected);
     _depChecked = Dependent.New("UpdateListViewItem.Checked", UpdateChecked);
     _depImageIndex = Dependent.New("UpdateListViewItem.ImageIndex", UpdateImageIndex);
     _depSubItems = Dependent.New("UpdateListViewItem.SubItems", UpdateSubItems);
 }
 public ComboBoxItem( object tag, GetObjectStringDelegate getItemText )
 {
     _tag = tag;
     _getItemText = getItemText;
     _depText = Dependent.New("ComboBoxItem.Text", UpdateText );
 }
 /// <summary>
 /// Creates a new dependent date/time picker.
 /// </summary>
 public UpdateDateTimePicker()
 {
     // Create all dependent sentries.
     _depEnabled = Dependent.New("UpdateDateTimePicker.Enabled", UpdateEnabled);
     _depValue = Dependent.New("UpdateDateTimePicker.Value", UpdateValue);
 }
Beispiel #55
0
 /// <summary>
 /// Creates a new dependent label.
 /// </summary>
 public UpdateLabel()
 {
     // Create all dependent sentries.
     _depText = Dependent.New("UpdateLabel.Text", UpdateText);
     _depEnabled = Dependent.New("UpdateLabel.Enabled", UpdateEnabled);
 }
 public ContactListViewModel(ContactList contactList)
 {
     _contactList = contactList;
     _depContactViewModels = new Dependent(UpdateContactViewModels);
     _depContactViewModels.Invalidated += new Action(_depContactViewModels_Invalidated);
 }
 public TargetCollection(SourceCollection source)
 {
     _source = source;
     _depResults = new Dependent(UpdateResults);
 }
 public TargetThread(SourceThread[] sources)
 {
     _sources = sources;
     _thread = new Thread(ThreadProc);
     _total = new Dependent<int>(() => _sources.Sum(source => source.Value));
 }
 public DirectDependent(SourceData source)
 {
     _source = source;
     _property = new Dependent<int>(() => _source.SourceProperty);
 }
 public ListBoxItem( object tag, GetObjectStringDelegate getItemText, GetObjectBoolDelegate getItemSelected, SetObjectBoolDelegate setItemSelected )
 {
     _tag = tag;
     _getItemText = getItemText;
     _getItemSelected = getItemSelected;
     _setItemSelected = setItemSelected;
     _depText = Dependent.New("ListBoxItem.Text", UpdateText);
     _depSelected = Dependent.New("ListBoxItem.Selected", UpdateSelected);
 }