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


C# Lazy类代码示例

本文整理汇总了C#中Lazy的典型用法代码示例。如果您正苦于以下问题:C# Lazy类的具体用法?C# Lazy怎么用?C# Lazy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ReflectedAsyncActionDescriptor

        internal ReflectedAsyncActionDescriptor(MethodInfo asyncMethodInfo, MethodInfo completedMethodInfo, string actionName, ControllerDescriptor controllerDescriptor, bool validateMethods) {
            if (asyncMethodInfo == null) {
                throw new ArgumentNullException("asyncMethodInfo");
            }
            if (completedMethodInfo == null) {
                throw new ArgumentNullException("completedMethodInfo");
            }
            if (String.IsNullOrEmpty(actionName)) {
                throw Error.ParameterCannotBeNullOrEmpty("actionName");
            }
            if (controllerDescriptor == null) {
                throw new ArgumentNullException("controllerDescriptor");
            }

            if (validateMethods) {
                string asyncFailedMessage = VerifyActionMethodIsCallable(asyncMethodInfo);
                if (asyncFailedMessage != null) {
                    throw new ArgumentException(asyncFailedMessage, "asyncMethodInfo");
                }

                string completedFailedMessage = VerifyActionMethodIsCallable(completedMethodInfo);
                if (completedFailedMessage != null) {
                    throw new ArgumentException(completedFailedMessage, "completedMethodInfo");
                }
            }

            AsyncMethodInfo = asyncMethodInfo;
            CompletedMethodInfo = completedMethodInfo;
            _actionName = actionName;
            _controllerDescriptor = controllerDescriptor;
            _uniqueId = new Lazy<string>(CreateUniqueId);
        }
开发者ID:nobled,项目名称:mono,代码行数:32,代码来源:ReflectedAsyncActionDescriptor.cs

