Skip to content

Commit

Permalink
Convert to file-scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzik committed Nov 1, 2022
1 parent 0d3e0f8 commit 48b250a
Show file tree
Hide file tree
Showing 1,169 changed files with 70,003 additions and 71,172 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ indent_size = 2
[*.cs]
indent_style = space
indent_size = 4
insert_final_newline = true

csharp_style_namespace_declarations = file_scoped

dotnet_diagnostic.IDE0161.severity = warning

[*.cake]
indent_style = space
Expand Down
39 changes: 19 additions & 20 deletions src/Examples.FirstAutomappedProject/CascadeConvention.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;

namespace Examples.FirstAutomappedProject
namespace Examples.FirstAutomappedProject;

/// <summary>
/// This is a convention that will be applied to all entities in your application. What this particular
/// convention does is to specify that many-to-one, one-to-many, and many-to-many relationships will all
/// have their Cascade option set to All.
/// </summary>
class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention
{
/// <summary>
/// This is a convention that will be applied to all entities in your application. What this particular
/// convention does is to specify that many-to-one, one-to-many, and many-to-many relationships will all
/// have their Cascade option set to All.
/// </summary>
class CascadeConvention : IReferenceConvention, IHasManyConvention, IHasManyToManyConvention
public void Apply(IManyToOneInstance instance)
{
public void Apply(IManyToOneInstance instance)
{
instance.Cascade.All();
}
instance.Cascade.All();
}

public void Apply(IOneToManyCollectionInstance instance)
{
instance.Cascade.All();
}
public void Apply(IOneToManyCollectionInstance instance)
{
instance.Cascade.All();
}

public void Apply(IManyToManyCollectionInstance instance)
{
instance.Cascade.All();
}
public void Apply(IManyToManyCollectionInstance instance)
{
instance.Cascade.All();
}
}
}
17 changes: 8 additions & 9 deletions src/Examples.FirstAutomappedProject/Entities/Employee.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace Examples.FirstAutomappedProject.Entities
namespace Examples.FirstAutomappedProject.Entities;

public class Employee
{
public class Employee
{
public virtual int Id { get; protected set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual Store Store { get; set; }
}
}
public virtual int Id { get; protected set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual Store Store { get; set; }
}
13 changes: 6 additions & 7 deletions src/Examples.FirstAutomappedProject/Entities/Location.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
namespace Examples.FirstAutomappedProject.Entities
namespace Examples.FirstAutomappedProject.Entities;

public class Location
{
public class Location
{
public virtual int Aisle { get; set; }
public virtual int Shelf { get; set; }
}
}
public virtual int Aisle { get; set; }
public virtual int Shelf { get; set; }
}
25 changes: 12 additions & 13 deletions src/Examples.FirstAutomappedProject/Entities/Product.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System.Collections.Generic;

namespace Examples.FirstAutomappedProject.Entities
namespace Examples.FirstAutomappedProject.Entities;

public class Product
{
public class Product
{
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual double Price { get; set; }
public virtual Location Location { get; set; }
public virtual IList<Store> StoresStockedIn { get; set; }
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual double Price { get; set; }
public virtual Location Location { get; set; }
public virtual IList<Store> StoresStockedIn { get; set; }

public Product()
{
StoresStockedIn = new List<Store>();
}
public Product()
{
StoresStockedIn = new List<Store>();
}
}
}
45 changes: 22 additions & 23 deletions src/Examples.FirstAutomappedProject/Entities/Store.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
using System.Collections.Generic;

namespace Examples.FirstAutomappedProject.Entities
namespace Examples.FirstAutomappedProject.Entities;

public class Store
{
public class Store
{
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual IList<Product> Products { get; set; }
public virtual IList<Employee> Staff { get; set; }
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual IList<Product> Products { get; set; }
public virtual IList<Employee> Staff { get; set; }

public Store()
{
Products = new List<Product>();
Staff = new List<Employee>();
}
public Store()
{
Products = new List<Product>();
Staff = new List<Employee>();
}

public virtual void AddProduct(Product product)
{
product.StoresStockedIn.Add(this);
Products.Add(product);
}
public virtual void AddProduct(Product product)
{
product.StoresStockedIn.Add(this);
Products.Add(product);
}

public virtual void AddEmployee(Employee employee)
{
employee.Store = this;
Staff.Add(employee);
}
public virtual void AddEmployee(Employee employee)
{
employee.Store = this;
Staff.Add(employee);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@
using Examples.FirstAutomappedProject.Entities;
using FluentNHibernate.Automapping;

namespace Examples.FirstAutomappedProject
namespace Examples.FirstAutomappedProject;

/// <summary>
/// This is an example automapping configuration. You should create your own that either
/// implements IAutomappingConfiguration directly, or inherits from DefaultAutomappingConfiguration.
/// Overriding methods in this class will alter how the automapper behaves.
/// </summary>
class ExampleAutomappingConfiguration : DefaultAutomappingConfiguration
{
/// <summary>
/// This is an example automapping configuration. You should create your own that either
/// implements IAutomappingConfiguration directly, or inherits from DefaultAutomappingConfiguration.
/// Overriding methods in this class will alter how the automapper behaves.
/// </summary>
class ExampleAutomappingConfiguration : DefaultAutomappingConfiguration
public override bool ShouldMap(Type type)
{
public override bool ShouldMap(Type type)
{
// specify the criteria that types must meet in order to be mapped
// any type for which this method returns false will not be mapped.
return type.Namespace == "Examples.FirstAutomappedProject.Entities";
}
// specify the criteria that types must meet in order to be mapped
// any type for which this method returns false will not be mapped.
return type.Namespace == "Examples.FirstAutomappedProject.Entities";
}

public override bool IsComponent(Type type)
{
// override this method to specify which types should be treated as components
// if you have a large list of types, you should consider maintaining a list of them
// somewhere or using some form of conventional and/or attribute design
return type == typeof(Location);
}
public override bool IsComponent(Type type)
{
// override this method to specify which types should be treated as components
// if you have a large list of types, you should consider maintaining a list of them
// somewhere or using some form of conventional and/or attribute design
return type == typeof(Location);
}
}
}
Loading

0 comments on commit 48b250a

Please sign in to comment.