当前位置: 首页>>代码示例>>C#>>正文


C# IBinder.Bind方法代码示例

本文整理汇总了C#中IBinder.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# IBinder.Bind方法的具体用法?C# IBinder.Bind怎么用?C# IBinder.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBinder的用法示例。


在下文中一共展示了IBinder.Bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindAsync

        public override async Task BindAsync(IBinder binder, Stream stream, IReadOnlyDictionary<string, string> bindingData)
        {
            string boundQueueName = QueueName;
            if (bindingData != null)
            {
                boundQueueName = _queueNameBindingTemplate.Bind(bindingData);
            }

            if (FileAccess == FileAccess.Write)
            {
                Stream queueStream = binder.Bind<Stream>(new QueueAttribute(boundQueueName));
                await queueStream.CopyToAsync(stream);
            }
            else
            {
                IAsyncCollector<byte[]> collector = binder.Bind<IAsyncCollector<byte[]>>(new QueueAttribute(boundQueueName));
                byte[] bytes;
                using (MemoryStream ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    bytes = ms.ToArray();
                }
                await collector.AddAsync(bytes);
            }
        }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-script,代码行数:25,代码来源:QueueBinding.cs

示例2: Init

        public void Init()
        {
            this.binder = new Binder();

            //Binds some objects to use on tests.
            binder.Bind<IMockInterface>().To<MockIClassWithAttributes>();
            binder.Bind(typeof(MockClassWithDependencies)).ToSelf();
        }
开发者ID:NotYours180,项目名称:adic,代码行数:8,代码来源:ReflectionCacheTests.cs

示例3: QueueToBlob

 /// <summary>
 /// Reads a message from the "orders" queue and writes a blob in the "orders" container
 /// </summary>
 public static void QueueToBlob(
     [QueueTrigger("orders")] string orders, 
     IBinder binder)
 {
     TextWriter writer = binder.Bind<TextWriter>(new BlobAttribute("orders/" + orders));
     writer.Write("Completed");
 }
开发者ID:raycdut,项目名称:azure-webjobs-sdk-samples,代码行数:10,代码来源:Functions.cs

示例4: ProcessQueueMessage

 // This function will get triggered/executed when a new message is written
 // on an Azure Queue called queue.
 public static void ProcessQueueMessage([QueueTrigger("afro")] String message, TextWriter log, IBinder binder, Int32 dequeueCount)
 {
     log.WriteLine("este es el intento numero{0}", dequeueCount);
     if (dequeueCount <= 5)
     {
         binder.Bind<QueueAttribute>(new QueueAttribute("afro-poison"));
     }
     throw new Exception("throw perra");
 }
开发者ID:iaderlorduy,项目名称:WebJobAzure,代码行数:11,代码来源:Functions.cs

示例5: Init

        public void Init()
        {
            this.injector = new InjectionContainer();
            this.binder = this.injector as IBinder;

            //Binds some objects to use on tests.
            binder.Bind<IMockInterface>().To<MockIClassWithAttributes>();
            binder.Bind<MockIClassWithoutAttributes>().ToSingleton().As("singleton");
            binder.Bind<MockIClass>().ToSingleton();

            this.containerIdentifierTests = new InjectionContainer();
            var mockClass1 = new MockIClass() { property1 = "MockClass1" };
            var mockClass2 = new MockIClassWithoutAttributes() { property1 = "MockClass2" };
            var mockClass3 = new MockIClassWithAttributes() { property1 = "MockClass3" };
            this.containerIdentifierTests.Bind<MockIClass>().To(mockClass1).As(TestIdentifier.MockClass);
            this.containerIdentifierTests.Bind<MockIClassWithoutAttributes>().To(mockClass2).As(TestIdentifier.MockClass);
            this.containerIdentifierTests.Bind<MockIClassWithAttributes>().To(mockClass3).As(TestIdentifier.MockClass);
            this.containerIdentifierTests.Bind<IMockInterface>().To(mockClass1).As(TestIdentifier.MockClass1);
            this.containerIdentifierTests.Bind<IMockInterface>().To(mockClass2).As(TestIdentifier.MockClass2);
            this.containerIdentifierTests.Bind<IMockInterface>().To(mockClass3).As(TestIdentifier.MockClass3);
            this.containerIdentifierTests.Bind<IMockInterface>().To<MockIClass>().As(TestIdentifier.MockClassSingle);
        }
