Beispiel #1
0
        private static InitResponse GetInitPlug()
        {
            InitResponse initResponse = new InitResponse()
            {
                Inits = new List <TecheartSln.Core.IInit>(), TemplateBaseViewModels = new List <TemplateViewModelInit>(), ToolViewModels = new List <ToolViewModel>()
            };
            var paths = GetPlugsPath();

            foreach (var v in paths)
            {
                var dll = GetAssembly(v);
                foreach (var dlltype in dll.GetTypes())
                {
                    if (dlltype.Name == "Init")
                    {
                        var pluginit = (TecheartSln.Core.IInit)Activator.CreateInstance(dlltype);
                        initResponse.Inits.Add(pluginit);
                        foreach (var v3 in pluginit.GetToolViewModel())
                        {
                            initResponse.ToolViewModels.Add(v3);
                        }
                    }
                    if (dlltype.BaseType == typeof(TemplateBaseViewModel))
                    {
                        MethodInfo methodDesc = dlltype.GetMethod("TemplateGuid");
                        if (methodDesc == null)
                        {
                            continue;
                        }
                        TemplateViewModelInit templateViewModelInit = new TemplateViewModelInit()
                        {
                            TemplateType = dlltype, Identifier = methodDesc.Invoke(null, null).ToString()
                        };
                        initResponse.TemplateBaseViewModels.Add(templateViewModelInit);
                    }
                }
            }

            return(initResponse);
        }
Beispiel #2
0
 protected Workspace()
 {
     _files = new ObservableCollection <TemplateBaseViewModel>();
     MessageSubscribeRelations.AddSubscribe(MessageType.CloseTempleteEvemt, new Relation()
     {
         CanUninstall     = false,
         IsActive         = true,
         IsKeep           = true,
         RelationDescribe = "监听模板类窗口关闭事件",
         RelationGuid     = Guid.NewGuid().ToString(),
         RelationAction   = messageData =>
         {
             base.BindingPropInOtherTask(() =>
             {
                 JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                 var response = javaScriptSerializer.Deserialize <CloseTempleteRequest>(messageData.MessageData);
                 Close(response.TempleteGuid);
             });
         },
     });
     plugInit = PluginTools.Init();
 }
Beispiel #3
0
        public static InitResponse Init()
        {
            InitResponse initResponse = GetInitPlug();

            return(initResponse);
        }