/// <summary> /// Initialize the O365 binding extension /// </summary> /// <param name="context">Context containing info relevant to this extension</param> public void Initialize(ExtensionConfigContext context) { _webhookTriggerProvider = new WebhookTriggerBindingProvider(); _notificationUrl = context.GetWebhookHandler(); var graphWebhookConverter = new GraphWebhookSubscriptionConverter(_graphServiceClientManager, _options, _subscriptionStore); // Webhooks var webhookSubscriptionRule = context.AddBindingRule <GraphWebhookSubscriptionAttribute>(); webhookSubscriptionRule.BindToInput <Subscription[]>(graphWebhookConverter); webhookSubscriptionRule.BindToInput <OpenType[]>(typeof(GenericGraphWebhookSubscriptionConverter <>), _graphServiceClientManager, _options, _subscriptionStore); webhookSubscriptionRule.BindToInput <string[]>(graphWebhookConverter); webhookSubscriptionRule.BindToInput <JArray>(graphWebhookConverter); webhookSubscriptionRule.BindToCollector <string>(CreateCollector); context.AddBindingRule <GraphWebhookTriggerAttribute>().BindToTrigger(_webhookTriggerProvider); // OneDrive var oneDriveService = new OneDriveService(_graphServiceClientManager); var OneDriveRule = context.AddBindingRule <OneDriveAttribute>(); var oneDriveConverter = new OneDriveConverter(oneDriveService); // OneDrive inputs OneDriveRule.BindToInput <byte[]>(oneDriveConverter); OneDriveRule.BindToInput <string>(oneDriveConverter); OneDriveRule.BindToInput <Stream>(oneDriveConverter); OneDriveRule.BindToInput <DriveItem>(oneDriveConverter); //OneDriveoutputs OneDriveRule.BindToCollector <byte[]>(oneDriveConverter); // Excel var excelService = new ExcelService(_graphServiceClientManager); var ExcelRule = context.AddBindingRule <ExcelAttribute>(); var excelConverter = new ExcelConverter(excelService); // Excel Outputs ExcelRule.AddConverter <object[][], string>(ExcelService.CreateRows); ExcelRule.AddConverter <JObject, string>(excelConverter); ExcelRule.AddOpenConverter <OpenType, string>(typeof(ExcelGenericsConverter <>), excelService); // used to append/update arrays of POCOs ExcelRule.BindToCollector <string>(excelConverter); // Excel Inputs ExcelRule.BindToInput <string[][]>(excelConverter); ExcelRule.BindToInput <WorkbookTable>(excelConverter); ExcelRule.BindToInput <OpenType>(typeof(ExcelGenericsConverter <>), excelService); // Outlook var outlookService = new OutlookService(_graphServiceClientManager); var OutlookRule = context.AddBindingRule <OutlookAttribute>(); var outlookConverter = new OutlookConverter(outlookService); // Outlook Outputs OutlookRule.AddConverter <JObject, Message>(outlookConverter); OutlookRule.AddOpenConverter <OpenType, Message>(typeof(OutlookGenericsConverter <>), outlookService); OutlookRule.AddConverter <string, Message>(outlookConverter); OutlookRule.BindToCollector <Message>(outlookConverter); }
/// <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); }