Ejemplo n.º 1
0
        public GraphWebhookSubscriptionAsyncCollector(ServiceManager extension, ILoggerFactory logFactory, GraphWebhookConfig config, GraphWebhookSubscriptionAttribute attribute)
        {
            _extension = extension;
            _log = logFactory?.CreateLogger(MicrosoftGraphExtensionConfig.CreateBindingCategory("GraphWebhook"));
            _webhookConfig = config;
            _attribute = attribute;
            _values = new List<string>();

            _attribute.Validate();
        }
Ejemplo n.º 2
0
        public GraphWebhookSubscriptionAsyncCollector(ServiceManager extension, TraceWriter log, GraphWebhookConfig config, GraphWebhookSubscriptionAttribute attribute)
        {
            _extension     = extension;
            _log           = log;
            _webhookConfig = config;
            _attribute     = attribute;
            _values        = new List <string>();

            _attribute.Validate();
        }
Ejemplo n.º 3
0
 public GraphWebhookSubscriptionHandler(ServiceManager manager, GraphWebhookConfig config, ILoggerFactory loggerFactory)
 {
     _manager = manager;
     _config  = config;
     _log     = loggerFactory?.CreateLogger(MicrosoftGraphExtensionConfig.CreateBindingCategory("GraphWebhookSubscription"));
 }
Ejemplo n.º 4
0
 public GraphWebhookSubscriptionHandler(ServiceManager manager, GraphWebhookConfig config, TraceWriter log)
 {
     _manager = manager;
     _config  = config;
     _log     = log;
 }
        /// <summary>
        /// Initialize the O365 binding extension
        /// </summary>
        /// <param name="context">Context containing info relevant to this extension</param>
        public void Initialize(ExtensionConfigContext context)
        {
            var config = context.Config;

            _appSettings = config.NameResolver;

            // Set up logging
            _log = context.Trace;

            ConfigureServiceManager(context);

            // Infer a blank Notification URL from the appsettings.
            string appSettingBYOBTokenMap = _appSettings.Resolve(O365Constants.AppSettingBYOBTokenMap);
            var    subscriptionStore      = _subscriptionStore ?? new WebhookSubscriptionStore(appSettingBYOBTokenMap);
            var    webhookTriggerProvider = new WebhookTriggerBindingProvider();

            _webhookConfig = new GraphWebhookConfig(context.GetWebhookHandler(), subscriptionStore, webhookTriggerProvider);

            var graphWebhookConverter = new GraphWebhookSubscriptionConverter(_serviceManager, _webhookConfig);

            // Webhooks
            var webhookSubscriptionRule = context.AddBindingRule <GraphWebhookSubscriptionAttribute>();

            webhookSubscriptionRule.BindToInput <Subscription[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <OpenType[]>(typeof(GenericGraphWebhookSubscriptionConverter <>), _serviceManager, _webhookConfig);
            webhookSubscriptionRule.BindToInput <string[]>(graphWebhookConverter);
            webhookSubscriptionRule.BindToInput <JArray>(graphWebhookConverter);
            webhookSubscriptionRule.BindToCollector <string>(CreateCollector);

            context.AddBindingRule <GraphWebhookTriggerAttribute>().BindToTrigger(webhookTriggerProvider);

            // OneDrive
            var OneDriveRule      = context.AddBindingRule <OneDriveAttribute>();
            var oneDriveConverter = new OneDriveConverter(_serviceManager);

            // OneDrive inputs
            OneDriveRule.BindToInput <byte[]>(oneDriveConverter);
            OneDriveRule.BindToInput <string>(oneDriveConverter);
            OneDriveRule.BindToInput <Stream>(oneDriveConverter);
            OneDriveRule.BindToInput <DriveItem>(oneDriveConverter);

            OneDriveRule.BindToCollector <byte[]>(CreateCollector);

            // Excel
            var ExcelRule = context.AddBindingRule <ExcelAttribute>();

            var excelConverter = new ExcelConverter(_serviceManager);

            // Excel Outputs
            ExcelRule.AddConverter <object[][], JObject>(ExcelService.CreateRows);
            ExcelRule.AddConverter <List <OpenType>, JObject>(typeof(GenericExcelRowConverter <>)); // used to append/update lists of POCOs
            ExcelRule.AddConverter <OpenType, JObject>(typeof(GenericExcelRowConverter <>));        // used to append/update arrays of POCOs
            ExcelRule.BindToCollector <JObject>(excelConverter.CreateCollector);
            ExcelRule.BindToCollector <JObject>(typeof(POCOExcelRowConverter <>));

            // Excel Inputs
            ExcelRule.BindToInput <string[][]>(excelConverter);
            ExcelRule.BindToInput <WorkbookTable>(excelConverter);
            ExcelRule.BindToInput <List <OpenType> >(typeof(POCOExcelRowConverter <>), _serviceManager);
            ExcelRule.BindToInput <OpenType>(typeof(POCOExcelRowConverter <>), _serviceManager);

            // Outlook
            var OutlookRule = context.AddBindingRule <OutlookAttribute>();

            // Outlook Outputs
            OutlookRule.AddConverter <JObject, Message>(OutlookService.CreateMessage);
            OutlookRule.AddConverter <string, Message>(OutlookService.CreateMessage);
            OutlookRule.BindToCollector <Message>(CreateCollector);
        }
Ejemplo n.º 6
0
 public GenericGraphWebhookSubscriptionConverter(ServiceManager serviceManager, GraphWebhookConfig webhookConfig) : base(serviceManager, webhookConfig)
 {
 }
Ejemplo n.º 7
0
 public GraphWebhookSubscriptionConverter(ServiceManager serviceManager, GraphWebhookConfig webhookConfig)
 {
     _serviceManager = serviceManager;
     _webhookConfig  = webhookConfig;
 }