Created
January 21, 2016 19:59
-
-
Save DominicFinn/d3afc35a3bc60608382e to your computer and use it in GitHub Desktop.
Trying to stop a domain being abused
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using ImmutableDomain.Commands; | |
using ImmutableDomain.Entities; | |
using ImmutableDomain.Help; | |
namespace ImmutableDomain.Other | |
{ | |
public class CallingClass | |
{ | |
private readonly IRepository repository; | |
public CallingClass(IRepository repository) | |
{ | |
this.repository = repository; | |
} | |
public void DoSomething() | |
{ | |
var command = new CreateEmployeeCommand(new Guid(), "Jim", "Smith"); | |
// command.FirstName = ""; YAY we can't mess with it. | |
// we can't create this in the wrong assembly | |
// var employee = new Employee(new Guid(), "", ""); | |
var employee = this.repository.Get<Employee>(Guid.Parse("F3E11CF0-89E6-44AD-B557-B32A0832D6E1")); | |
// we can't overwrite the name | |
// employee.FirstName = ""; | |
// we need to use the IEditableEmployee to update the employee | |
// but it's internal so it must be used in the right assembly | |
//(employee as IEditableEmployee).Update("Jim", "Hoff"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment