using System;
using System.Reflection;
using Chernobyl.Collections.Generic.Event;
using Chernobyl.Event;
using Chernobyl.Utility;
namespace Chernobyl.Dependency
{
///
/// Used to mark an instance that needs to be retrieved from an
/// instance. When this
/// instance has it's
///
/// method invoked, it will take the instance from the
/// provided but only if that instance exists. Otherwise the property will
/// set the instance when it receives that instance.
///
[AttributeUsage(AttributeTargets.Property)]
public class InjectAttribute : ServiceAttribute
{
///
/// Initializes a new instance of the
/// class.
///
public InjectAttribute()
{ }
///
/// Initializes a new instance of the
/// class.
///
/// The location of the service within the
/// hierarchy or an empty array if the service
/// is at the root of the hierarchy. This array
/// represents the "path" that must be taken through the hierarchy of
/// to get to the location where the service
/// specified by resides. Each
/// must implement the
/// interface. An example of what the service path might look like
/// (using '/' as separators):
/// /IEventEnumerable/IGraphicsServices/ITextureServices
/// In this example, the service represented by
/// is located in the ITextureServices. That
/// is located within IGraphicsServices which
/// is located at the root .
public InjectAttribute(params Type[] location)
: base(location)
{ }
///
/// Retrieves the service from the instance
/// and passes it to the provided.
///
/// The instance that allows access to the other
/// services and provides adding or removing of specific services.
/// The instance that contained a code element that
/// was attributed with a instance.
/// The code element that was attributed
/// with a and whose service needs to be
/// added into the .
public override void Resolve(IEventCollection