开发者ID:cgarciae,项目名称:adic,代码行数:22,代码来源:InjectorTests.cs

示例6: BackupFile

        public static void BackupFile(
            string fileContent,
            string fileName,
            IBinder binder,
            TextWriter log)
        {
            log.WriteLine("Backing up file in Azure Storage: " + fileName);

            // Use IBinder because property binding doesn't work without a trigger attribute
            // if it would work, the code would be much simpler
            TextWriter backupFile = binder.Bind<TextWriter>(new BlobAttribute("backup/" + fileName));
            backupFile.Write(fileContent);
        }
开发者ID:rustd,项目名称:WebJobsSDKSamples,代码行数:13,代码来源:Functions.cs

示例7: RecordTime

        public static void RecordTime(IBinder binder, TextWriter logger)
        {
            var start = $"{DateTime.UtcNow:yyyyMMdd-HHmmss}";

            var blobAttribute = new BlobAttribute($"output/{start}");
            var blob = binder.Bind<CloudBlockBlob>(blobAttribute);

            blob.UploadText(start);
            logger.WriteLine(start);

            //RecordTimeAndSleep(start, blob, logger);
            RecordTimes(start, blob, logger);
        }
开发者ID:sakapon,项目名称:Samples-2016,代码行数:13,代码来源:Functions.cs

