예제 #1
0
        /// <summary>
        /// Creates new instance of type T
        /// </summary>
        /// <typeparam name="T">Interface type of instance to create</typeparam>
        /// <returns>Created object instance</returns>
        public T New <T>()
        {
            CheckThread();

            Guid typeId = typesService.GetTypeIdCached(typeof(T));

            if (typeId.Equals(Guid.Empty))
            {
                throw new ArgumentException("Type not registered:" + typeof(T).AssemblyQualifiedName);
            }

            Guid instanceId = Guid.Empty;

            if (typesService.IsDictionaryType(typeId))
            {
                instanceId = dictionaryInstancesService.NewInstance(typeId);
            }
            else
            if (typesService.IsCollectionType(typeId))
            {
                instanceId = collectionInstancesService.NewInstance(typeId);
            }
            else
            {
                instanceId = objectInstancesService.NewInstance(typeId);
            }

            T proxy = proxyCreatorService.NewObject <T>(runtimeProxyFacade, instanceId, false);

            mutableProxyMap.AddProxy(instanceId, proxy);
            return(proxy);
        }