Example #1
0
        /// <summary>
        /// 从ComponentFactory配置节点获取插件信息
        /// </summary>
        /// <param name="nodeName">配置节点名称</param>
        /// <returns>配置对象PluginUtils</returns>
        public static PluginUtils GetComponentAssemblerInfo(string nodeName)
        {
            if (doc == null)
            {
                GetPluginData();
            }

            XmlNode     root = doc.DocumentElement;
            XmlNode     node = root.SelectSingleNode("ComponentFactory/" + nodeName);
            PluginUtils util = new PluginUtils();

            util.AssemblerName   = node.Attributes["LoadFromAssembly"].Value;
            util.FacadeNameSpace = node.Attributes["FacadeNameSpace"].Value;
            return(util);
        }
Example #2
0
        /// <summary>
        /// 获取指定类型插件
        /// 如果没有Cache,则Create
        /// </summary>
        /// <returns>构造的对象</returns>
        public static T GetPlugin()
        {
            string key    = PluginUtils.ConcisionTypeName <T>();
            T      plugin = (T)cache[key];

            lock (syncObj)
            {
                if (null == plugin)
                {
                    plugin = BuildPlugin();
                    if (plugin != null)
                    {
                        cache[key] = plugin;
                    }
                }
            }
            return(plugin);
        }