示例8: CreateShuffle

        /// <summary>
        /// Waits for message from the queue and creates shuffles
        /// </summary>
        /// <param name="shufflerequests">The message received from queue</param>
        public static void CreateShuffle(
            [QueueInput] ShuffleRequestMessage shufflerequests,
            IBinder binder)
        {
            string shuffleId = shufflerequests.ShuffleId;

            ImageProcessingJobs processor = new ImageProcessingJobs();
            string shuffle = processor.CreateShuffle(shuffleId);

            Stream shuffleBlob = binder.Bind<Stream>(new BlobOutputAttribute("shuffle" + shuffleId + @"/shuffle.jpg"));

            using (Stream localShuffle = File.OpenRead(shuffle))
            {
                localShuffle.CopyTo(shuffleBlob);
            }
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:20,代码来源:ImageProcessingJobs.cs

示例9: ScanAndRegisterHandlers

        void ScanAndRegisterHandlers(IBinder binder, IScanner scanner) 
        {
            var handlerTups = scanner.ScanTypes(typeof(Registrar).Assembly)
                                        .Where(t => !t.IsAbstract)
                                        .Select(t => new {
                                            ImplType = t,
                                            IntType = t.GetInterfaces()
                                                            .SingleOrDefault(i => i.IsGenericType
                                                                                && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>))
                                        })
                                        .Where(tup => tup.IntType != null);

            foreach(var tup in handlerTups) {
                binder.Bind(tup.IntType, tup.ImplType);
            }
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:16,代码来源:Registrar.cs

示例10: CreateShuffle

        /// <summary>
        /// Waits for message from the queue and creates shuffles
        /// </summary>
        /// <param name="shufflerequest">The message received from queue</param>
        public static void CreateShuffle(
            [QueueTrigger("shufflerequests")] ShuffleRequestMessage shufflerequest,
            IBinder binder)
        {
            string shuffleId = shufflerequest.ShuffleId;

            ImageProcessingJobs processor = new ImageProcessingJobs();
            string shuffle = processor.CreateShuffle(shuffleId);

            BlobAttribute attribute = new BlobAttribute("shuffle" + shuffleId + @"/shuffle.jpg", FileAccess.Write);
            Stream shuffleBlob = binder.Bind<Stream>(attribute);

            using (Stream localShuffle = File.OpenRead(shuffle))
            {
                localShuffle.CopyTo(shuffleBlob);
            }
        }
开发者ID:alpaix,项目名称:azure-webjobs-sdk-samples,代码行数:21,代码来源:ImageProcessingJobs.cs

示例11: BindAsync

        public override async Task BindAsync(IBinder binder, Stream stream, IReadOnlyDictionary<string, string> bindingData)
        {
            string boundBlobPath = Path;
            if (bindingData != null)
            {
                boundBlobPath = _pathBindingTemplate.Bind(bindingData);
            }

            Stream blobStream = binder.Bind<Stream>(new BlobAttribute(boundBlobPath, FileAccess));
            if (FileAccess == FileAccess.Write)
            {
                await stream.CopyToAsync(blobStream);
            }
            else
            {
                await blobStream.CopyToAsync(stream);
            }
        }
开发者ID:wondenge,项目名称:azure-webjobs-sdk-script,代码行数:18,代码来源:BlobBinding.cs

示例12: Bind

        public void Bind(IBinder binder)
        {
            Mock<IUnitOfWork> mock = new Mock<IUnitOfWork>();
            mock.Setup(m => m.Products.GetAll()).Returns(new List<Product>
            {
                new Product {ProductID=1,Name = "Table", Price = 25, Category="Kitchen"},
                new Product {ProductID=2,Name = "Ball", Price = 179,Category = "Outside"},
                new Product {ProductID=3,Name = "Oven", Price = 95, Category="Kitchen"},
                new Product {ProductID=4,Name = "KeyBoard", Price = 10,Category = "Office"},
                new Product {ProductID=5,Name = "Phone", Price = 20,Category = "Office"},
                new Product {ProductID=6,Name = "Mouse", Price = 45,Category = "Office"},
                new Product {ProductID=7,Name = "TV", Price = 34, Category = "Office"},
                new Product {ProductID=8,Name = "Glass", Price = 47,Category = "Kitchen"},
                new Product {ProductID=9,Name = "Plate", Price = 88, Category="Kitchen"},
                new Product {ProductID=10,Name = "Fork", Price = 44, Category="Kitchen"},
                new Product {ProductID=11,Name = "Knife", Price = 66, Category ="Kitchen"}
            }.AsQueryable());

            //binder.BindToConstant<IUnitOfWork, IUnitOfWork>(mock.Object);
            binder.Bind<IUnitOfWork, StefanStoreUow>();
        }
开发者ID:stefansperanta,项目名称:StefanStoreGoodRepo,代码行数:21,代码来源:RepoModule.cs

示例13: BlobIBinder

 /// <summary>
 /// Same as "BlobNameFromQueueMessage" but using IBinder 
 /// </summary>
 public static void BlobIBinder(
     [QueueTrigger("persons")] Person persons, 
     IBinder binder)
 {
     TextWriter writer = binder.Bind<TextWriter>(new BlobAttribute("persons/" + persons.Name + "BlobIBinder"));
     writer.Write("Hello " + persons.Name);
 }
开发者ID:harishc27,项目名称:azure-webjobs-sdk-samples,代码行数:10,代码来源:Functions.cs

示例14: Register

        public void Register(IBinder x, IScanner scanner) 
        {
            x.Bind<HttpContext>(_ => HttpContext.Current);
            x.Bind<HttpContextBase>(_ => new HttpContextWrapper(HttpContext.Current));

            x.Bind(c => c.Resolve<HttpContext>().Request);
            x.Bind(c => c.Resolve<HttpContext>().Response);
            x.Bind(c => c.Resolve<HttpContext>().Server);
            x.Bind(c => c.Resolve<HttpContext>().Session);

            x.BindSingleton<ICache>(_ => new BrigitaCache(MemoryCache.Default));
            x.Bind<ICacheManager, MemoryCacheManager>();

            //x.Register<IRoutePublisher, RoutePublisher>();

            x.Bind<IEventPublisher, EventPublisher>();
            x.Bind<ISubscriptionService, SubscriptionService>();

            x.Bind<IGenericAttributeService, GenericAttributeService>();

            x.Bind<IPluginFinder, BrigitaPluginFinder>();

            x.Bind<ILogger, NullLogger>();


            x.BindGeneric(typeof(IRepo<>), typeof(Repo<>));
                        
            x.Bind<ILinkProvider, LinkProvider>();

            x.Bind<IMediator, Mediator>();

            x.Bind<IPicSource, PicSource>();
            x.Bind<IPictureService, PictureService>();

            x.Bind<ILocaleContext, LocaleContext>();
            x.Bind<ILocaleCodeProvider, LocaleCodeProvider>();
            
            x.BindGeneric(typeof(ILocalizer<>), typeof(Localizer<>));
            x.BindGeneric(typeof(IStringLocalizer<>), typeof(StringLocalizer<>));
            x.BindGeneric(typeof(ICurrencyLocalizer<>), typeof(CurrencyLocalizer<>));


            x.Bind<IWorkContext, BrigitaWorkContext>();




            x.Bind<IPageHelper, PageHelper>();
            x.Bind<ILinkHelper, LinkHelper>();

            //!!!!!!!! JUST FOR TESTING... !!!!!!!!!
            x.Bind(new StoreInformationSettings());
            x.Bind(new TaxSettings());
            x.Bind(new CurrencySettings());
            x.Bind(new LocalizationSettings());
            x.Bind(new CustomerSettings());
            x.Bind(new CommonSettings());
            x.Bind(new CatalogSettings());
            x.Bind(new SeoSettings());
            x.Bind(new MediaSettings());
            x.Bind<ISettingService, SettingService>();

            x.Bind<IUserAgentHelper, UserAgentHelper>();
            x.Bind<IWebHelper, WebHelper>();

            /*x.Bind<IWorkContext, WebWorkContext>();*/
            x.Bind<IStoreContext, WebStoreContext>();

            x.Bind<ICategories, BrigitaCategories>();
            x.Bind<IScopedCategories, ScopedCategories>();

            x.Bind<IProducts, BrigitaProducts>();


            x.Bind<ICustomerService, CustomerService>();
            x.Bind<IVendorService, VendorService>();
            x.Bind<IStoreService, BrigitaStores>();
            x.Bind<IAuthenticationService, FormsAuthenticationService>();
            x.Bind<ILanguageService, LanguageService>();
            x.Bind<ICurrencyService, CurrencyService>();
            x.Bind<IStoreMappingService, StoreMappingService>();

            x.Bind<IPageHeadBuilder, PageHeadBuilder>();


            //data layer
            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();
            x.Bind<DataSettings>(c => dataSettingsManager.LoadSettings());

            x.BindTransient<BaseDataProviderManager, EfDataProviderManager>();
            x.BindTransient<IDataProvider>(c => c.Resolve<BaseDataProviderManager>().LoadDataProvider());

            if(dataProviderSettings != null && dataProviderSettings.IsValid()) {
                var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
                var dataProvider = efDataProviderManager.LoadDataProvider();
                dataProvider.InitConnectionFactory();

                x.Bind<IDbContext>(c => new NopObjectContext(dataProviderSettings.DataConnectionString, false, false));
            }
//.........这里部分代码省略.........
开发者ID:jasonholloway,项目名称:brigita,代码行数:101,代码来源:Registrar.cs

示例15: Bind

 public void Bind(IBinder binder)
 {
     binder.Bind<IProductService,ProductService>();
        binder.Bind<INavigationService, NavigationService>();
        binder.Bind<ICartService, CartService>();
 }
开发者ID:stefansperanta,项目名称:StefanStoreGoodRepo,代码行数:6,代码来源:ServiceModule.cs


注:本文中的IBinder.Bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。