SHARE
TWEET

Untitled

a guest Jun 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public sealed class VariantProcessor
  2. {
  3.         private readonly Lazy<IEntityVersion> _entityVersion;
  4.         private string _myAppConnectionString { get; set; }
  5.         private readonly Action<Variant> _transform;
  6.         public Variant(Func<IEntityVersion> entityVersion,string _myAppConnectionString,Action<Variant> transform)
  7.         {
  8.              _entityVersion = new Lazy<IEntityVersion>(entityVersion);
  9.              _myAppConnectionString = _myAppConnectionString;
  10.              _transform = transform;
  11.         }
  12.         public void Process(Variant model)
  13.         {
  14.             string variantVersion =string.empty;
  15.             try
  16.             {
  17.                 _transform(model);
  18.                 try
  19.                 {
  20.                     variantVersion = _entityVersion.Value.GetVersion();
  21.                 }
  22.                 catch (Exception)
  23.                 {
  24.                    //rollback Transform operation
  25.                 }
  26.             }
  27.             catch (Exception)
  28.             {
  29.             }
  30.         }
  31. }
  32.  
  33. public class AggregateCalculator : IVariantProcessor
  34. {
  35.     private string _myAppConnectionString { get; set; }  
  36.     public void Process(Variant model)
  37.         {
  38.             _myAppConnectionString = ConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString;
  39.             new VariantProcessor( () => new EntityVersion(_myAppConnectionString),_myAppConnectionString,
  40.                () => Transform(model));
  41.         }
  42.     private void Transform(Variant model)
  43.     {
  44.         //logic
  45.     }
  46. }
  47.      
  48. variantVersion = _entityVersion.Value.GetVersion();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top