예제 #1
0
 public void RegisterType <TType>(Export expAttribute = null)
 {
     RegisterType <TType, TType>(expAttribute);
 }
예제 #2
0
        private void HandleExportAttribute(Type typeContract, Type typeImplementation, Export exportAttribute = null)
        {
            Export _exportAttribute = null;

            if (exportAttribute != null)
            {
                _exportAttribute = exportAttribute;
            }
            else
            {
                Attribute[] attrs = Attribute.GetCustomAttributes(typeImplementation);

                _exportAttribute = attrs.Where(a => a.GetType() == typeof(Export)).FirstOrDefault() as Export;
            }

            if (_exportAttribute == null && !_instanceList.IsSharedType(typeContract, typeImplementation))
            {
                _instanceList.Add(typeContract, typeImplementation);
            }
            else if (_exportAttribute != null &&
                     _exportAttribute.CreationPolicy == CreationPolicy.Shared &&
                     !_instanceList.IsSharedType(_exportAttribute.ContractType, typeImplementation))
            {
                _instanceList.Add(_exportAttribute.ContractType, typeImplementation);
            }
        }