コード例 #1
0
ファイル: Program.cs プロジェクト: SpectrumLi/TSVDExamples
        static void Main(string[] args)
        {
            int    x  = 10;
            double y  = 0;
            float  z  = 0;
            long   xx = 0;
            char   yy = '1';


            Dictionary <int, Type> d = new Dictionary <int, Type>();

            d[1] = x.GetType();
            d[2] = y.GetType();
            d[3] = z.GetType();
            d[4] = xx.GetType();
            d[5] = yy.GetType();

            Parallel.ForEach(d.Keys, (i) =>
            {
                try
                {
                    TypeCacher.GetPropertiesAndFields(d[i]);
                    TypeCacher.GetPropertiesAndFields(d[i]);
                }
                catch (Exception)
                {
                }
            });
        }
コード例 #2
0
        public void SameTags_ActivatesObjects_OfSameType()
        {
            Type TypeResolver() => typeof(SameTags_ActivatesObjects_OfSameType_TestData);

            var tc1 = new TypeCacher <SameTags_ActivatesObjects_OfSameType_TestData>();
            var tc2 = new TypeCacher <SameTags_ActivatesObjects_OfSameType_TestData>();
            var o1  = tc1.Activate(TypeResolver);
            var o2  = tc2.Activate(TypeResolver);

            Assert.Equal(o1.GetType(), o2.GetType());
        }
コード例 #3
0
        public void DifferentTags_ActivatesDifferentObjects()
        {
            Type TypeResolver1() => typeof(DifferentTags_ActivatesDifferentObjects_TestData1);
            Type TypeResolver2() => typeof(DifferentTags_ActivatesDifferentObjects_TestData2);

            var tc1 = new TypeCacher <DifferentTags_ActivatesDifferentObjects_TestData1>();
            var tc2 = new TypeCacher <DifferentTags_ActivatesDifferentObjects_TestData2>();
            var o1  = tc1.Activate(TypeResolver1);
            var o2  = tc2.Activate(TypeResolver2);

            Assert.NotEqual(o1.GetType(), o2.GetType());
        }
コード例 #4
0
        public void SameTags_InvokesResover_Once()
        {
            int invoked = 0;

            Type TypeResolver()
            {
                invoked++; return(typeof(SameTags_InvokesResover_Once_TestData));
            }

            var tc1 = new TypeCacher <SameTags_InvokesResover_Once_TestData>();
            var tc2 = new TypeCacher <SameTags_InvokesResover_Once_TestData>();
            var o1  = tc1.Activate(TypeResolver);
            var o2  = tc2.Activate(TypeResolver);

            Assert.Equal(1, invoked);
        }