protected override SceneNode InternalCreateRawInstance(ITypeId instanceType) { IType type = this.ViewModel.ProjectContext.ResolveType(instanceType); if (type != null && type.RuntimeType != (System.Type)null) { ToolboxExampleAttribute attribute = TypeUtilities.GetAttribute <ToolboxExampleAttribute>(type.RuntimeType); if (attribute != null) { IToolboxExampleFactory toolboxExampleFactory = Activator.CreateInstance(attribute.ToolboxExampleFactoryType) as IToolboxExampleFactory; if (toolboxExampleFactory != null && toolboxExampleFactory.Examples != null) { IToolboxExample[] toolboxExampleArray = Enumerable.ToArray <IToolboxExample>(toolboxExampleFactory.Examples); if (this.exampleInfo.Index < toolboxExampleArray.Length) { IToolboxExample toolboxExample = toolboxExampleArray[this.exampleInfo.Index]; if (toolboxExample != null) { ISceneNodeModelItem sceneNodeModelItem = toolboxExample.CreateExample(this.ViewModel.ExtensibilityManager.EditingContext) as ISceneNodeModelItem; if (sceneNodeModelItem != null && sceneNodeModelItem.SceneNode != null) { return(sceneNodeModelItem.SceneNode); } } } } } } return(base.InternalCreateRawInstance(instanceType)); }
public static ExampleAssetInfo FromToolboxExample(IToolboxExample example, int index) { return(new ExampleAssetInfo() { Index = index, DisplayName = example.DisplayName, Description = AssetInfoModel.GetDescription(example.GetType()), Categories = Enumerable.ToArray <CustomAssetCategoryPath>(AssetTypeHelper.GetCustomAssetCategoryPaths(example.GetType())), IsBrowable = AssetTypeHelper.IsTypeBrowsable(example.GetType()), SmallIcon = ExampleAssetInfo.CopyStream(example.GetImageStream(new Size(12.0, 12.0))), LargeIcon = ExampleAssetInfo.CopyStream(example.GetImageStream(new Size(24.0, 24.0))) }); }