private static GetSet[][] GetAccessors(RuntimeTypeHandle type)
        {
            lock (PropertyAccess)
            {
                var index = (SilverlightSerializer.IsChecksum ? 1 : 0) + (SilverlightSerializer.IsChecksum && SilverlightSerializer.IgnoreIds ? 1 : 0);
                
                GetSet[][][] collection;
                if (!PropertyAccess.TryGetValue(type, out collection))
                {
                    collection = new GetSet[3][][];
                    PropertyAccess[type] = collection;
                }
                var accessors = collection[index];
                if (accessors == null)
                {
                    var vanilla = GetVanilla(type);

                    var acs = new List<GetSet>();
                    var props = SilverlightSerializer.GetPropertyInfo(type);
                    foreach (var p in props)
                    {
                        var gs = typeof (GetSetGeneric<,>);
                        var tp = gs.MakeGenericType(new Type[] { Type.GetTypeFromHandle(type), p.PropertyType });
                        var getSet = (GetSet) Activator.CreateInstance(tp, new object[] {p});
                        getSet.Vanilla = getSet.Get(vanilla);
                        acs.Add(getSet);
                    }
                    accessors = new GetSet[2][];
                    accessors[0] = acs.ToArray();
                    acs.Clear();
                    var fields = SilverlightSerializer.GetFieldInfo(type);
                    foreach (var f in fields)
                    {
                        var gs = typeof (GetSetGeneric<,>);
                        var tp = gs.MakeGenericType(new Type[] { Type.GetTypeFromHandle(type), f.FieldType });
                        var getSet = (GetSet) Activator.CreateInstance(tp, new object[] {f});
                        getSet.Vanilla = getSet.Get(vanilla);
                        acs.Add(getSet);
                    }
                    accessors[1] = acs.ToArray();

                    collection[index] = accessors;
                }
                return accessors;
            }
        }
예제 #2
0
        private static GetSet[][] GetAccessors(RuntimeTypeHandle type)
        {
            lock (PropertyAccess)
            {
                var index = (SilverlightSerializer.IsChecksum ? 1 : 0) + (SilverlightSerializer.IsChecksum && SilverlightSerializer.IgnoreIds ? 1 : 0);

                GetSet[][][] collection;
                if (!PropertyAccess.TryGetValue(type, out collection))
                {
                    collection           = new GetSet[3][][];
                    PropertyAccess[type] = collection;
                }
                var accessors = collection[index];
                if (accessors == null)
                {
                    var vanilla = GetVanilla(type);

                    var acs   = new List <GetSet>();
                    var props = SilverlightSerializer.GetPropertyInfo(type);
                    foreach (var p in props)
                    {
                        var gs     = typeof(GetSetGeneric <,>);
                        var tp     = gs.MakeGenericType(new Type[] { Type.GetTypeFromHandle(type), p.PropertyType });
                        var getSet = (GetSet)Activator.CreateInstance(tp, new object[] { p });
                        getSet.Vanilla = getSet.Get(vanilla);
                        acs.Add(getSet);
                    }
                    accessors    = new GetSet[2][];
                    accessors[0] = acs.ToArray();
                    acs.Clear();
                    var fields = SilverlightSerializer.GetFieldInfo(type);
                    foreach (var f in fields)
                    {
                        var gs     = typeof(GetSetGeneric <,>);
                        var tp     = gs.MakeGenericType(new Type[] { Type.GetTypeFromHandle(type), f.FieldType });
                        var getSet = (GetSet)Activator.CreateInstance(tp, new object[] { f });
                        getSet.Vanilla = getSet.Get(vanilla);
                        acs.Add(getSet);
                    }
                    accessors[1] = acs.ToArray();

                    collection[index] = accessors;
                }
                return(accessors);
            }
        }