using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Reflection;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Go go = new Go();
//获取当前执行的程序集中所有的标有特性标签的代码段
AssemblyCatalog catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
//将所有Export特性标签存放进组件容器中(其实是一个数组里面)
CompositionContainer container = new CompositionContainer(catalog);
//找到所传入对象中所有拥有Import特性标签的属性,并在组件容器的数组中找到与这些属性匹配的Export特性标签所标注的类,然后进行实例化并给这些属性赋值。
//简而言之,就是找到与Import对应的Export所标注的类,并用这个类的实例来给Import所标注的属性赋值,用于解耦。
container.ComposeParts(go);
if (go.test!=null)
{
go.test.show();
}
Console.ReadLine();
}
}
//定义一个测试接口
interface ITest {
void show();
}
//Export出去的类型和名称都要和Import标注的属性匹配,类型可以写ITest, 也可以写Test
[Export("wakaka",typeof(ITest))]
class Test : ITest
{
public void show()
{
Console.WriteLine("OK");
}
}
class Go
{
[Import("wakaka")]
public ITest test { get; set; }
}
}
I’m not good at website optimization, suggestion is
1. Inspect your site source to find the slow response elements;
2. Use some optimization plugins like Hyper Cache;
3. Consider the server system, runtime or network optimization;
Long time reader, first time commenter — so, thought I’d drop a comment..
— and at the same time ask for a favor.
Your wordpress site is very simplistic – hope you don’t mind me asking what
theme you’re using? (and don’t mind if I steal it?
:P)
I just launched my small businesses site –also built in wordpress like yours– but
the theme slows (!) the site down quite a bit.
In case you have a minute, you can find it by searching for “royal cbd” on Google (would appreciate any feedback)
Keep up the good work– and take care of yourself during the coronavirus scare!
~Justin
The theme use is “Specia” .
I’m not good at website optimization, suggestion is
1. Inspect your site source to find the slow response elements;
2. Use some optimization plugins like Hyper Cache;
3. Consider the server system, runtime or network optimization;