当前位置: 首页>>代码示例>>C#>>正文


C# IPicoContainer.GetComponentInstance方法代码示例

本文整理汇总了C#中IPicoContainer.GetComponentInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IPicoContainer.GetComponentInstance方法的具体用法?C# IPicoContainer.GetComponentInstance怎么用?C# IPicoContainer.GetComponentInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPicoContainer的用法示例。


在下文中一共展示了IPicoContainer.GetComponentInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveInstance

 public virtual object ResolveInstance(IPicoContainer container, IComponentAdapter adapter, Type expectedType)
 {
     IComponentAdapter componentAdapter = ResolveAdapter(container, adapter, expectedType);
     if (componentAdapter != null)
     {
         return container.GetComponentInstance(componentAdapter.ComponentKey);
     }
     return null;
 }
开发者ID:smmckay,项目名称:picocontainer,代码行数:9,代码来源:BasicComponentParameter.cs

示例2: GetCollectionInstance

		private ICollection GetCollectionInstance(IPicoContainer container, Type expectedType, IDictionary adapterList)
		{
			Type collectionType = expectedType;
			if (collectionType.IsInterface)
			{
				// The order of tests are significant. The least generic types last.
				if (typeof (IList).IsAssignableFrom(collectionType))
				{
					collectionType = typeof (ArrayList);
				}
//            } else if (BlockingQueue.class.isAssignableFrom(collectionType)) {
//                collectionType = ArrayBlockingQueue.class;
//            } else if (Queue.class.isAssignableFrom(collectionType)) {
//                collectionType = LinkedList.class;
					/*} else if (SortedSet.class.isAssignableFrom(collectionType)) {
                collectionType = TreeSet.class;
            } else if (Set.class.isAssignableFrom(collectionType)) {
                collectionType = HashSet.class;
            }*/
				else if (typeof (ICollection).IsAssignableFrom(collectionType))
				{
					collectionType = typeof (ArrayList);
				}
			}
			try
			{
				IList result = (IList) Activator.CreateInstance(collectionType);

				foreach (DictionaryEntry entry in adapterList)
				{
					IComponentAdapter componentAdapter = (IComponentAdapter) entry.Value;
					result.Add(container.GetComponentInstance(componentAdapter.ComponentKey));
				}

				return result;
			}
			catch (Exception e)
			{
				throw new PicoInitializationException(e);

			}
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:42,代码来源:CollectionComponentParameter.cs

示例3: GetDictionaryInstance

		private IDictionary GetDictionaryInstance(IPicoContainer container, Type expectedType, IDictionary adapterList) 
		{
			Type collectionType = expectedType;
			if (collectionType.IsInterface) 
			{
				collectionType = typeof(Hashtable);
			}

			try 
			{
				IDictionary result = (IDictionary) Activator.CreateInstance(collectionType);
				foreach (DictionaryEntry entry in adapterList)
				{
					Object key = entry.Key;
					result.Add(key, container.GetComponentInstance(key));
				}
				return result;
			} 
			catch (Exception e)
			{
				throw new PicoInitializationException(e);
			}
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:23,代码来源:CollectionComponentParameter.cs

示例4: GetArrayInstance

		private object[] GetArrayInstance(IPicoContainer container, Type expectedType, IDictionary adapterList)
		{
			object[] result = (object[]) Array.CreateInstance(expectedType.GetElementType(), adapterList.Count);
			int i = 0;

			foreach (DictionaryEntry entry in adapterList)
			{
				IComponentAdapter componentAdapter = (IComponentAdapter) entry.Value;
				result[i] = container.GetComponentInstance(componentAdapter.ComponentKey);
				i++;
			}
			return result;
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:13,代码来源:CollectionComponentParameter.cs


注:本文中的IPicoContainer.GetComponentInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。