Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. public abstract class NutrientDemand
  2.     {
  3.         public int Value { get; }
  4.         protected NutrientDemand(int value)
  5.         {
  6.             this.Value = value;
  7.         }
  8.  
  9.         public static T Create<T>(int value)
  10.             where T : NutrientDemand
  11.         {
  12.             return (T)typeof(T).GetConstructor(new[] { typeof(int) }).Invoke(new object[] { value });
  13.         }
  14.     }
  15.  
  16.     public class KDemand : NutrientDemand
  17.     {
  18.         public KDemand(int value) : base(value)
  19.         {
  20.         }
  21.     }
  22.  
  23.  
  24. public class ApplyLeachingStep<TNutriendDemand>
  25.         where TNutriendDemand : NutrientDemand
  26.     {
  27.         public TNutriendDemand Execute(TNutriendDemand nutrientNeed)
  28.         {
  29.             var result = NutrientDemand.Create<TNutriendDemand>(3);
  30.             return result;
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement