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


C# IContext.Resolve方法代码示例

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


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

示例1: CreateHudOverlaySetView

        HudOverlaySetView CreateHudOverlaySetView(IContext container, IEnumerable<Parameter> parameters)
        {
            ITexture consoleTexture = container.Resolve<ITexture>(new TypedParameter(typeof(Texture2D), ContentManager.Load<Texture2D>("Textures/blank")));
            IFont consoleFont = container.Resolve<IFont>(new TypedParameter(typeof(SpriteFont), ContentManager.Load<SpriteFont>("Fonts/detailsFont")));
            int edgeGap = OverlaySetView.EDGE_GAP;

            Rectangle scoreWindow = new Rectangle((int)(ScreenSize.X / 2) + 30 + edgeGap, (int)(ScreenSize.Y / 2) + edgeGap, (int)(ScreenSize.X / 2) - 30 - 2 * edgeGap, (int)(ScreenSize.Y / 2) - InputBoxHeight - 3 * edgeGap);
            var scoreView = container.Resolve<ScoreOverlayView>(new TypedParameter(typeof(IFont), consoleFont), new NamedParameter("scoreWindow", scoreWindow));

            return new HudOverlaySetView(scoreView, container.Resolve<ISpriteBatch>(), consoleTexture, consoleFont);
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:11,代码来源:OverlaysModule.cs

示例2: CloudInfrastructureProviders

		static CloudInfrastructureProviders CloudInfrastructureProviders(IContext c)
		{
			return new CloudInfrastructureProviders(
				// storage providers supporting the O/C mapper scenario
				c.Resolve<IBlobStorageProvider>(),
				c.Resolve<IQueueStorageProvider>(),
				c.Resolve<ITableStorageProvider>(),

				// optional providers supporting the execution framework scenario
				c.ResolveOptional<ILog>(),
				c.ResolveOptional<IProvisioningProvider>(),
				c.ResolveOptional<IRuntimeFinalizer>());
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:13,代码来源:StorageModule.cs

示例3: SettingsControl

		public SettingsControl(IContext context)
		{
			_areaControls = new List<ConfigurationControlBase>();

			InitializeComponent();

			Tasks.TaskListPresentationModel m = context.Resolve<Tasks.TaskListPresentationModel>();
			_tasksButton.Tag = m.View;
			_areaControls.Add((ConfigurationControlBase) _tasksButton.Tag);

			_writingSystemButton.Tag = new WritingSystemSetup();
			_areaControls.Add((ConfigurationControlBase) _writingSystemButton.Tag);

			_fieldsButton.Tag = new FieldsControl();
			_areaControls.Add((ConfigurationControlBase) _fieldsButton.Tag);

			_interfaceLanguageButton.Tag = new InterfaceLanguageControl();
			_areaControls.Add((ConfigurationControlBase) _interfaceLanguageButton.Tag);

			_actionsButton.Tag = new ActionsControl();
			_areaControls.Add((ConfigurationControlBase) _actionsButton.Tag);

			_backupButton.Tag = new BackupPlanControl();
			_areaControls.Add((ConfigurationControlBase) _backupButton.Tag);

			_chorusButton.Tag = new ChorusControl();
			_areaControls.Add((ConfigurationControlBase)_chorusButton.Tag);

		   _optionsListButton.Tag = new OptionListControl();
			_areaControls.Add((ConfigurationControlBase) _optionsListButton.Tag);

			SetStyle(ControlStyles.ResizeRedraw, true); //makes OnPaint work
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:33,代码来源:SettingsControl.cs

示例4: CreateTaskConfiguration

		private ITaskConfiguration CreateTaskConfiguration(IContext context, TaskTypeCatalog taskTypes, XPathNavigator taskNode)
		{
			string taskName = taskNode.GetAttribute("taskName", string.Empty);

			if (taskTypes.TaskNameToConfigType.ContainsKey(taskName)) //has a config class
			{
				//make the task configuration class, using the xml we're looking at
				return context.Resolve<ITaskConfiguration>(taskName + "Config",// using this service name
												   new Parameter[] { new TypedParameter(typeof(string), taskNode.OuterXml) });
			}
			return null;
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:12,代码来源:ConfigFileReader.cs

示例5: CreateConsoleOverlaySetView

        ConsoleOverlaySetView CreateConsoleOverlaySetView(IContext container, IEnumerable<Parameter> parameters)
        {
            ITexture consoleTexture = container.Resolve<ITexture>(new TypedParameter(typeof(Texture2D), ContentManager.Load<Texture2D>("Textures/blank")));
            IFont consoleFont = container.Resolve<IFont>(new TypedParameter(typeof(SpriteFont), ContentManager.Load<SpriteFont>("Fonts/detailsFont")));
            int edgeGap = OverlaySetView.EDGE_GAP;

            Rectangle consoleWindow = new Rectangle(edgeGap, edgeGap, (int)(ScreenSize.X / 2) - 30 - edgeGap, (int)ScreenSize.Y - InputBoxHeight - 3 * edgeGap);
            Rectangle messageWindow = new Rectangle((int)(ScreenSize.X / 2) + 30 + edgeGap, edgeGap, (int)(ScreenSize.X / 2) - 30 - 2 * edgeGap, (int)(ScreenSize.Y / 2) - 2 * edgeGap);
            Rectangle inputWindow = new Rectangle(edgeGap, (int)ScreenSize.Y - edgeGap - InputBoxHeight, (int)ScreenSize.X - 2 * edgeGap, InputBoxHeight);
            Rectangle possibleCompletionsWindow = new Rectangle((int)(consoleWindow.Right / 2), consoleWindow.Bottom - edgeGap, (int)(messageWindow.Width / 2), 0);

            var fontParameter = new TypedParameter(typeof(IFont), consoleFont);
            var commandConsoleParameter = new TypedParameter(typeof(IConsole<string>), container.Resolve<ICommandConsole>());
            var messageConsoleParameter = new TypedParameter(typeof(IConsole<ChatMessage>), container.Resolve<IMessageConsole>());
            var inputView = container.Resolve<InputOverlayView>(fontParameter, new NamedParameter("inputWindow", inputWindow));
            var commandConsoleView = container.Resolve<LogOverlayView<string>>(fontParameter, commandConsoleParameter, new NamedParameter("logWindow", consoleWindow), new TypedParameter(typeof(Color), Color.White));
            var messageConsoleView = container.Resolve<LogOverlayView<ChatMessage>>(fontParameter, messageConsoleParameter, new NamedParameter("logWindow", messageWindow), new TypedParameter(typeof(Color), Color.Green));
            var possibleCommandsView = container.Resolve<PossibleCommandsLogHudView>(fontParameter, new TypedParameter(typeof(ICommandConsole), container.Resolve<ICommandConsole>()), new NamedParameter("templateWindow", possibleCompletionsWindow), new TypedParameter(typeof(Color), Color.Yellow));

            return new ConsoleOverlaySetView(inputView, commandConsoleView, messageConsoleView, possibleCommandsView, container.Resolve<ISpriteBatch>(), consoleTexture, consoleFont);
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:21,代码来源:OverlaysModule.cs

示例6: StorageAccountFromSettings

		private static CloudStorageAccount StorageAccountFromSettings(IContext c)
		{
			var settings = c.Resolve<ICloudConfigurationSettings>();
			CloudStorageAccount account;
			if (CloudStorageAccount.TryParse(settings.DataConnectionString, out account))
			{
				// http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx
				ServicePointManager.FindServicePoint(account.BlobEndpoint).UseNagleAlgorithm = false;
				ServicePointManager.FindServicePoint(account.TableEndpoint).UseNagleAlgorithm = false;
				ServicePointManager.FindServicePoint(account.QueueEndpoint).UseNagleAlgorithm = false;

				return account;
			}
			throw new InvalidOperationException("Failed to get valid connection string");
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:15,代码来源:StorageModule.cs

示例7: CreateTask

		private static ITask CreateTask(IContext context, ITaskConfiguration config)
		{
			try
			{
				//make the task itself, handing it this configuration object.
				//its other constructor arguments come "automatically" out of the context
				return context.Resolve<ITask>(config.TaskName, new Parameter[] { new NamedParameter("config", config) });
			}
			catch (Exception e)
			{
				string message = e.Message;
				while (e.InnerException != null) //the user will see this, so lets dive down to the actual cause
				{
					e = e.InnerException;
					message = e.Message;
				}
				return new FailedLoadTask(config.TaskName, "", message);
			}
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:19,代码来源:ConfigFileTaskBuilder.cs

示例8: GetDecoratedTransport

		private static ITransport GetDecoratedTransport(IContext context, Type transportType)
		{
			var container = context.Resolve<ThreadScopedContainer>();
			return new MessageSinkTransport(
				context.Resolve(transportType) as ITransport, () => container.Resolve<MasterSink>());
		}
开发者ID:thirkcircus,项目名称:NServiceBus.MessageSinks,代码行数:6,代码来源:MessageSinkConfigurationModule.cs

示例9: QueueStorageProvider

		static IQueueStorageProvider QueueStorageProvider(IContext c)
		{
			IDataSerializer formatter;
			if (!c.TryResolve(out formatter))
			{
				formatter = new CloudFormatter();
			}

			return new QueueStorageProvider(
				c.Resolve<CloudQueueClient>(),
				c.Resolve<IBlobStorageProvider>(),
				formatter,
				// RuntimeFinalizer is a dependency (as the name suggest) on the worker runtime
				// This dependency is typically not available in a pure O/C mapper scenario.
				// In such case, we just pass a dummy finalizer (that won't be used any
				c.ResolveOptional<IRuntimeFinalizer>());
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:17,代码来源:StorageModule.cs

示例10: TableStorageProvider

		static ITableStorageProvider TableStorageProvider(IContext c)
		{
			IDataSerializer formatter;
			if (!c.TryResolve(out formatter))
			{
				formatter = new CloudFormatter();
			}

			return new TableStorageProvider(c.Resolve<CloudTableClient>(), formatter);
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:10,代码来源:StorageModule.cs

示例11: QueueClient

		static CloudQueueClient QueueClient(IContext c)
		{
			var account = c.Resolve<CloudStorageAccount>();
			var queueService = account.CreateCloudQueueClient();
			queueService.RetryPolicy = BuildDefaultRetry();
			return queueService;
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:7,代码来源:StorageModule.cs

示例12: BlobClient

		static CloudBlobClient BlobClient(IContext c)
		{
			var account = c.Resolve<CloudStorageAccount>();
			var storage = account.CreateCloudBlobClient();
			storage.RetryPolicy = BuildDefaultRetry();
			return storage;
		}
开发者ID:cdrnet,项目名称:Lokad.Cloud,代码行数:7,代码来源:StorageModule.cs


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