示例2: TestingContext

        static TestingContext()
        {
            _library = new Lazy<FixtureLibrary>(() =>
            {
                try
                {
                    var fixture = new SentenceFixture();
                    var library = FixtureLibrary.CreateForAppDomain(new GrammarSystem().Start());

                    // Need to force it to use this one instead of the FactFixture in the samples project
                    var factFixture = new StoryTeller.Testing.EndToEndExecution.FactFixture();
                    library.Models["Fact"] = factFixture.Compile(CellHandling.Basic());
                    library.Fixtures["Fact"] = factFixture;

                    return library;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    throw;
                }
            });


        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:25,代码来源:TestingContext.cs

示例3: PartPresenter

        public PartPresenter(PartPresenterView view, IUnityContainer container)
        {
            _container = container;
            View = view;
            View.DataContext = this;
            _regionManager = new RegionManager();
            RegionManager.SetRegionManager(View, _regionManager);

            _addPartCommand = new Lazy<DelegateCommand<object>>(() => new DelegateCommand<object>(AddPartExecuted));
            Action<int> add = (i) =>
            {
                var region = _regionManager.Regions["Page1Content" + i];
                if (region.Views.Count() == 0)
                {
                    var partView = _container.Resolve<PartView>();

                    region.Add(partView);
                    region.Activate(partView);

                }
            };

            add(1);
            add(2);
            add(3);
        }
开发者ID:Antares007,项目名称:InRetail,代码行数:26,代码来源:PartPresenter.cs

示例4: ConstructorMap

        public ConstructorMap(ConstructorInfo ctor, IEnumerable<ConstructorParameterMap> ctorParams)
        {
            Ctor = ctor;
            CtorParams = ctorParams;

            _runtimeCtor = new Lazy<LateBoundParamsCtor>(() => DelegateFactory.CreateCtor(ctor, CtorParams));
        }
开发者ID:garora,项目名称:AutoMapper,代码行数:7,代码来源:ConstructorMap.cs

示例5: CrawledPage

 public CrawledPage(Uri uri)
     : base(uri)
 {
     _htmlDocument = new Lazy<HtmlDocument>(() => InitializeHtmlAgilityPackDocument() );
     _csQueryDocument = new Lazy<CQ>(() => InitializeCsQueryDocument());
     Content = new PageContent();
 }
开发者ID:haigneyc,项目名称:abot,代码行数:7,代码来源:CrawledPage.cs

示例6: RegisterHubExtensions

        private void RegisterHubExtensions()
        {
            var methodDescriptorProvider = new Lazy<ReflectedMethodDescriptorProvider>();
            Register(typeof(IMethodDescriptorProvider), () => methodDescriptorProvider.Value);

            var hubDescriptorProvider = new Lazy<ReflectedHubDescriptorProvider>(() => new ReflectedHubDescriptorProvider(this));
            Register(typeof(IHubDescriptorProvider), () => hubDescriptorProvider.Value);

            var parameterBinder = new Lazy<DefaultParameterResolver>();
            Register(typeof(IParameterResolver), () => parameterBinder.Value);

            var activator = new Lazy<DefaultHubActivator>(() => new DefaultHubActivator(this));
            Register(typeof(IHubActivator), () => activator.Value);

            var hubManager = new Lazy<DefaultHubManager>(() => new DefaultHubManager(this));
            Register(typeof(IHubManager), () => hubManager.Value);

            var proxyGenerator = new Lazy<DefaultJavaScriptProxyGenerator>(() => new DefaultJavaScriptProxyGenerator(this));
            Register(typeof(IJavaScriptProxyGenerator), () => proxyGenerator.Value);

            var requestParser = new Lazy<HubRequestParser>();
            Register(typeof(IHubRequestParser), () => requestParser.Value);

            var assemblyLocator = new Lazy<DefaultAssemblyLocator>(() => new DefaultAssemblyLocator());
            Register(typeof(IAssemblyLocator), () => assemblyLocator.Value);

            // Setup the default hub pipeline
            var dispatcher = new Lazy<IHubPipeline>(() => new HubPipeline().AddModule(new AuthorizeModule()));
            Register(typeof(IHubPipeline), () => dispatcher.Value);
            Register(typeof(IHubPipelineInvoker), () => dispatcher.Value);
        }
开发者ID:SaveTrees,项目名称:SignalR,代码行数:31,代码来源:DefaultDependencyResolver.cs

示例7: ProductionQueueFromSelection

        public ProductionQueueFromSelection(World world, ProductionQueueFromSelectionInfo info)
        {
            this.world = world;

            tabsWidget = new Lazy<ProductionTabsWidget>(() =>
                Widget.RootWidget.GetWidget<ProductionTabsWidget>(info.ProductionTabsWidget));
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:7,代码来源:ProductionQueueFromSelection.cs

示例8: ApplicationVersionContextInitializer

 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationVersionContextInitializer" /> class.
 /// </summary>
 /// <param name="applicationVersion">The application version. If null, calculated from <see cref="Assembly.GetEntryAssembly"/>.</param>
 public ApplicationVersionContextInitializer(string applicationVersion = null)
 {
     _applicationVersion = new Lazy<string>(() =>
         String.IsNullOrWhiteSpace(applicationVersion)
             ? (Assembly.GetEntryAssembly()?.ToString() ?? Assembly.GetExecutingAssembly().ToString())
             : applicationVersion);
 }
开发者ID:fidmor89,项目名称:SLAB_AppInsights,代码行数:11,代码来源:ApplicationVersionContextInitializer.cs

示例9: Chapter

        public Chapter()
        {
            pagesUrl = new Lazy<IEnumerable<Page>>(() =>
            {
                var content = Utility.GetContent(Uri);

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(content);
                List<Page> pages = new List<Page>();

                doc.DocumentNode
                    .SelectNodes("//select[@id=\"pageMenu\"]//option")
                    .ToList()
                    .ForEach(p =>
                    {
                        Page page = new Page
                        {
                            ChapterName = Title,
                            ChapterNumber = Number,
                            PageNumber = Convert.ToInt32(p.NextSibling.InnerText),
                            Uri = MangaPanda.BaseUrl + p.Attributes["value"].Value
                        };

                        pages.Add(page);
                    });

                return pages;
            });
        }
开发者ID:vgdagpin,项目名称:MangaAPI,代码行数:29,代码来源:Chapter.cs

示例10: AbpNHibernateInterceptor

        public AbpNHibernateInterceptor(IIocManager iocManager)
        {
            _iocManager = iocManager;

            _abpSession =
                new Lazy<IAbpSession>(
                    () => _iocManager.IsRegistered(typeof(IAbpSession))
                        ? _iocManager.Resolve<IAbpSession>()
                        : NullAbpSession.Instance,
                    isThreadSafe: true
                    );
            _guidGenerator =
                new Lazy<IGuidGenerator>(
                    () => _iocManager.IsRegistered(typeof(IGuidGenerator))
                        ? _iocManager.Resolve<IGuidGenerator>()
                        : SequentialGuidGenerator.Instance,
                    isThreadSafe: true
                    );

            _eventBus =
                new Lazy<IEventBus>(
                    () => _iocManager.IsRegistered(typeof(IEventBus))
                        ? _iocManager.Resolve<IEventBus>()
                        : NullEventBus.Instance,
                    isThreadSafe: true
                );
        }
开发者ID:vytautask,项目名称:aspnetboilerplate,代码行数:27,代码来源:AbpNHibernateInterceptor.cs

示例11: UseRedis

        /// <summary>
        /// Use Redis as the messaging backplane for scaling out of ASP.NET SignalR applications in a web farm.
        /// </summary>
        /// <param name="resolver">The dependency resolver</param>
        /// <param name="configuration">The Redis scale-out configuration options.</param> 
        /// <returns>The dependency resolver.</returns>
        public static IDependencyResolver UseRedis(this IDependencyResolver resolver, RedisScaleoutConfiguration configuration)
        {
            var bus = new Lazy<RedisMessageBus>(() => new RedisMessageBus(resolver, configuration, new RedisConnection()));
            resolver.Register(typeof(IMessageBus), () => bus.Value);

            return resolver;
        }
开发者ID:ZixiangBoy,项目名称:SignalR-1,代码行数:13,代码来源:DependencyResolverExtensions.cs

示例12: WebWorkContext

        public WebWorkContext(Func<string, ICacheManager> cacheManager,
            HttpContextBase httpContext,
            ICustomerService customerService,
			IStoreContext storeContext,
            IAuthenticationService authenticationService,
            ILanguageService languageService,
            ICurrencyService currencyService,
			IGenericAttributeService attrService,
            TaxSettings taxSettings, CurrencySettings currencySettings,
            LocalizationSettings localizationSettings, Lazy<ITaxService> taxService,
            IStoreService storeService, ISettingService settingService,
			IUserAgent userAgent)
        {
            this._cacheManager = cacheManager("static");
            this._httpContext = httpContext;
            this._customerService = customerService;
            this._storeContext = storeContext;
            this._authenticationService = authenticationService;
            this._languageService = languageService;
            this._attrService = attrService;
            this._currencyService = currencyService;
            this._taxSettings = taxSettings;
            this._taxService = taxService;
            this._currencySettings = currencySettings;
            this._localizationSettings = localizationSettings;
            this._storeService = storeService;
            this._settingService = settingService;
            this._userAgent = userAgent;
        }
开发者ID:ejimenezdelgado,项目名称:SmartStoreNET,代码行数:29,代码来源:WebWorkContext.cs

示例13: ExecuteCommand

		private static void ExecuteCommand(CommandType command, DirectoryInfo baseDirectory, Lazy<Uri> url, string userName, string password) 
		{
			var engine = Engine.CreateStandard(baseDirectory);
			switch (command)
			{
				case CommandType.Help:
					break;
				case CommandType.Generate:
					var generatedDocuments = engine.Generate();
					foreach (var generatedDocument in generatedDocuments)
					{
						System.Console.WriteLine(generatedDocument);
						System.Console.WriteLine();
					}
					break;
				case CommandType.Check:
					var haveChanged =
						engine.CheckIfChanged(url.Value, userName, password);
					System.Console.WriteLine(haveChanged? "Changed": "Have not changed");
					break;
				case CommandType.Push:
					engine.PushIfChanged(url.Value, userName, password);
					break;
				case CommandType.Purge:
					engine.PurgeDatabase(url.Value, userName, password);
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
		}
开发者ID:artikh,项目名称:CouchDude.SchemeManager,代码行数:30,代码来源:Program.cs

示例14: ProductionPaletteWidget

        public ProductionPaletteWidget([ObjectCreator.Param] World world,
		                               [ObjectCreator.Param] WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = new Lazy<TooltipContainerWidget>(() =>
                Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => Game.modData.SpriteLoader.LoadAllSprites(
                        u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);

            overlayFont = Game.Renderer.Fonts["TinyBold"];
            holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2;
            readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2;
            timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4,2);
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:25,代码来源:ProductionPaletteWidget.cs

示例15: ConfigSource

 public ConfigSource(FubuRegistry provenance, IConfigurationAction action)
 {
     _provenance = provenance;
     _action = action;
     Id = Guid.NewGuid();
     _description = new Lazy<Description>(() => Description.For(action));
 }
开发者ID:aluetjen,项目名称:fubumvc,代码行数:7,代码来源:ConfigSource.cs


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