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); }
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 }
/// <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 }
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)); }
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 }
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)); }
public static TValue Get <TKey, TValue>(ThreadSafeStore <TKey, TValue> store, TKey key) { return(XThreadSafe.Api.Get(store, key)); }
/// <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)); }
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)); }
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))); }
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); }
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)); }
public EnumApi() { EnumMemberNamesPerType = XThreadSafe.ThreadSafeStore <Type, BidirectionalDictionary <string, string> >(InitializeEnumType); }
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); }
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)); }