本文整理汇总了C#中IApplicationContext.GetObjectsOfType方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationContext.GetObjectsOfType方法的具体用法?C# IApplicationContext.GetObjectsOfType怎么用?C# IApplicationContext.GetObjectsOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationContext
的用法示例。
在下文中一共展示了IApplicationContext.GetObjectsOfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunExample
protected override void RunExample(IApplicationContext ctx)
{
var factory = ctx.GetObject<Factory>();
factory.Create("Car");
factory.Create("Motorcycle");
factory.Create("Luxury Car");
var shopsInContext = ctx.GetObjectsOfType(typeof(Shop)).Values.OfType<Shop>().Select(s => s.ToString()).ToArray();
Console.WriteLine("Shops available in context: {0}", string.Join(",", shopsInContext));
Console.WriteLine("Done...");
}
示例2: GetAllInstancesRecursive
private static void GetAllInstancesRecursive(IApplicationContext context, Type serviceType, ref ICollection<object> result)
{
if (context == null)
return;
foreach (var o in context.GetObjectsOfType(serviceType).Values)
{
result.Add(o);
}
GetAllInstancesRecursive(context.ParentContext, serviceType, ref result);
}
示例3: Form1
public Form1()
{
InitializeComponent();
mediaTree = leftPanel1.Summary;
mediaTree.SelectedItemChanged += new EventHandler(mediaTree_AfterSelect);
mediaStore = new MediaStore();
mediaItems = new List<MediaItem>();
foreach (MediaItem item in mediaStore.GetAllMedia())
mediaItems.Add(item);
leftPanel1.Initialise(mediaItems);
ctx = ContextRegistry.GetContext();
foreach (DictionaryEntry entry in ctx.GetObjectsOfType(typeof(MediaTypeProvider)))
{
MediaTypeProvider provider = (MediaTypeProvider)entry.Value;
providers[provider.Name] = provider;
drpItemTypes.Items.Add(new ListItem(provider, provider.Name));
}
drpItemTypes.SelectedIndex = 0;
UpdateDisplay();
}