コード例 #1
0
ファイル: ExampleContext.cs プロジェクト: erasmosud/sharpbox
        /// <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();
        }
コード例 #2
0
ファイル: FileStrategy.cs プロジェクト: erasmosud/sharpbox
        public FileStrategy(Io.Strategy.IStrategy persistenceStrategy, string filePath)
        {
            _file = new Io.Client(persistenceStrategy);
            _filePath = filePath;

            if (!_file.Exists(_filePath)) _file.Write(filePath, new List<Response>());
            Trail = _file.Read<List<Response>>(filePath);
        }
コード例 #3
0
ファイル: AppContext.cs プロジェクト: erasmosud/sharpbox
        /// <summary>
        /// A bit of a kitchen sink. Will instantiate Dispatch, Email, File, Audit, Notification, and map default commands and listeners.
        /// </summary>
        /// <param name="smtpClient"></param>
        /// <param name="ioStrategy"></param>
        public AppContext(SmtpClient smtpClient, Io.Strategy.IStrategy ioStrategy)
        {
            Dispatch = new Client();
              Email = new Email.Client(smtpClient);
              File = new Io.Client(ioStrategy);
              Audit = new Audit.Client();
              Notification = new Notification.Client(Email);

              RegisterCommands();
              MapListeners();
        }