public JsonDynamicContract(Type underlyingType) : base(underlyingType)
 {
     this._callSiteGetters = new ThreadSafeStore <string, CallSite <Func <CallSite, object, object> > >(new Func <string, CallSite <Func <CallSite, object, object> > >(JsonDynamicContract.CreateCallSiteGetter));
     this._callSiteSetters = new ThreadSafeStore <string, CallSite <Func <CallSite, object, object, object> > >(new Func <string, CallSite <Func <CallSite, object, object, object> > >(JsonDynamicContract.CreateCallSiteSetter));
     base.ContractType     = JsonContractType.Dynamic;
     this.Properties       = new JsonPropertyCollection(base.UnderlyingType);
 }
示例#2
0
        public JsonReflectionApi()
        {
            CreatorCache = XThreadSafe.ThreadSafeStore <Type, Func <object[], object> >(GetCreator);

#if !(NET20 || DOTNET)
            AssociatedMetadataTypesCache = XThreadSafe.ThreadSafeStore <Type, Type> (GetAssociateMetadataTypeFromAttribute);
#endif
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContractResolver"/> class.
        /// </summary>
        /// <param name="shareCache">
        /// If set to <c>true</c> the <see cref="DefaultContractResolver"/> will use a cached shared with other resolvers of the same type.
        /// Sharing the cache will significantly performance because expensive reflection will only happen once but could cause unexpected
        /// behavior if different instances of the resolver are suppose to produce different results. When set to false it is highly
        /// recommended to reuse <see cref="DefaultContractResolver"/> instances with the <see cref="JsonSerializer"/>.
        /// </param>
        public DefaultContractResolver(bool shareCache)
        {
            DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;
#if !(UNITY_IOS || UNITY_IPHONE)
            _sharedCache = shareCache;
#else
            _typeContractCache = new ThreadSafeStore <Type, JsonContract>(CreateContract);
#endif
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContractResolver"/> class.
        /// </summary>
        /// <param name="shareCache">
        /// If set to <c>true</c> the <see cref="DefaultContractResolver"/> will use a cached shared with other resolvers of the same type.
        /// Sharing the cache will significantly performance because expensive reflection will only happen once but could cause unexpected
        /// behavior if different instances of the resolver are suppose to produce different results. When set to false it is highly
        /// recommended to reuse <see cref="DefaultContractResolver"/> instances with the <see cref="JsonSerializer"/>.
        /// </param>
        public DefaultContractResolver(bool shareCache)
        {
            DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;
            _sharedCache = shareCache;

#if MONOTOUCH
            _typeContractCache = new ThreadSafeStore <Type, JsonContract>(CreateContract);
#endif
        }
示例#5
0
        public T GetAttribute <T>(object type) where T : Attribute
        {
            var tType = typeof(T);

            if (!dictionary.TryGetValue(tType.TypeHandle, out ThreadSafeStore <object, Attribute> threadSafeStore))
            {
                threadSafeStore = new ThreadSafeStore <object, Attribute>();
            }

            return((T)threadSafeStore.Get(type));
        }
示例#6
0
        public TValue Get <TKey, TValue>(ThreadSafeStore <TKey, TValue> store, TKey key)
        {
//#if HAVE_CONCURRENT_DICTIONARY
            return(store.InternalStore.GetOrAdd(key, store.Creator));
//#else
//            TValue value;
//            if (!store.InternalStore.TryGetValue(key, out value))
//            {
//                return AddValue(key);
//            }

//            return value;
//#endif
        }
示例#7
0
 static JsonTypeReflector()
 {
     JsonTypeReflector.JsonConverterCreatorCache    = new ThreadSafeStore <Type, Func <object[], JsonConverter> >(new Func <Type, Func <object[], JsonConverter> >(JsonTypeReflector.GetJsonConverterCreator));
     JsonTypeReflector.AssociatedMetadataTypesCache = new ThreadSafeStore <Type, Type>(new Func <Type, Type>(JsonTypeReflector.GetAssociateMetadataTypeFromAttribute));
 }
示例#8
0
文件: XThreadSafe.cs 项目: E01D/Base
 public static TValue Get <TKey, TValue>(ThreadSafeStore <TKey, TValue> store, TKey key)
 {
     return(XThreadSafe.Api.Get(store, key));
 }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContractResolver"/> class.
        /// </summary>
        public DefaultContractResolver()
        {
            DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;

            _typeContractCache = new ThreadSafeStore <Type, JsonContract>(CreateContract);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultSerializationBinder"/> class.
 /// </summary>
 public DefaultSerializationBinder()
 {
     _typeCache = new ThreadSafeStore<TypeNameKey, Type>(GetTypeFromTypeNameKey);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultContractResolver"/> class.
        /// </summary>
        public DefaultContractResolver()
        {
            DefaultMembersSearchFlags = BindingFlags.Public | BindingFlags.Instance;

              _typeContractCache = new ThreadSafeStore<Type, JsonContract>(CreateContract);
        }
 static GeometryServicesExtensions()
 {
     _store = new ThreadSafeStore<string, IGeometryFactory>( t => GeometryServiceProvider.Instance.CreateGeometryFactory(GetSrid(t)));
 }
 public DefaultSerializationBinder()
 {
     Class6.yDnXvgqzyB5jw();
     base();
     this._typeCache = new ThreadSafeStore <StructMultiKey <string, string>, Type>(new Func <StructMultiKey <string, string>, Type>(this.GetTypeFromTypeNameKey));
 }
示例#14
0
 static DiscriminatedUnionConverter()
 {
     Class6.yDnXvgqzyB5jw();
     DiscriminatedUnionConverter.UnionCache           = new ThreadSafeStore <Type, DiscriminatedUnionConverter.Union>(new Func <Type, DiscriminatedUnionConverter.Union>(DiscriminatedUnionConverter.CreateUnion));
     DiscriminatedUnionConverter.UnionTypeLookupCache = new ThreadSafeStore <Type, Type>(new Func <Type, Type>(DiscriminatedUnionConverter.CreateUnionTypeLookup));
 }
 static KeyValuePairConverter()
 {
     KeyValuePairConverter.ReflectionObjectPerType = new ThreadSafeStore <Type, ReflectionObject>(new Func <Type, ReflectionObject>(KeyValuePairConverter.InitializeReflectionObject));
 }
示例#16
0
 static KeyValuePairConverter()
 {
     Class6.yDnXvgqzyB5jw();
     KeyValuePairConverter.ReflectionObjectPerType = new ThreadSafeStore <Type, ReflectionObject>(new Func <Type, ReflectionObject>(KeyValuePairConverter.InitializeReflectionObject));
 }
 static GeometryServicesExtensions()
 {
     _store = new ThreadSafeStore <string, IGeometryFactory>(t => GeometryServiceProvider.Instance.CreateGeometryFactory(GetSrid(t)));
 }
示例#18
0
 public DefaultSerializationBinder()
 {
     this._typeCache =
         new ThreadSafeStore <TypeNameKey, Type>(new Func <TypeNameKey, Type>(this.GetTypeFromTypeNameKey));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultSerializationBinder"/> class.
 /// </summary>
 public DefaultSerializationBinder()
 {
     _typeCache = new ThreadSafeStore <TypeNameKey, Type>(GetTypeFromTypeNameKey);
 }
示例#20
0
 static JsonTypeReflector()
 {
     JsonTypeReflector.JsonConverterTypeCache       = new ThreadSafeStore <ICustomAttributeProvider, Type>(new Func <ICustomAttributeProvider, Type>(JsonTypeReflector.GetJsonConverterTypeFromAttribute));
     JsonTypeReflector.AssociatedMetadataTypesCache = new ThreadSafeStore <Type, Type>(new Func <Type, Type>(JsonTypeReflector.GetAssociateMetadataTypeFromAttribute));
 }
示例#21
0
 public EnumApi()
 {
     EnumMemberNamesPerType = XThreadSafe.ThreadSafeStore <Type, BidirectionalDictionary <string, string> >(InitializeEnumType);
 }
示例#22
0
 public DefaultContractResolver()
 {
     _contractCache = new ThreadSafeStore <Type, SshContract>(CreateContract);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultSerializationBinder"/> class.
 /// </summary>
 public DefaultSerializationBinder()
 {
     _typeCache = new ThreadSafeStore <StructMultiKey <string, string>, Type>(GetTypeFromTypeNameKey);
 }
示例#24
0
 static JsonTypeReflector()
 {
     Class6.yDnXvgqzyB5jw();
     JsonTypeReflector.CreatorCache = new ThreadSafeStore <Type, Func <object[], object> >(new Func <Type, Func <object[], object> >(JsonTypeReflector.GetCreator));
     JsonTypeReflector.AssociatedMetadataTypesCache = new ThreadSafeStore <Type, Type>(new Func <Type, Type>(JsonTypeReflector.GetAssociateMetadataTypeFromAttribute));
 }