本文整理汇总了C#中IInjector类的典型用法代码示例。如果您正苦于以下问题:C# IInjector类的具体用法?C# IInjector怎么用?C# IInjector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInjector类属于命名空间,在下文中一共展示了IInjector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ContextRuntime
/// <summary>
/// Create a new ContextRuntime.
/// </summary>
/// <param name="serviceInjector"></param>
/// <param name="contextConfiguration">the Configuration for this context.</param>
/// <param name="parentContext"></param>
public ContextRuntime(
IInjector serviceInjector,
IConfiguration contextConfiguration,
Optional<ContextRuntime> parentContext)
{
ContextConfiguration config = contextConfiguration as ContextConfiguration;
if (config == null)
{
var e = new ArgumentException("contextConfiguration is not of type ContextConfiguration");
Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
}
_contextLifeCycle = new ContextLifeCycle(config.Id);
_serviceInjector = serviceInjector;
_parentContext = parentContext;
try
{
_contextInjector = serviceInjector.ForkInjector();
}
catch (Exception e)
{
Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
Optional<string> parentId = ParentContext.IsPresent() ?
Optional<string>.Of(ParentContext.Value.Id) :
Optional<string>.Empty();
ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
}
// Trigger the context start events on contextInjector.
_contextLifeCycle.Start();
}
开发者ID:kijungs,项目名称:incubator-reef,代码行数:38,代码来源:ContextRuntime.cs
示例2: GroupCommClient
public GroupCommClient(
[Parameter(typeof(GroupCommConfigurationOptions.SerializedGroupConfigs))] ISet<string> groupConfigs,
[Parameter(typeof(TaskConfigurationOptions.Identifier))] string taskId,
StreamingNetworkService<GeneralGroupCommunicationMessage> networkService,
AvroConfigurationSerializer configSerializer,
IInjector injector)
{
_commGroups = new Dictionary<string, ICommunicationGroupClientInternal>();
_networkService = networkService;
foreach (string serializedGroupConfig in groupConfigs)
{
IConfiguration groupConfig = configSerializer.FromString(serializedGroupConfig);
IInjector groupInjector = injector.ForkInjector(groupConfig);
var commGroupClient = (ICommunicationGroupClientInternal)groupInjector.GetInstance<ICommunicationGroupClient>();
_commGroups[commGroupClient.GroupName] = commGroupClient;
}
networkService.Register(new StringIdentifier(taskId));
foreach (var group in _commGroups.Values)
{
group.WaitingForRegistration();
}
}
开发者ID:NurimOnsemiro,项目名称:reef,代码行数:25,代码来源:GroupCommClient.cs
示例3: Approve
public static bool Approve(IInjector injector, IEnumerable<object> guards)
{
object guardInstance;
foreach (object guard in guards)
{
if (guard is Func<bool>)
{
if ((guard as Func<bool>)())
continue;
return false;
}
if (guard is Type)
{
if (injector != null)
guardInstance = injector.InstantiateUnmapped(guard as Type);
else
guardInstance = Activator.CreateInstance(guard as Type);
}
else
guardInstance = guard;
MethodInfo approveMethod = guardInstance.GetType().GetMethod("Approve");
if (approveMethod != null)
{
if ((bool)approveMethod.Invoke (guardInstance, null) == false)
return false;
}
else
{
throw(new Exception (String.Format("Guard {0} is not a valid guard. It doesn't have the method 'Approve'", guardInstance)));
}
}
return true;
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:35,代码来源:Guards.cs
示例4: EvaluatorSettings
private EvaluatorSettings(
[Parameter(typeof(ApplicationIdentifier))] string applicationId,
[Parameter(typeof(EvaluatorIdentifier))] string evaluatorId,
[Parameter(typeof(EvaluatorHeartbeatPeriodInMs))] int heartbeatPeriodInMs,
[Parameter(typeof(HeartbeatMaxRetry))] int maxHeartbeatRetries,
[Parameter(typeof(RootContextConfiguration))] string rootContextConfigString,
RuntimeClock clock,
IRemoteManagerFactory remoteManagerFactory,
REEFMessageCodec reefMessageCodec,
IInjector injector)
{
_injector = injector;
_applicationId = applicationId;
_evaluatorId = evaluatorId;
_heartBeatPeriodInMs = heartbeatPeriodInMs;
_maxHeartbeatRetries = maxHeartbeatRetries;
_clock = clock;
if (string.IsNullOrWhiteSpace(rootContextConfigString))
{
Utilities.Diagnostics.Exceptions.Throw(
new ArgumentException("empty or null rootContextConfigString"), Logger);
}
_rootContextConfig = new ContextConfiguration(rootContextConfigString);
_rootTaskConfiguration = CreateTaskConfiguration();
_rootServiceConfiguration = CreateRootServiceConfiguration();
_remoteManager = remoteManagerFactory.GetInstance(reefMessageCodec);
_operationState = EvaluatorOperationState.OPERATIONAL;
}
开发者ID:NurimOnsemiro,项目名称:reef,代码行数:30,代码来源:EvaluatorSettings.cs
示例5: ModuleConnector
/*============================================================================*/
/* Constructor */
/*============================================================================*/
/**
* @private
*/
public ModuleConnector(IContext context)
{
IInjector injector= context.injector;
_rootInjector = GetRootInjector(injector);
_localDispatcher = injector.GetInstance(typeof(IEventDispatcher)) as IEventDispatcher;
context.WhenDestroying(Destroy);
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:14,代码来源:ModuleConnector.cs
示例6: ContextRuntime
public ContextRuntime(
string id,
IInjector serviceInjector,
IConfiguration contextConfiguration)
{
// This should only be used at the root context to support backward compatibility.
LOGGER.Log(Level.Info, "Instantiating root context");
_contextLifeCycle = new ContextLifeCycle(id);
_serviceInjector = serviceInjector;
_parentContext = Optional<ContextRuntime>.Empty();
try
{
_contextInjector = serviceInjector.ForkInjector();
}
catch (Exception e)
{
Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
Optional<string> parentId = ParentContext.IsPresent() ?
Optional<string>.Of(ParentContext.Value.Id) :
Optional<string>.Empty();
ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
}
// Trigger the context start events on contextInjector.
_contextLifeCycle.Start();
}
开发者ID:LastOne817,项目名称:reef,代码行数:29,代码来源:ContextRuntime.cs
示例7: Apply
public static void Apply(IInjector injector, IEnumerable<object> hooks)
{
object hookInstance;
foreach (object hook in hooks)
{
if (hook is Action)
{
(hook as Action)();
continue;
}
if (hook is Type)
{
if (injector != null)
hookInstance = injector.InstantiateUnmapped(hook as Type);
else
hookInstance = Activator.CreateInstance(hook as Type);
}
else
hookInstance = hook;
MethodInfo hookMethod = hookInstance.GetType().GetMethod("Hook");
if (hookMethod != null)
hookMethod.Invoke (hookInstance, null);
else
throw new Exception ("Invalid hook to apply");
}
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:28,代码来源:Hooks.cs
示例8: Process
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
public void Process(object view, Type type, IInjector injector)
{
if(!_injectedObjects.ContainsKey(view))
{
InjectAndRemember(view, injector);
}
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:11,代码来源:ViewInjectionProcessor.cs
示例9: CommandMap
//---------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------
/**
* Creates a new <code>CommandMap</code> object
*
* @param eventDispatcher The <code>IEventDispatcher</code> to listen to
* @param injector An <code>IInjector</code> to use for this context
* @param reflector An <code>IReflector</code> to use for this context
*/
public CommandMap( IEventDispatcher eventDispatcher, IInjector injector, IReflector reflector )
{
this.eventDispatcher = eventDispatcher;
this.injector = injector;
this.reflector = reflector;
this.eventTypeMap = new Dictionary<string,Dictionary<Type, Dictionary<Type, Action<Event>>>>();
this.verifiedCommandClasses = new Dictionary<Type,bool>();
}
开发者ID:tekool,项目名称:silverlight-robotlegs-framework,代码行数:18,代码来源:CommandMap.cs
示例10: EventCommandTrigger
/*============================================================================*/
/* Constructor */
/*============================================================================*/
public EventCommandTrigger (IInjector injector, IEventDispatcher dispatcher, Enum type, Type eventClass = null, IEnumerable<CommandMappingList.Processor> processors = null, ILogger logger = null)
{
_dispatcher = dispatcher;
_type = type;
_eventClass = eventClass;
_mappings = new CommandMappingList(this, processors, logger);
_executor = new CommandExecutor(injector, _mappings.RemoveMapping);
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:12,代码来源:EventCommandTrigger.cs
示例11: ViewMap
//---------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------
/**
* Creates a new <code>ViewMap</code> object
*
* @param contextView The root view node of the context. The map will listen for ADDED_TO_STAGE events on this node
* @param injector An <code>IInjector</code> to use for this context
*/
public ViewMap( FrameworkElement contextView, IInjector injector )
: base(contextView, injector)
{
// mappings - if you can do it with fewer dictionaries you get a prize
this.mappedPackages = new List<string>();
this.mappedTypes = new Dictionary<Type,Type>();
this.injectedViews = new Dictionary<FrameworkElement,bool>(); //Warning was marked as weak
}
开发者ID:tekool,项目名称:silverlight-robotlegs-framework,代码行数:17,代码来源:ViewMap.cs
示例12: Unprocess
public void Unprocess(object view, Type type, IInjector injector)
{
if (_createdMediatorsByView.ContainsKey(view))
{
DestroyMediator(_createdMediatorsByView[view]);
_createdMediatorsByView.Remove(view);
}
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:8,代码来源:MediatorCreator.cs
示例13: MediatorFactory
/*============================================================================*/
/* Constructor */
/*============================================================================*/
public MediatorFactory (IInjector injector)
{
_injector = injector;
_manager = injector.HasMapping (typeof(IMediatorManager))
? injector.GetInstance (typeof(IMediatorManager)) as IMediatorManager
: new MediatorManager ();
_manager.ViewRemoved += RemoveMediators;
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:12,代码来源:MediatorFactory.cs
示例14: ViewMapBase
//---------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------
/**
* Creates a new <code>ViewMap</code> object
*
* @param contextView The root view node of the context. The map will listen for ADDED_TO_STAGE events on this node
* @param injector An <code>IInjector</code> to use for this context
*/
public ViewMapBase( FrameworkElement contextView, IInjector injector )
{
this.injector = injector;
// change this at your peril lest ye understand the problem and have a better solution
this.useCapture = true;
// this must come last, see the setter
this.ContextView = contextView;
}
开发者ID:tekool,项目名称:silverlight-robotlegs-framework,代码行数:19,代码来源:ViewMapBase.cs
示例15: Setup
public void Setup()
{
injector = new RobotlegsInjector();
viewInjector = new ViewInjectionProcessor();
injectionValue = MapSpriteForInjection();
view = new ViewWithInjection();
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:7,代码来源:ViewInjectionProcessorTest.cs
示例16: Setup
public void Setup()
{
injector = new robotlegs.bender.framework.impl.RobotlegsInjector();
viewProcessorFactory = new ViewProcessorFactory(injector);
trackingProcessor = new TrackingProcessor();
view = new object();
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:7,代码来源:ViewProcessorFactoryTest.cs
示例17: before
public void before()
{
context = new Context();
injector = context.injector;
injector.Map<IDirectCommandMap>().ToType<DirectCommandMap>();
subject = injector.GetInstance<IDirectCommandMap>() as DirectCommandMap;
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:7,代码来源:DirectCommandMapTest.cs
示例18: Extend
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
public void Extend(IContext context)
{
_injector = context.injector;
_logger = context.GetLogger(this);
context.AfterInitializing (BeforeInitializing);
context.AddConfigHandler(new InstanceOfMatcher (typeof(IContextView)), AddContextView);
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:11,代码来源:ContextViewExtension.cs
示例19: Extend
public void Extend (IContext context)
{
_injector = context.injector;
_parentFinder = new SupportParentFinder();
_injector.Map(typeof(IParentFinder)).ToValue(_parentFinder);
context.BeforeInitializing(BeforeInitializing);
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:8,代码来源:SupportParentFinderExtension.cs
示例20: Extend
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
public void Extend(IContext context)
{
context.BeforeInitializing(BeforeInitializing)
.BeforeDestroying(BeforeDestroying)
.WhenDestroying(WhenDestroying);
_injector = context.injector;
_injector.Map (typeof(IMediatorMap)).ToSingleton (typeof(MediatorMap));
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:12,代码来源:MediatorMapExtension.cs
注:本文中的IInjector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论