2

すべてのキャッシュの NCache Manager では、ジェネリックの場合、コンパクト タイプを個別に定義する必要があります。キャッシュ コンパクトに一度にすべてのクラスを提供する方法はありますか

4

1 に答える 1

4

Runtime.dll class GenericTypeProvider1 : IGenericTypeProvider { #region IGenericTypeProvider メンバーから Ncache IGenericTypeProvider インターフェイスを実装する必要があります。

    public Type[] GetGenericTypes()
    {
        ArrayList aryList = new ArrayList();

        #region Classes that hold generic types inside or inherited from the generic types...
        aryList.Add(new PrimitiveTypes());
        aryList.Add(new ComplexTypes());
        aryList.Add(new UnsignedTypes());
        aryList.Add(new GenericHolder());
        aryList.Add(new GenericChild()); 
        #endregion

        #region Custom Generic objects that take only one type arguemt ...
        aryList.Add(new GenericClass<string>());
        aryList.Add(new GenericClass<bool>());
        aryList.Add(new GenericClass<double>());
        aryList.Add(new GenericClass<byte[]>());
        aryList.Add(new GenericClass<DateTime>());
        aryList.Add(new GenericClass<TimeSpan>());
        aryList.Add(new GenericClass<Guid>());
        aryList.Add(new GenericClass<Product>());
        aryList.Add(new GenericClass<AllTypes>());
        aryList.Add(new GenericClass<NullableObject>());
        aryList.Add(new GenericClass<List<AllTypes>>());
        aryList.Add(new GenericClass<List<AllDataTypes>>());
        aryList.Add(new GenericClass<List<NullableObject>>());
        aryList.Add(new GenericClass<Dictionary<string, NullableObject>>());
        aryList.Add(new GenericClass<List<GenericList<NullableObject>>>());
        aryList.Add(new GenericClass<List<Dictionary<string, NullableObject>>>()); 
        #endregion

        //--- Populate the type array with the types of the above given objects ...
        Type[] types = new Type[aryList.Count];
        for (int i = 0; i < types.Length; i++)
            types[i] = aryList[i].GetType();


        return types;
    }
于 2013-10-11T12:42:43.237 に答える