Exemplo n.º 1
0
        public object CreateInstance()
        {
            if (ImplementedType == null)
            {
                CreateType();
            }

            if (ImplementedType == null)
            {
                return(null);
            }

            var instance = Activator.CreateInstance(ImplementedType);

            if (methodImplementations.Any())
            {
                var dictField = ImplementedType.GetField(ILHelper.METHOD_DICTIONARY, BindingFlags.NonPublic | BindingFlags.Instance);

                var dict = (IDictionary <string, Delegate>)dictField.GetValue(instance);

                foreach (var impl in methodImplementations)
                {
                    dict.Add(impl.Key, impl.Value);
                }
            }

            return(instance);
        }
Exemplo n.º 2
0
 public override object Provide()
 {
     return(ImplementedType.New(Dependencies));
 }