Пример #1
0
        /// <summary>
        /// Creates a cross-reference in the storage, which points to the stack of <see cref="AmbientDbContext"/>
        /// in the ConditionalWeakTable.
        /// </summary>
        private void Initialize()
        {
            var crossReferenceKey = _storage.GetValue <ContextualStorageItem>(AmbientDbContextStorageKey.Key);

            if (crossReferenceKey == null)
            {
                crossReferenceKey = new ContextualStorageItem(Guid.NewGuid().ToString("N"));

                _storage.SetValue(AmbientDbContextStorageKey.Key, crossReferenceKey);

                AmbientDbContextTable.Add(crossReferenceKey, ImmutableStack.Create <IAmbientDbContext>());
            }
        }
        /// <summary>
        /// Creates a cross-reference in the storage, which points to the stack of <see cref="AmbientDbContext"/>
        /// in the ConditionalWeakTable.
        /// </summary>
        private void Initialize()
        {
#if NET451
            var crossReferenceKey = _storage.GetValue <ContextualStorageItem>(AmbientDbContextStorageKey.Key);
#else
            var crossReferenceKey = _storage.GetValue <string>(AmbientDbContextStorageKey.Key);
#endif

            if (crossReferenceKey == null)
            {
#if NET451
                crossReferenceKey = new ContextualStorageItem(Guid.NewGuid().ToString("N"));
#else
                crossReferenceKey = Guid.NewGuid().ToString("N");
#endif
                _storage.SetValue(AmbientDbContextStorageKey.Key, crossReferenceKey);

#if NET451
                AmbientDbContextTable.Add(crossReferenceKey.Value, ImmutableStack.Create <IAmbientDbContext>());
#else
                AmbientDbContextTable.Add(crossReferenceKey, ImmutableStack.Create <IAmbientDbContext>());
#endif
            }
        }