Exemplo n.º 1
0
        /// <summary>
        /// Extension of the AppContext which contains the dispatcher. All we've done is throw in some dispatcher friendly components.
        /// </summary>
        /// <param name="LogOn">Example of something you might want encapulated and updated.</param>
        /// <param name="smtpClient">Powers the email client.</param>
        public ExampleContext(string LogOn, SmtpClient smtpClient)
            : base()
        {
            Dispatch = new Client();

              this.LogOn = LogOn;

              Email = new Email.Client(smtpClient);
              File = new Io.Client(new Io.Strategy.Binary.BinaryStrategy());

              Audit = new Audit.Client(); // This is passed as a ref because the audit class will register itself to various events depending on the audit level chosen.

              // Bootstrap the notification client.
              Notification = new Notification.Client(Email);
              var subjectResource = new Resource() { Value = "Example Subject: {0}", ResourceType = ResourceType.EmailSubject};
              var bodyResource = new Resource { Value = "Example Body: {0}", ResourceType = ResourceType.EmailBody};

              var emailTemplate = new ExampleEmailTemplate(typeof(object[]), subjectResource, bodyResource);

              Notification.AddEmailTemplate(ExampleContext.OnUserChange, emailTemplate);

              WireUpListeners();
              WireUpRoutines();
              WireUpCommandHubItems();
        }
Exemplo n.º 2
0
        protected override string FormatResource(Resource resource, object entity)
        {
            if (resource.ResourceType.Equals(ResourceType.EmailSubject)) return this.FormatSubject(resource, entity);
              if (resource.ResourceType.Equals(ResourceType.EmailBody)) return this.FormatBody(resource, entity);

              throw new ArgumentException("Resource Type not supported by this template");
        }
Exemplo n.º 3
0
 protected override string FormatSubject(Resource resource, object entity)
 {
     return string.Format(resource.Value, entity);
 }
Exemplo n.º 4
0
 public ExampleEmailTemplate(Type entityType, Resource subjectResource, Resource bodyResource)
     : base(entityType, subjectResource, bodyResource)
 {
 }
Exemplo n.º 5
0
 protected abstract string FormatResource(Resource resource, object entity);
Exemplo n.º 6
0
 protected EmailTemplate(Type entityType, Resource subjectResource, Resource bodyResource)
 {
     this.EntityType = entityType;
       this._subjectResource = subjectResource;
       this._bodyResource = bodyResource;
 }