Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Reflection;
  4. using TheTankGame.Entities.Parts.Contracts;
  5. using TheTankGame.Entities.Parts.Factories.Contracts;
  6.  
  7. namespace TheTankGame.Entities.Parts.Factories
  8. {
  9. public class PartFactory : IPartFactory
  10. {
  11. public IPart CreatePart(string partType, string model, double weight, decimal price, int additionalParameter)
  12. {
  13. Type classType = Assembly.GetCallingAssembly()
  14. .GetTypes()
  15. .FirstOrDefault(x => x.Name == partType + "Part");
  16.  
  17. var partInstance = (IPart)Activator.CreateInstance
  18. (classType, model, weight, price, additionalParameter);
  19.  
  20. return partInstance;
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement