public void UpdatePerson(IPerson person) { var ctx = new AddressBookContext(); var entity = ctx.Persons.Find(person.ID); Mappings.Map(person, entity); ctx.SaveChanges(); }
public StudentController(IView view) { this.person = new StudentModel(){ name="Jan",surname="Kowalski" }; this.view = view; }
public IContact AddNewContact(IPerson person, string typeContact, string valueContact) { if (person == null) throw new ArgumentNullException("person"); if (string.IsNullOrWhiteSpace(typeContact)) throw new ArgumentNullException("typeContact"); if (string.IsNullOrWhiteSpace(valueContact)) throw new ArgumentNullException("valueContact"); int newId = 1; while (true) { bool flag = true; foreach (var z in Persons) foreach(var cont in z.Contacts) if (cont.ID == newId) { ++newId; flag = false; } if(flag) break; } var newContact = new Contact(newId, person.ID, typeContact, valueContact); person.Contacts.Add(newContact); RaisePropertyChanged("Persons"); return newContact; }
public void changes_to_the_source_should_be_marshalled_via_a_call_to_send(Mock<SynchronizationContext> synchronizationContext, BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { synchronizationContext.Setup(x => x.Send(It.IsAny<SendOrPostCallback>(), It.IsAny<object>())); sourceObject.Line1 = "Line 1, mighty fine"; synchronizationContext.VerifyAll(); }
/// <summary> /// Adds the person. /// </summary> /// <param name="person">The person.</param> /// <param name="hostName">Name of the host.</param> /// <returns></returns> /// <exception cref="InverGrove.Domain.Exceptions.ParameterNullException">person</exception> public IPerson AddPerson(IPerson person, string hostName) { Guard.ParameterNotNull(person, "person"); /* TODO - Check if this EMAIL address exists. Email will be the sole check to guard against duplicate persons. TODO - People will be a cached list that is placed into cache when a person logs into the website. This list will never be more than a couple hundred (likley around 150) so no big deal caching that. */ var existingPerson = this.personRepository.Get(p => p.EmailPrimary == person.PrimaryEmail).FirstOrDefault().ToModel(); var existingEmail = this.EmailExists(person, existingPerson); if (!string.IsNullOrEmpty(person.PrimaryEmail) && existingEmail) { person.PersonId = existingPerson.PersonId; person.ErrorMessage = "This email address already exists."; return person; } person.PersonId = this.personRepository.Add(person); if (person.IsUser && (person.PersonId > 0)) { this.SendNewUserVerification(person, hostName); } return person; }
public bool IsOlderThan(IPerson other) { DateTime firstDate, secondDate; try { firstDate = DateTime.Parse(this.OtherInfo.Substring(this.OtherInfo.Length - 10)); } catch (Exception) { throw new InvalidCastException("First data is not valid!"); } try { secondDate = DateTime.Parse(other.OtherInfo.Substring(other.OtherInfo.Length - 10)); } catch (Exception) { throw new InvalidCastException("Second data is not valid!"); } return firstDate < secondDate; }
public void it_must_have_a_converter(BindingManager bindingManager, MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { bindingManager.Bindings.Remove(binding); binding.Converter = null; var ex = Assert.Throws<InvalidOperationException>(() => bindingManager.Bindings.Add(binding)); Assert.Equal("All MultiSourceBindings require a converter.", ex.Message); }
public bool ContainsPerson(IPerson person) { if (person == null) throw new ArgumentNullException(nameof(person)); return _cache.ContainsKey(person); }
public void the_converted_value_is_used_when_the_target_is_changed(BindingManager bindingManager, SingleSourceBinding binding, Mock<IValueConverter> converter, IPerson targetObject, IPerson sourceObject) { converter.Setup(x => x.ConvertBack("Value", typeof(string), "parameter", null)).Returns("Converted Value"); targetObject.Address.Line2 = "Value"; Assert.Equal("Converted Value", sourceObject.Address.Line1); converter.VerifyAll(); }
static ProxyTestHelper() { _person = new Person(PersonId); _business = new Business(BusinessId); _location = new Location(LocationId); _phone = new Phone(PhoneId); }
public virtual void MapToEntity(IPersonModel model, ref IPerson entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // Person Properties entity.Hometown = model.Hometown; entity.Country = model.Country; entity.Email = model.Email; entity.Website = model.Website; entity.BirthDate = model.BirthDate; entity.DeathDate = model.DeathDate; // Related Objects entity.PrimaryImageFileId = model.PrimaryImageFileId; entity.PrimaryImageFile = (ImageFile)model.PrimaryImageFile?.MapToEntity(); entity.GenderId = model.GenderId; entity.Gender = (Gender)model.Gender?.MapToEntity(); // Associated Objects entity.CharactersCreated = model.CharactersCreated?.Where(i => i.Active).Select(CreatorCharacterMapperExtensions.MapToEntity).ToList(); entity.PersonAliases = model.PersonAliases?.Where(i => i.Active).Select(PersonAliasMapperExtensions.MapToEntity).ToList(); entity.IssuesWritten = model.IssuesWritten?.Where(i => i.Active).Select(IssueWriterMapperExtensions.MapToEntity).ToList(); entity.MoviesProduced = model.MoviesProduced?.Where(i => i.Active).Select(MovieProducerMapperExtensions.MapToEntity).ToList(); entity.MoviesWritten = model.MoviesWritten?.Where(i => i.Active).Select(MovieWriterMapperExtensions.MapToEntity).ToList(); entity.PromosWritten = model.PromosWritten?.Where(i => i.Active).Select(PromoMapperExtensions.MapToEntity).ToList(); entity.StoryArcsWritten = model.StoryArcsWritten?.Where(i => i.Active).Select(StoryArcWriterMapperExtensions.MapToEntity).ToList(); entity.VolumesWritten = model.VolumesWritten?.Where(i => i.Active).Select(VolumeWriterMapperExtensions.MapToEntity).ToList(); }
private bool IsDismissed(IPerson person, DateTime day) { if (person.DayOfWeekDismisses.Any(d => d.GetDismissStatus(day).Dismissed)) return true; if (person.TemporaryDismisses.Any(d => d.GetDismissStatus(day).Dismissed)) return true; return false; }
public int CompareTo(IPerson other) { if (this.Id < other.Id) return -1; return this.Id > other.Id ? 1 : 0; // If ids are both 0 (no id for students), then no guidelines are given => equals. // But we could consider sorting them by their family names if needed. }
public Supplement(bool isHourCanceled, DateTime date, ITeachingHour hour, ISchedule schedule, IPerson teacher = null) { this.IsHourCanceled = isHourCanceled; this.Date = date; this.Hour = hour; this.Schedule = schedule; this.Teacher = teacher; }
public void it_becomes_active(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { sourceObject.Name = "New Name"; Assert.Equal("New Name", targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("Another Name", sourceObject.Name); }
public void conversions_from_target_to_source_are_automatically_converted_where_possible(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { targetObject.Name = "69"; Assert.Equal(69, sourceObject.Age); targetObject.Name = "13a"; Assert.Equal(69, sourceObject.Age); }
public void InsertPerson(IPerson person) { var ctx = new AddressBookContext(); var entity = new Person(); Mappings.Map(person, entity); ctx.Persons.Add(entity); ctx.SaveChanges(); }
public void updating_the_target_does_not_update_the_source(BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { targetObject.Name = "A new address"; Assert.Null(sourceObject.Line1); targetObject.Name = "Another new address"; Assert.Null(sourceObject.Line1); }
public Spouse(IPerson me, IPerson so, DateTime marriageDt, DateTime? divorceDt, int ordinal) { _me = me; _est = so; _marriedOn = marriageDt; _separatedOn = divorceDt; _ordinal = ordinal; }
public void it_becomes_inactive(BindingManager bindingManager, BindingBase binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "New Name"; Assert.Null(targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("New Name", sourceObject.Line1); }
public void it_is_not_yet_active(MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "Line 1"; Assert.Null(targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("Line 1", sourceObject.Line1); }
public void it_is_not_yet_active(SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { sourceObject.Name = "New Name"; Assert.Null(targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("New Name", sourceObject.Name); }
public void conversions_from_target_to_source_are_ignored_when_there_is_no_converter(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { targetObject.Name = "Kent"; Assert.Null(sourceObject.Gender); targetObject.Name = "Male"; Assert.Null(sourceObject.Gender); }
public void Add(IPerson person) { lock (thisLock) { persons.Add(person); totalWeight += person.Weight; OnPersonAdded(new PersonEventArgs(person)); } }
public void it_becomes_active(BindingManager bindingManager, MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "Line 1, mighty fine"; Assert.Equal("Line 1, mighty fine~", targetObject.Name); targetObject.Name = "Foo~Bar"; Assert.Equal("Foo", sourceObject.Line1); Assert.Equal("Bar", sourceObject.Line2); }
public IPerson Resolve(IPerson person, SqlDataReader reader) { person.PersonId = Convert.ToInt32(reader["personId"]); person.FirstName = Convert.ToString(reader["firstName"]); person.MiddleName = Convert.ToString(reader["middleName"]); person.LastName = Convert.ToString(reader["lastName"]); return person; }
/// <summary> /// The sample behavior. /// </summary> /// <param name="target">The target or parent object if needed.</param> public override void Behave(IPerson target) { lock (Builder) { Builder.AppendFormat( "{0} {1} is a person standing still.\n", target.FirstName, target.LastName); } }
public static void DumpPerson(IPerson person, int depth, int indent = 0) { PrintName(person, indent); WriteLine(indent, "Names: {0}", String.Join(", ", person.Names)); WriteLine(indent, "Age Range: {0}", person.AgeRange == null ? "null" : person.AgeRange.ToString()); WriteLine(indent, "Gender: {0}", person.Gender); DumpBaseEntity(person, depth, indent); }
public Attendance(IPerson person, IEnumerable<TimeFrame> attendedTimes) { if (person == null) throw new ArgumentNullException(nameof(person)); if (attendedTimes == null) throw new ArgumentNullException(nameof(attendedTimes)); Attendee = person; AttendedTimes = attendedTimes.ToArray(); }
public void it_has_the_correct_target_path(MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { var multiBinding = binding as MultiBinding; if (multiBinding == null) { return; } Assert.Same("Name", multiBinding.TargetPath); }
public void the_target_expression_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject) { var typedBinding = singleSourceBinding as TypedBinding <IPerson, IPerson>; if (typedBinding == null) { return; } var ex = Assert.Throws <InvalidOperationException>(() => typedBinding.TargetExpression = null); Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message); }
public void FindByIdShouldReturnPersonWhenUsedWithValidId() { IPerson person = this.setUpDatabase.FindById(1); Assert.IsNotNull(person); }
public int[] GetAllMarks(IPerson person) { return(((Student)person).marks); }
public PersonCommand(IPerson person) { receiver = person ?? throw new ArgumentNullException(); }
public Facade() { _factory = new SynchroFactory(); _person = new ConcretePerson(_factory); _department = new ConcreteDepartment(); }
public void BusSetUp() { _bus = new FakeBus(new FakeDriver(), 100, 50, 2, 1); _passengers = new FakePassenger(); _driver = new FakeDriver(); }
public void the_source_path_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject) { var binding = singleSourceBinding as Binding; if (binding == null) { return; } var ex = Assert.Throws <InvalidOperationException>(() => binding.SourcePath = null); Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message); }
public void InitiateDb() { db = new Database(); person = new Person(Name, Id); db.AddPeople(person); }
public void Remove(IPerson person) { this.people.RemoveWhere(p => p.Id == person.Id && p.Username == person.Username); }
public bool IsContained(IPerson person) { return(person.StudentStatus > 0); }
public void FindByUserNameShouldReturnCorrectPersonWhenProvidedValidUserName() { IPerson person = this.setUpDatabase.FindByUsername("Test1"); Assert.AreEqual("Test1", person.Username); }
public abstract void GetKcalValue(IPerson person);
public abstract void SetLabel(Label label, IPerson person);
public static (IPerson item, RuleEnumerators.RuleStatus status, string[] failedFields) Validate(this IPerson item, IPersonRuleProcessor processor) { return(processor.Process(item)); }
public void BlockOrUnblockPerson(IPerson person, bool blockOrUnblock) { person.IsBlocked = blockOrUnblock; }
public void the_converter_parameter_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { var ex = Assert.Throws <InvalidOperationException>(() => binding.ConverterParameter = "whatever"); Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message); }
public void it_is_present_in_the_bindings_collection(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { Assert.Contains(binding, bindingManager.Bindings); }
public void Add(IPerson person) { Console.WriteLine(person.FirstName); }
/// <summary> /// Create Order method called via delegate. /// User can enter integer or float values. /// </summary> /// <param name="person"> Customer or Employee, depending of user choice </param> static void CreateOrder(IPerson person) { Order order = new Order(); order.AddItem(person); }
public void the_mode_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { var ex = Assert.Throws <InvalidOperationException>(() => binding.Mode = BindingMode.OneWayToTarget); Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message); }
public bool IsAlreadySeat(IPerson person) { return(chairs.Any(x => x.Visitor == person)); }
public void it_cannot_be_added_again(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject) { var ex = Assert.Throws <InvalidOperationException>(() => bindingManager.Bindings.Add(binding)); Assert.Equal("This binding is already activated.", ex.Message); }
public void SendEmail(IPerson owner, string message) { Console.WriteLine($"email to: {owner.FirstName}, message: { message }"); }
public void Add(IPerson person) // IPerson kullanıldığında ister customer ister student gönderilebilir { Console.WriteLine(person.FirstName); }
public Credit(IPerson person) : base(person) { }
/// <summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. /// </summary> void Start() { _luaEnv = new LuaEnv(); _luaEnv.AddLoader(GameUtils.MyLoader); _luaEnv.DoString("require 'CSharpCallLua1'"); Debug.Log("/*获取基本变量*/"); /*获取基本变量*/ int intA = _luaEnv.Global.Get <int>("int_Age"); Debug.Log(intA); float floB = _luaEnv.Global.Get <float>("flo_Stature"); Debug.Log(floB); bool isHandsome = _luaEnv.Global.Get <bool>("isHandsome"); Debug.Log(isHandsome); string name = _luaEnv.Global.Get <string>("strName"); Debug.Log(name); Debug.Log("/*获取table的方式一,通过类Class(Struct) */"); /*获取table的方式一,通过类Class(Struct) */ Person _per = _luaEnv.Global.Get <Person>("person"); Debug.Log(_per.name); Debug.Log(_per.age); Debug.Log("/*获取table的方式二,通过接口interface(推荐) */"); /*获取table的方式二,通过接口interface(推荐) */ IPerson _iPer = _luaEnv.Global.Get <IPerson>("person"); Debug.Log(_iPer.name); Debug.Log(_iPer.age); _iPer.eat(_iPer.name, "鸡腿"); Debug.Log("/*获取table的方式三,通过键值对Dictionary、集合List(推荐)*/"); /*获取table的方式三,通过键值对Dictionary、集合List(推荐) */ //Dictionary--只能映射table里面有键的元素 Debug.Log("Dictionary>>>"); Dictionary <string, object> _dic = _luaEnv.Global.Get <Dictionary <string, object> >("person"); foreach (string key in _dic.Keys) { Debug.Log(key + "-" + _dic[key]); } //List--只能映射table里面没有的元素 Debug.Log("List>>>"); List <object> _list = _luaEnv.Global.Get <List <object> >("person"); foreach (object item in _list) { Debug.Log(item); } /*通过LuaTable类(不推荐,性能较差) */ Debug.Log("LuaTable>>>"); LuaTable _table = _luaEnv.Global.Get <LuaTable>("person"); print(_table.Get <string>("name")); print(_table.Get <int>("age")); print(_table.Length); Debug.Log("访问Lua中的全局函数>>>"); /*访问Lua中的全局函数 */ //方法一:映射到delegate Debug.Log("delegate>>>"); Add _act = _luaEnv.Global.Get <Add>("add"); int _resa, _resb; print(_act(1, 2, out _resa, out _resb)); print(_resa); print(_resb); //方法二:映射到LuaFunction(不推荐) Debug.Log("LuaFunction>>>"); LuaFunction _lf = _luaEnv.Global.Get <LuaFunction>("add"); object[] _os = _lf.Call(3, 4); foreach (object item in _os) { print(item); } }
public DepositBase(IDepositModel currentModel, IDepositUser currentUser, IPerson currentPerson) : base(currentModel, currentUser, currentPerson) { CurrentUser = currentUser; CurrentModel = currentModel; }
public PersonState Interact(IPerson person) => PersonState.Killed;
public void FindByUserNameShouldReturnPersonWhenProvidedValidUserName() { IPerson person = this.setUpDatabase.FindByUsername("Test1"); Assert.IsNotNull(person); }