Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns type identifier for a given type
 /// </summary>
 /// <param name="type">Type to identify</param>
 /// <returns>Type ID, or empty Guid if not found</returns>
 public Guid GetTypeId(Type type)
 {
     return(typesService.GetTypeIdCached(type));
 }