view Implab.ServiceHost/Unity/InjectionValueContext.cs @ 273:79110a16cab7 v3

Working on Unity xml configuration: Refactoring in progress
author cin
date Thu, 26 Apr 2018 19:35:01 +0300
parents
children
line wrap: on
line source

using System;
using Unity.Injection;

namespace Implab.ServiceHost.Unity {

    public class InjectionValueContext {

        readonly TypeResolver m_resolver;

        public Type AcceptsType { get; private set; }

        public object Value { get; set; }

        internal InjectionValueContext(TypeResolver resolver, Type acceptsType) {
            m_resolver = resolver;
            AcceptsType = acceptsType;
        }

        public Type ResolveType(string typeSpec) {
            if (string.IsNullOrEmpty(typeSpec)) {
                if (AcceptsType == null)
                    throw new Exception("The type must be specified");
                return AcceptsType;
            }
            return m_resolver.Resolve(typeSpec);
        }

        public void Visit(ITextValue value) {

        }

        public void Visit(ISerializedValue value) {

        }

        public void Visit(IDependencyReference value) {
            Value = new ResolvedParameter()
        }

    }
}