Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlReaderTest"/> class.
        /// </summary>
        public SqlReaderTest()
        {
            // In unit tests the DataDirectory path used by connection strings is
            // null. We set the path here to ensure that connection strings
            // that use DataDirectory function as expected.
            AppDomain.CurrentDomain.SetData(
                "DataDirectory",
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data"));

            HttpContext.Current = new HttpContext(
                new HttpRequest(string.Empty, "http://tempuri.org", string.Empty),
                new HttpResponse(new StringWriter(CultureInfo.InvariantCulture)));

            this.model = Substitute.For <IMetadataCache>();
            this.model.Get(Arg.Any <string>()).Returns(x => null);

            // SQL Server does not have permissions on the executable folder in
            // AppVeyor to attach a LocalDB database. So we create a database in Full
            // SQL Server as we do have sa privileges.
            if (Environment.GetEnvironmentVariable("APPVEYOR") == "True")
            {
                this.CreateDatabase();
            }

            this.realDatabaseRecordId = this.CreateFileInDatabase();
        }
Ejemplo n.º 2
0
        private static BuildXL.Cache.MemoizationStore.Interfaces.Caches.ICache CreateDistributedCache(ILogger logger, Config cacheConfig)
        {
            int cacheKeyBumpTimeMins = cacheConfig.CacheKeyBumpTimeMins;

            if (cacheKeyBumpTimeMins <= 0)
            {
                logger.Debug("Config specified bump time in minutes is invalid {0}. Using default bump time {1}", cacheKeyBumpTimeMins, Config.DefaultCacheKeyBumpTimeMins);
                cacheKeyBumpTimeMins = Config.DefaultCacheKeyBumpTimeMins;
            }

            TimeSpan keyBump = TimeSpan.FromMinutes(cacheKeyBumpTimeMins);

            var metadataTracer = new DistributedCacheSessionTracer(logger, nameof(DistributedCache));

            string metadataKeyspace = cacheConfig.CacheNamespace;

            if (string.IsNullOrWhiteSpace(metadataKeyspace))
            {
                metadataKeyspace = DefaultMetadataKeyspace;
            }

            IMetadataCache metadataCache = RedisMetadataCacheFactory.Create(metadataTracer, keySpace: metadataKeyspace, cacheKeyBumpTime: keyBump);

            var innerCache = cacheConfig.DisableContent
                ?  new OneLevelCache(
                contentStoreFunc: () => new ReadOnlyEmptyContentStore(),
                memoizationStoreFunc: () => (BuildCacheCache)BuildCacheUtils.CreateBuildCacheCache(cacheConfig, logger, Environment.GetEnvironmentVariable("VSTSPERSONALACCESSTOKEN")),
                id: Guid.NewGuid(),
                passContentToMemoization: false)
                : BuildCacheUtils.CreateBuildCacheCache(cacheConfig, logger, Environment.GetEnvironmentVariable("VSTSPERSONALACCESSTOKEN"));

            ReadThroughMode readThroughMode = cacheConfig.SealUnbackedContentHashLists ? ReadThroughMode.ReadThrough : ReadThroughMode.None;

            return(new DistributedCache(logger, innerCache, metadataCache, metadataTracer, readThroughMode));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureReaderTest"/> class.
        /// </summary>
        public AzureReaderTest()
        {
            CloudStorageEmulatorShepherd.Start();
            this.CreateFileInDatabase();

            this.model = Substitute.For <IMetadataCache>();
            this.model.Get(Arg.Any <string>()).Returns(x => null);
        }
        public MachineKeyMetadataCache(IMetadataCache inner)
        {
            if (inner == null)
            {
                throw new ArgumentNullException("inner");
            }

            this.inner = inner;
        }
 private void SetCache(IMetadataCache cache)
 {
     if (protect)
     {
         this.cache = new MachineKeyMetadataCache(cache);
     }
     else
     {
         this.cache = cache;
     }
 }
 private void SetCache(IMetadataCache cache)
 {
     if (protect)
     {
         this.cache = new MachineKeyMetadataCache(cache);
     }
     else
     {
         this.cache = cache;
     }
 }
Ejemplo n.º 7
0
 public BusinessReflector(IMetadataCache metadata)
 {
     _metadata      = metadata;
     _typename2Type = new Dictionary <string, Type>()
     {
         { "int", typeof(int) },
         { "long", typeof(long) },
         { "byte", typeof(byte) },
         { "decimal", typeof(decimal) },
         { "bool", typeof(bool) }
     };
 }
Ejemplo n.º 8
0
 internal ObjectMetadataCache(IMetadataCache metadataCache, AdomdConnection connection, InternalObjectType objectType, string requestType, ListDictionary restrictions, string relationColumn)
 {
     this.msgDelegate    = new AdomdUtils.GetInvalidatedMessageDelegate(this.GetMessageForCacheExpiration);
     this.isInitialized  = false;
     this.cacheState     = MetadataCacheState.Empty;
     this.metadataCache  = metadataCache;
     this.connection     = connection;
     this.objectType     = objectType;
     this.requestType    = requestType;
     this.restrictions   = restrictions;
     this.relationColumn = relationColumn;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="S3ReaderTest"/> class.
        /// </summary>
        public S3ReaderTest()
        {
            HttpContext.Current = new HttpContext(
                new HttpRequest(string.Empty, "http://tempuri.org", string.Empty),
                new HttpResponse(new StringWriter(CultureInfo.InvariantCulture)));

            object cachedValue = null;

            this.model = Substitute.For <IMetadataCache>();
            this.model.Get(Arg.Any <string>()).Returns(x => cachedValue);
            this.model.When(x => x.Put(Arg.Any <string>(), Arg.Any <object>())).Do(x => cachedValue = x[1]);
        }
Ejemplo n.º 10
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="DistributedCache" /> class.
        /// </summary>
        public DistributedCache(ILogger logger, ICache innerICache, IMetadataCache metadataCache, DistributedCacheSessionTracer cacheTracer, ReadThroughMode readThroughMode)
        {
            Contract.Requires(logger != null);
            Contract.Requires(innerICache != null);
            Contract.Requires(metadataCache != null);

            _logger        = logger;
            _innerICache   = innerICache;
            _metadataCache = metadataCache;

            _tracer          = cacheTracer;
            _readThroughMode = readThroughMode;
        }
Ejemplo n.º 11
0
 public PropertyMetadata(IMetadataCache cache, string name, EntityMetadata owner, PropertyGeneralUsageCategoryStruct generalBehavior
                         , DataType dataType, bool isNullable, bool isExpression, string title, string expressionDefinitionIdentifier)
 {
     _cache         = cache;
     Name           = name;
     Title          = title;
     GeneralBahvior = generalBehavior;
     _dataTypeInfo  = dataType;
     DataType       = (DataTypes)dataType.Id;
     IsNullable     = isNullable;
     IsExpression   = isExpression;
     _expressionDefinitionIdentifier = expressionDefinitionIdentifier;
     owner.AddProperty(this);
     Owner = owner;
 }
Ejemplo n.º 12
0
        public async Task <CodeGenerationResult> GenerateCode(IMetadataCache cache, IInstanceInfo instanceInfo, string path, string instanceName)
        {
            var codeGen              = new EfCoreCodeGenerator();
            var compileUnit          = codeGen.CreateCode(cache, instanceInfo);
            var compositionDirectory = Path.Combine(path, instanceInfo.InstanceName);

            EnsurePath(compositionDirectory);
            var sourceCodeFilePath = Path.Combine(compositionDirectory, "source.cs");

            codeGen.GenerateSourceCode(compileUnit, sourceCodeFilePath);
            var assembliesPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);             //TODO: This is hardcoded
            var assemblyPath   = Path.Combine(compositionDirectory, instanceName + ".dll");

            return(await new EfCoreCompiler().GenerateAssemblyAsync(sourceCodeFilePath, assemblyPath, assembliesPath));
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="DistributedCacheSession" /> class.
        /// </summary>
        public DistributedCacheSession(
            ILogger logger,
            string name,
            ICacheSession innerCacheSession,
            Guid innerCacheId,
            IMetadataCache metadataCache,
            DistributedCacheSessionTracer tracer,
            ReadThroughMode readThroughModeMode)
            : base(logger, name, innerCacheSession, innerCacheId, metadataCache, tracer, readThroughModeMode)
        {
            Contract.Requires(logger != null);
            Contract.Requires(innerCacheSession != null);
            Contract.Requires(metadataCache != null);

            _innerCacheSession = innerCacheSession;
        }
        public CachingMetadataBasedIssuerNameRegistry(
            Uri metadataAddress, string issuerName,
            IMetadataCache cache, 
            int cacheDuration = DefaultCacheDuration, 
            bool protect = true,
            bool lazyLoad = false)
            : base(metadataAddress, issuerName, System.ServiceModel.Security.X509CertificateValidationMode.None, true)
        {
            if (cache == null) throw new ArgumentNullException("cache");

            this.protect = protect;
            SetCache(cache);
            this.cacheDuration = cacheDuration;

            if (!lazyLoad)
            {
                this.LoadMetadata();
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataService" /> class.
        /// </summary>
        /// <param name="loggerFactory">The logger factory,</param>
        /// <param name="serviceProvider">
        /// The <see cref="IServiceProvider" /> to instanciate <see cref="IMetadataProvider" /> s.
        /// </param>
        /// <param name="cache">The cache provider for the resolved metadata.</param>
        public MetadataService(ILoggerFactory loggerFactory = null, IServiceProvider serviceProvider = null, IMetadataCache cache = null)
        {
            _logger = loggerFactory?.CreateLogger <MetadataService>();
            _Cache  = cache;

            if (serviceProvider != null)
            {
                foreach (var s in serviceProvider.GetServices <IMetadataProvider>())
                {
                    if (s.IsEnabled)
                    {
                        Providers.Add(s);
                    }
                    else
                    {
                        _logger.LogWarning("Ignore disabled IMetadataProvider: {0}", s);
                    }
                }
            }
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ReadOnlyDistributedCacheSession" /> class.
        /// </summary>
        public ReadOnlyDistributedCacheSession(
            ILogger logger,
            string name,
            IReadOnlyCacheSession innerCacheSession,
            Guid innerCacheId,
            IMetadataCache metadataCache,
            DistributedCacheSessionTracer tracer,
            ReadThroughMode readThroughModeMode)
        {
            Contract.Requires(logger != null);
            Contract.Requires(innerCacheSession != null);
            Contract.Requires(metadataCache != null);

            Logger             = logger;
            Name               = name;
            MetadataCache      = metadataCache;
            _innerCacheSession = innerCacheSession;
            _innerCacheId      = innerCacheId;
            DistributedTracer  = tracer;
            _readThroughMode   = readThroughModeMode;
        }
        public CachingMetadataBasedIssuerNameRegistry(
            Uri metadataAddress, string issuerName,
            IMetadataCache cache,
            int cacheDuration = DefaultCacheDuration,
            bool protect      = true,
            bool lazyLoad     = false)
            : base(metadataAddress, issuerName, System.ServiceModel.Security.X509CertificateValidationMode.None, true)
        {
            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }

            this.protect = protect;
            SetCache(cache);
            this.cacheDuration = cacheDuration;

            if (!lazyLoad)
            {
                this.LoadMetadata();
            }
        }
Ejemplo n.º 18
0
 public PropertyMetadata(IMetadataCache cache, string name, EntityTypeMetadata owner, PropertyGeneralUsageCategoryStruct generalBehavior
                         , DataType dataType, bool isNullable, bool isExpression, string title, string expressionDefinitionIdentifier, IEnumerable <MetadataDbAccess.Entities.PropertyBehavior> behaviors)
 {
     _cache         = cache;
     Name           = name;
     Title          = title;
     GeneralBahvior = generalBehavior;
     _dataTypeInfo  = dataType;
     DataType       = (DataTypes)dataType.Id;
     IsNullable     = isNullable;
     IsExpression   = isExpression;
     _expressionDefinitionIdentifier = expressionDefinitionIdentifier;
     owner.AddProperty(this);
     Owner     = owner;
     Behaviors = behaviors?.Select(x => new PropertyBehaviorMetadata
     {
         AdditionalBehavior = new AdditionalBehaviorMetadata
         {
             Name       = x.AdditionalBehavior.Name,
             Definition = x.AdditionalBehavior.Definition
         },
         Parameters = x.Parameters
     }).ToList();
 }
Ejemplo n.º 19
0
 public RabbitMQConfigurator(IOptions <DaJetAgentOptions> options, IMetadataCache cache)
 {
     _metadataCache = cache;
     Options        = options.Value;
 }
 internal CubeDef(DataRow cubeRow, AdomdConnection connection, DateTime populationTime, string catalog, string sessionId)
 {
     this.baseData       = new BaseObjectData(connection, true, null, cubeRow, null, null, catalog, sessionId);
     this.populationTime = populationTime;
     this.metadataCache  = new CubeMetadataCache(connection, this);
 }
Ejemplo n.º 21
0
        public SearchResultCache(IMetadataCache metadataCache)
        {
            MetadataCache = metadataCache;

            items = new Dictionary <string, SearchResult>();
        }
Ejemplo n.º 22
0
        public MainForm()
        {
            InitializeComponent();
            ProcessCommandLine();

            staticHttpClient = new StaticHttpClient(Settings.Network);

            pathFormatter = new PathFormatter(Program.ApplicationPath, Program.SourcePath, Settings.PathFormatter.Custom, Settings.PathFormatter, Settings.Lists.Tags.LanguageNames, Settings.PathFormatter.IsEnabled);

            tagsModel         = new TagsModel();
            tokenModifiers    = TokenModifiers.All.Concat(new ITokenModifier[] { new TagTokenModifier(tagsModel) }).ToArray();
            bookmarkFormatter = new BookmarkFormatter(Settings.Lists.Bookmarks, Settings.Lists.Tags, tagsModel, pathFormatter, tokenModifiers);
            bookmarksModel    = new BookmarksModel(tagsModel, bookmarkFormatter);
            libraryModel      = new LibraryModel(pathFormatter.GetCacheDirectory(), new WinformsTimer(0, Settings.Polling.LibraryRefreshInterval));
            browsingModel     = new BrowsingModel();
            galleryModel      = new GalleryModel(tagsModel);
            detailsModel      = new DetailsModel();

            metadataKeywordLists = new MetadataKeywordLists();
            metadataProcessors   = new List <IMetadataProcessor>();
            metadataConverters   = new List <IMetadataConverter>();
            archiveWriters       = new List <IArchiveWriter>();
            queryParser          = new QueryParser(tagsModel);

            coreTextFormatter     = new CoreTextFormatter(pathFormatter, tokenModifiers);
            aboutTextFormatter    = new AboutTextFormatter(pathFormatter);
            tagTextFormatter      = new TagTextFormatter();
            metadataTextFormatter = new MetadataTextFormatter(pathFormatter, Settings.Lists.Tags.LanguageNames, metadataKeywordLists, tokenModifiers);

            documentTemplates                      = new DocumentTemplates();
            documentTemplates.About                = new DocumentTemplate <object>("about", Settings.Cache.Templates, pathFormatter, (x, context) => aboutTextFormatter.Format(x));
            documentTemplates.Details              = new DocumentTemplate <Metadata>("details", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.DetailsPreload       = new DocumentTemplate <Metadata>("details-preload", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.Download             = new DocumentTemplate <Metadata>("download", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.GalleryTooltip       = new DocumentTemplate <Metadata>("gallery-tooltip", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.LibraryCovergrid     = new DocumentTemplate <ISearchProgressArg>("library-covergrid", Settings.Cache.Templates, pathFormatter, (text, context) => searchProgressArgTextFormatter.Format(text, context, "library"));
            documentTemplates.LibraryCovergridItem = new DocumentTemplate <Metadata>("library-covergrid-item", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.SearchCovergrid      = new DocumentTemplate <ISearchProgressArg>("search-covergrid", Settings.Cache.Templates, pathFormatter, (text, context) => searchProgressArgTextFormatter.Format(text, context, "search"));
            documentTemplates.SearchCovergridItem  = new DocumentTemplate <Metadata>("search-covergrid-item", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.SearchPreload        = new DocumentTemplate <ISearchArg>("search-preload", Settings.Cache.Templates, pathFormatter, (text, context) => searchArgTextFormatter.Format(text, context));
            documentTemplates.Startup              = new DocumentTemplate <object>("startup", Settings.Cache.Templates, pathFormatter, (text, context) => coreTextFormatter.Format(text, context));

            searchArgTextFormatter         = new SearchArgTextFormatter(pathFormatter, metadataKeywordLists, tagsModel, tokenModifiers);
            searchProgressArgTextFormatter = new SearchProgressArgTextFormatter(pathFormatter, metadataKeywordLists, tagsModel, metadataTextFormatter, tokenModifiers, documentTemplates.SearchCovergridItem, documentTemplates.LibraryCovergridItem);

            metadataCache     = new MetadataCache();
            searchResultCache = new SearchResultCache(metadataCache);
            sessionManager    = new SessionManager(pathFormatter, searchResultCache, Settings.Cache.Session.RecentLifeSpan, Settings.Cache.Session.SearchLifeSpan, Settings.Cache.Session.TaggedLifeSpan, Settings.Network);
            cacheFileSystem   = new CacheFileSystem(pathFormatter, searchResultCache, archiveWriters);
            pluginSystem      = new PluginSystem(Logger, pathFormatter, cacheFileSystem, archiveWriters, metadataConverters, metadataProcessors);

            backgroundTaskWorker = new BackgroundTaskWorker()
            {
                IdleWaitTime = Settings.BackgroundWorkers.BackgroundTaskWorker.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.BackgroundTaskWorker.MaxConcurrentJobCount
            };
            pageDownloader = new PageDownloader(staticHttpClient.Client, pathFormatter, searchResultCache, cacheFileSystem)
            {
                IdleWaitTime = Settings.BackgroundWorkers.PageDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.PageDownloader.MaxConcurrentJobCount
            };
            coverDownloader = new CoverDownloader(staticHttpClient.Client, pathFormatter, metadataKeywordLists)
            {
                IdleWaitTime = Settings.BackgroundWorkers.CoverDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.CoverDownloader.MaxConcurrentJobCount
            };
            coverLoader = new CoverDownloader(staticHttpClient.Client, pathFormatter, metadataKeywordLists)
            {
                IdleWaitTime = Settings.BackgroundWorkers.CoverLoader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.CoverLoader.MaxConcurrentJobCount
            };
            galleryDownloader = new GalleryDownloader(staticHttpClient.Client, pathFormatter, searchResultCache)
            {
                IdleWaitTime = Settings.BackgroundWorkers.GalleryDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.GalleryDownloader.MaxConcurrentJobCount
            };

            detailsTabControl         = new TabControlEx();
            detailsTabPage            = new TabPage();
            downloadTabPage           = new TabPage();
            listsTabControl           = new TabControlEx();
            tagsTabPage               = new TabPage();
            bookmarksTabPage          = new TabPage();
            libraryTabPage            = new TabPage();
            browsingTabPage           = new TabPage();
            mainViewTabControl        = new TabControlEx();
            galleryBrowserViewTabPage = new TabPage();
            libraryBrowserViewTabPage = new TabPage();
            downloadsListViewTabPage  = new TabPage();
            webBrowserToolTip         = new WebBrowserTreeNodeToolTip(pathFormatter, documentTemplates.GalleryTooltip);
            loadTimer = new Timer(components);

            searchHandler = new SearchHandler(
                libraryModel
                , mainViewTabControl
                , libraryBrowserViewTabPage
                , galleryBrowserViewTabPage
                , Settings.Cache
                , searchResultCache
                , Logger
                , browsingModel
                , pathFormatter
                , staticHttpClient.Client
                , queryParser
                , galleryModel
                , detailsModel
                , galleryDownloader
                , sessionManager
                , Settings.Network);

            bookmarkPromptUtility = new BookmarkPromptUtility(bookmarksModel, Settings.Lists.Bookmarks);

            tagsFilter           = new TagsFilter(Settings.Lists.Tags, metadataKeywordLists);
            bookmarksFilter      = new BookmarksFilter(Settings.Lists.Bookmarks);
            libraryFilter        = new LibraryFilter(Settings.Lists.Library);
            browsingFilter       = new BrowsingFilter(Settings.Lists.Browsing);
            libraryBrowserFilter = new LibraryBrowserFilter(Settings.Library.Browser);
            galleryBrowserFilter = new GalleryBrowserFilter(Settings.Gallery.Browser);
            detailsBrowserFilter = new DetailsBrowserFilter(Settings.Details.Browser);

            tagsTreeView       = new TagsTreeView(tagsFilter, tagsModel, tagTextFormatter, Settings.Lists.Tags, metadataKeywordLists, searchHandler, bookmarkPromptUtility, staticHttpClient.Client);
            tagsToolStrip      = new TagsToolStrip(tagsFilter, tagsModel, Settings.Lists.Tags, metadataKeywordLists, Settings.Polling.FilterDelay);
            bookmarksTreeView  = new BookmarksTreeView(bookmarksFilter, bookmarksModel, Settings.Lists.Bookmarks, webBrowserToolTip, queryParser, cacheFileSystem, searchHandler);
            bookmarksToolStrip = new BookmarksToolStrip(bookmarksFilter, bookmarksModel, Settings.Lists.Bookmarks, Settings.Polling.FilterDelay);
            libraryTreeView    = new LibraryTreeView(libraryFilter, libraryModel, archiveWriters, webBrowserToolTip, searchHandler, cacheFileSystem);
            libraryToolStrip   = new LibraryToolStrip(libraryFilter, libraryModel, Settings.Lists.Library, Settings.Polling.FilterDelay);
            browsingTreeView   = new BrowsingTreeView(browsingFilter, browsingModel, Settings.Lists.Browsing, searchHandler, sessionManager, queryParser);
            browsingToolStrip  = new BrowsingToolStrip(browsingFilter, browsingModel, Settings.Lists.Browsing, Settings.Polling.FilterDelay);

            galleryBrowserView      = new GalleryBrowserView(galleryBrowserFilter, galleryModel, documentTemplates.SearchCovergrid, documentTemplates.SearchPreload, pathFormatter, Settings.Gallery.Browser, pageDownloader, coverDownloader, metadataKeywordLists, tagsModel, searchHandler);
            galleryToolStrip        = new GalleryBrowserToolStrip(galleryBrowserFilter, galleryModel, Settings.Gallery.Browser, searchHandler);
            libraryBrowserView      = new LibraryBrowserView(libraryBrowserFilter, libraryModel, documentTemplates.LibraryCovergrid, documentTemplates.SearchPreload, documentTemplates.LibraryCovergridItem, pathFormatter, pageDownloader, coverLoader, metadataKeywordLists, Settings.Library.Browser, searchResultCache);
            libraryBrowserToolStrip = new LibraryBrowserToolStrip(libraryBrowserFilter, libraryModel, Settings.Library.Browser, searchHandler);
            detailsToolStrip        = new DetailsBrowserToolStrip(detailsBrowserFilter, detailsModel, searchHandler);
            detailsBrowserView      = new DetailsBrowserView(detailsBrowserFilter, detailsModel, documentTemplates.Details, documentTemplates.Download, documentTemplates.DetailsPreload, galleryDownloader, pageDownloader, coverDownloader, metadataKeywordLists, Settings.Details.Browser, searchResultCache, cacheFileSystem);
            theme                  = new Theme();
            applicationLoader      = new ApplicationLoader();
            fullScreenRestoreState = new FullScreenRestoreState();
            mainMenuStrip          = new MainMenuStrip(Settings);
            startupSpecialHandler  = new StartupSpecialHandler(Settings.Gallery, tagsModel, metadataKeywordLists, searchHandler);
            taskbar                = new Taskbar(coverDownloader, galleryDownloader, pageDownloader, searchResultCache, cacheFileSystem);

            publicApi = new PublicApi(staticHttpClient.Client
                                      , pathFormatter
                                      , cacheFileSystem
                                      , searchResultCache
                                      , searchHandler
                                      , bookmarkPromptUtility
                                      , pluginSystem
                                      , libraryBrowserToolStrip
                                      , Settings.Library
                                      , galleryToolStrip
                                      , Settings.Gallery
                                      , Settings.Details
                                      , galleryDownloader
                                      , coverDownloader
                                      , pageDownloader
                                      , Settings.Notifications
                                      , metadataKeywordLists
                                      , Settings
                                      );

            splitContainer1 = new SplitContainerEx();
            splitContainer2 = new SplitContainerEx();
            splitContainer3 = new SplitContainerEx();

            splitContainer1.BeginInit();
            splitContainer1.Panel2.SuspendLayout();
            splitContainer1.SuspendLayout();

            splitContainer2.BeginInit();
            splitContainer2.Panel1.SuspendLayout();
            splitContainer2.SuspendLayout();

            splitContainer3.BeginInit();
            splitContainer3.SuspendLayout();

            SuspendLayout();

            //
            //
            //
            loadTimer.Interval = 100;
            loadTimer.Tick    += LoadTimer_Tick;

            //
            //
            //
            tagsTabPage.Name     = "tagsTabPage";
            tagsTabPage.TabIndex = 0;
            tagsTabPage.Tag      = "tags";
            tagsTabPage.Text     = "Tags";
            tagsTabPage.UseVisualStyleBackColor = true;

            bookmarksTabPage.Name     = "bookmarksTabPage";
            bookmarksTabPage.TabIndex = 1;
            bookmarksTabPage.Tag      = "bookmarks";
            bookmarksTabPage.Text     = "Bookmarks";
            bookmarksTabPage.UseVisualStyleBackColor = true;

            libraryTabPage.Name     = "libraryTabPage";
            libraryTabPage.TabIndex = 2;
            libraryTabPage.Tag      = "library";
            libraryTabPage.Text     = "Library";
            libraryTabPage.UseVisualStyleBackColor = true;

            browsingTabPage.Name     = "browsingTabPage";
            browsingTabPage.TabIndex = 4;
            browsingTabPage.Tag      = "browsing";
            browsingTabPage.Text     = "Browsing";
            browsingTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            listsTabControl.Dock          = DockStyle.Fill;
            listsTabControl.Name          = "treeViewTabControl";
            listsTabControl.SelectedIndex = -1;
            listsTabControl.TabIndex      = 2;
            listsTabControl.TabPages.Add(tagsTabPage);
            listsTabControl.TabPages.Add(bookmarksTabPage);
            listsTabControl.TabPages.Add(libraryTabPage);
            listsTabControl.TabPages.Add(browsingTabPage);
            listsTabControl.Selected += TreeViewTabControl_Selected;

            splitContainer3.Panel1.Controls.Add(listsTabControl);

            //
            //
            //
            tagsTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            tagsToolStrip.Dock         = DockStyle.Top;
            tagsToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            tagsToolStrip.AutoSize     = true;

            //
            //
            //
            tagsTabPage.Controls.Add(tagsTreeView);
            tagsTabPage.Controls.Add(tagsToolStrip);

            //
            //
            //
            bookmarksModel.ItemAdded   += BookmarksModel_ItemAdded;
            bookmarksModel.ItemChanged += BookmarksModel_ItemChanged;

            //
            //
            //
            bookmarksTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            bookmarksToolStrip.Dock         = DockStyle.Top;
            bookmarksToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            bookmarksToolStrip.AutoSize     = true;

            //
            //
            //
            bookmarksTabPage.Controls.Add(bookmarksTreeView);
            bookmarksTabPage.Controls.Add(bookmarksToolStrip);

            //
            //
            //
            libraryTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            libraryToolStrip.Dock         = DockStyle.Top;
            libraryToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            libraryToolStrip.AutoSize     = true;

            //
            //
            //
            libraryTabPage.Controls.Add(libraryTreeView);
            libraryTabPage.Controls.Add(libraryToolStrip);

            //
            //
            //
            browsingModel.ItemAdded   += BrowsingModel_ItemAdded;
            browsingModel.ItemChanged += BrowsingModel_ItemChanged;

            //
            //
            //
            browsingToolStrip.Dock         = DockStyle.Top;
            browsingToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            browsingToolStrip.AutoSize     = true;

            //
            //
            //
            browsingTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            browsingTabPage.Controls.Add(browsingTreeView);
            browsingTabPage.Controls.Add(browsingToolStrip);

            //
            //
            //
            galleryBrowserViewTabPage.Name     = "galleryBrowserViewTabPage";
            galleryBrowserViewTabPage.Padding  = Padding.Empty;
            galleryBrowserViewTabPage.TabIndex = 0;
            galleryBrowserViewTabPage.Text     = "Search";
            galleryBrowserViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            libraryBrowserViewTabPage.Name     = "libraryBrowserViewTabPage";
            libraryBrowserViewTabPage.TabIndex = 1;
            libraryBrowserViewTabPage.Text     = "Library";
            libraryBrowserViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            downloadsListViewTabPage.Name     = "downloadsListViewTabPage";
            downloadsListViewTabPage.TabIndex = 2;
            downloadsListViewTabPage.Text     = "Downloads";
            downloadsListViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            mainViewTabControl.Controls.Add(galleryBrowserViewTabPage);
            mainViewTabControl.Controls.Add(libraryBrowserViewTabPage);
            mainViewTabControl.Controls.Add(downloadsListViewTabPage);
            mainViewTabControl.Dock          = DockStyle.Fill;
            mainViewTabControl.Name          = "mainViewTabControl";
            mainViewTabControl.SelectedIndex = 0;
            mainViewTabControl.TabIndex      = 2;
            mainViewTabControl.Selected     += MainViewTabControl_Selected;

            splitContainer3.Panel2.Controls.Add(mainViewTabControl);
            splitContainer2.Panel2.Controls.Add(detailsTabControl);

            //
            // detailsTabControl
            //
            detailsTabControl.Controls.Add(detailsTabPage);
            detailsTabControl.Controls.Add(downloadTabPage);
            detailsTabControl.Dock          = DockStyle.Fill;
            detailsTabControl.Name          = "detailsTabControl";
            detailsTabControl.SelectedIndex = 0;
            detailsTabControl.TabIndex      = 2;

            //
            // detailsTabPage
            //
            detailsTabPage.Name     = "detailsTabPage";
            detailsTabPage.TabIndex = 0;
            detailsTabPage.Text     = "Details";
            detailsTabPage.UseVisualStyleBackColor = true;

            //
            // downloadTabPage
            //
            downloadTabPage.Name     = "downloadTabPage";
            downloadTabPage.TabIndex = 1;
            downloadTabPage.Text     = "Download";
            downloadTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            galleryBrowserView.Dock = DockStyle.Fill;
            galleryBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            galleryToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            galleryToolStrip.AutoSize     = true;
            galleryToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            galleryBrowserViewTabPage.Controls.Add(galleryBrowserView);
            galleryBrowserViewTabPage.Controls.Add(galleryToolStrip);

            //
            //
            //
            libraryBrowserView.Dock = DockStyle.Fill;
            libraryBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            libraryBrowserToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            libraryBrowserToolStrip.AutoSize     = true;
            libraryBrowserToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            libraryBrowserViewTabPage.Controls.Add(libraryBrowserView);
            libraryBrowserViewTabPage.Controls.Add(libraryBrowserToolStrip);

            //
            //
            //
            detailsToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            detailsToolStrip.AutoSize     = true;
            detailsToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            detailsBrowserView.Dock = DockStyle.Fill;
            detailsBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            detailsTabPage.Controls.Add(detailsBrowserView);
            detailsTabPage.Controls.Add(detailsToolStrip);

            //
            // splitContainer1
            //
            splitContainer1.Dock          = DockStyle.Fill;
            splitContainer1.FixedPanel    = FixedPanel.Panel1;
            splitContainer1.Margin        = new Padding(0);
            splitContainer1.Name          = "splitContainer1";
            splitContainer1.Orientation   = Orientation.Horizontal;
            splitContainer1.Panel1MinSize = 22;

            //
            // splitContainer1.Panel2
            //
            splitContainer1.Panel2.Controls.Add(splitContainer2);
            splitContainer1.Size              = new Size(1364, 637);
            splitContainer1.SplitterDistance  = 25;
            splitContainer1.SplitterIncrement = 22;
            splitContainer1.SplitterWidth     = 7;
            splitContainer1.TabIndex          = 2;

            //
            // splitContainer2
            //
            splitContainer2.Dock       = DockStyle.Fill;
            splitContainer2.FixedPanel = FixedPanel.Panel2;
            splitContainer2.Margin     = new Padding(0);
            splitContainer2.Name       = "splitContainer2";

            //
            // splitContainer2.Panel1
            //
            splitContainer2.Panel1.Controls.Add(splitContainer3);
            splitContainer2.Size             = new Size(1364, 605);
            splitContainer2.SplitterDistance = 1214;
            splitContainer2.SplitterWidth    = 7;
            splitContainer2.TabIndex         = 1;

            //
            // splitContainer3
            //
            splitContainer3.Dock             = DockStyle.Fill;
            splitContainer3.FixedPanel       = FixedPanel.Panel1;
            splitContainer3.Margin           = new Padding(0);
            splitContainer3.Name             = "splitContainer3";
            splitContainer3.Size             = new Size(1214, 605);
            splitContainer3.SplitterDistance = 200;
            splitContainer3.SplitterWidth    = 7;
            splitContainer3.TabIndex         = 0;

            //
            // applicationMenuStrip
            //
            mainMenuStrip.Exit               += MainMenuStrip_Exit;
            mainMenuStrip.ToggleListsPanel   += MainMenuStrip_ToggleListsPanel;
            mainMenuStrip.ToggleDetailsPanel += MainMenuStrip_ToggleDetailsPanel;
            mainMenuStrip.ToggleFullScreen   += MainMenuStrip_ToggleFullScreen;
            mainMenuStrip.ShowAbout          += MainMenuStrip_ShowAbout;
            mainMenuStrip.ShowPlugins        += MainMenuStrip_ShowPlugins;

            //
            // this
            //
            Controls.Add(splitContainer1);
            Controls.Add(mainMenuStrip);
            Controls.Add(webBrowserToolTip);
            webBrowserToolTip.BringToFront();
            MainMenuStrip = mainMenuStrip;
            Padding       = new Padding(0);
            Text          = aboutTextFormatter.Format(Settings.Window.TextFormat);
            if (Settings.Network.Offline)
            {
                Text += " [OFFLINE]";
            }
            Enabled = false;

            //
            // splash screen
            //
            if (Settings.SplashScreen.IsVisible)
            {
                startupWebBrowser      = new StartupWebBrowserView(coreTextFormatter, documentTemplates.Startup, applicationLoader);
                startupWebBrowser.Name = "startupWebBrowserView";
                startupWebBrowser.Dock = DockStyle.Fill;
                startupWebBrowser.WebBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;

                Controls.Add(startupWebBrowser);
                startupWebBrowser.BringToFront();

                // avoid flickering
                listsTabControl.Visible    = false;
                mainViewTabControl.Visible = false;
                detailsTabControl.Visible  = false;
            }

            backgroundTaskWorker.ProgressChanged += TaskBackgroundWorker_ProgressChanged;

            pageDownloader.PagesDownloadCompleted += PageDownloader_PagesDownloadCompleted;

            ReadTheme();
            ApplyTheme();
            ApplyVisualStyles();

            splitContainer1.Panel2.ResumeLayout(false);
            splitContainer1.EndInit();
            splitContainer1.ResumeLayout(false);

            splitContainer2.Panel1.ResumeLayout(false);
            splitContainer2.EndInit();
            splitContainer2.ResumeLayout(false);

            splitContainer3.EndInit();
            splitContainer3.ResumeLayout(false);

            ResumeLayout(false);
            PerformLayout();
        }
 internal CacheBasedCollection(AdomdConnection connection, InternalObjectType objectType, IMetadataCache metadataCache) : this(connection, metadataCache.GetObjectCache(objectType))
 {
 }
        public MachineKeyMetadataCache(IMetadataCache inner)
        {
            if (inner == null) throw new ArgumentNullException("inner");

            this.inner = inner;
        }
Ejemplo n.º 25
0
        public CodeDomBusinessCode CreateCode(IMetadataCache cache, IInstanceInfo instanceInfo)
        {
            var compileUnit   = new CodeCompileUnit();
            var codeNamespace = new CodeNamespace(instanceInfo.GetNamespace());

            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(IDisposable).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(DbContext).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(IBusinessRepositoryFactory).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(KeyAttribute).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(NotMappedAttribute).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(TableAttribute).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(ForeignKeyAttribute).Namespace));
            codeNamespace.Imports.Add(new CodeNamespaceImport(typeof(JsonIgnoreAttribute).Namespace));

            var codeDbContext = CreateDbContextCode(instanceInfo);

            codeNamespace.Types.Add(codeDbContext);
            foreach (var type in cache)
            {
                var primaryKey = type.GetPrimaryKey();
                var codeType   = new CodeTypeDeclaration(type.Name)
                {
                    IsPartial = true
                };
                if (primaryKey == null)
                {
                    codeType.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(NotMappedAttribute))));
                }
                else
                {
                    AddTypeToDbContext(type, codeDbContext);
                }
                if (!string.IsNullOrWhiteSpace(type.SchemaName) || !string.IsNullOrWhiteSpace(type.TableName))
                {
                    if (string.IsNullOrWhiteSpace(type.SchemaName))
                    {
                        codeType.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(TableAttribute)),
                                                                                   new CodeAttributeArgument(new CodePrimitiveExpression(type.TableName ?? type.Name.Pluralize()))));
                    }
                    else
                    {
                        codeType.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(TableAttribute)),
                                                                                   new CodeAttributeArgument(new CodePrimitiveExpression(type.TableName ?? type.Name.Pluralize())),
                                                                                   new CodeAttributeArgument("Schema", new CodePrimitiveExpression(type.SchemaName ?? "dbo"))
                                                                                   ));
                    }
                }
                foreach (var property in type.GetDirectProperties().OrderBy(x => x.Name))
                {
                    if (property.IsExpression)
                    {
                        continue;
                    }
                    var snippet = new CodeSnippetTypeMember();

                    string dataType;
                    if (property.DataType == DataTypes.NavigationEntity || property.DataType == DataTypes.NavigationList)
                    {
                        snippet.Text += "		[JsonIgnore]"+ Environment.NewLine;
                    }
                    if (property.DataType == DataTypes.Date)
                    {
                        snippet.Text += "		[Column(TypeName=\"date\")]"+ Environment.NewLine;
                    }
                    if (property.DataType == DataTypes.NavigationList)
                    {
                        dataType = $"System.Collections.Generic.ICollection<{property.EntityTypeName}>";
                    }
                    else if (property.DataType == DataTypes.ForeignKey)
                    {
                        var propertyType = cache[property.EntityTypeName];
                        dataType = propertyType.GetPrimaryKey().GetDataType().ClrType;
                    }
                    else
                    {
                        dataType = property.EntityTypeName ?? property.GetDataType().ClrType;
                    }
                    if (property.IsNullable && property.GetDataType().IsValueType)
                    {
                        dataType += "?";
                    }
                    if (property.InverseProperty != null)
                    {
                        snippet.Text += $"		[InverseProperty(\"{property.InverseProperty.Name}\")]\n";
                    }
                    if (property.ForeignKey != null)
                    {
                        snippet.Text += $"		[ForeignKey(\"{property.ForeignKey.Name}\")]\n";
                    }
                    if (property == primaryKey)
                    {
                        snippet.Text += "		[Key]\n";
                    }
                    snippet.Text += $"		public virtual {dataType} {property.Name} {{ get; set; }}";
                    codeType.Members.Add(snippet);
                }
                codeNamespace.Types.Add(codeType);
            }
            var factoryCode = new CodeTypeDeclaration("DbContextFactory")
            {
                IsPartial = true
            };

            factoryCode.BaseTypes.Add($"IBusinessRepositoryFactory");
            factoryCode.Members.Add(new CodeSnippetTypeMember($"		public virtual IDisposable GetDbContext(DbContextOptions options){{ return new {instanceInfo.GetDbContextName()}(options as DbContextOptions<{instanceInfo.GetDbContextName()}>); }}"));
            factoryCode.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(ExportAttribute)),
                                                                          new CodeAttributeArgument(new CodeSnippetExpression("typeof(IBusinessRepositoryFactory)"))));
            codeNamespace.Types.Add(factoryCode);
            compileUnit.Namespaces.Add(codeNamespace);
            return(new CodeDomBusinessCode {
                Code = compileUnit
            });
        }
Ejemplo n.º 26
0
 internal ObjectMetadataCache(IMetadataCache metadataCache, AdomdConnection connection, SchemaRowsetCacheData rowsetData, ListDictionary restrictions) : this(metadataCache, connection, (rowsetData == null) ? InternalObjectType.InternalTypeMemberProperty : rowsetData.ObjectType, (rowsetData == null) ? null : rowsetData.RequestType, restrictions, (rowsetData == null) ? null : rowsetData.RelationColumnName)
 {
 }
        void LoadCustomConfiguration(XmlNodeList nodeList)
        {
            if (nodeList == null || nodeList.Count == 0)
            {
                throw new ConfigurationErrorsException("No configuration provided.");
            }

            var node = nodeList.Cast <XmlNode>().FirstOrDefault(x => x.LocalName == "metadataCache");

            if (node == null)
            {
                throw new ConfigurationErrorsException("Expected 'metadataCache' element.");
            }

            var elem = node as XmlElement;

            var protect = elem.Attributes["protect"];

            if (protect != null)
            {
                if (protect.Value != "true" && protect.Value != "false")
                {
                    throw new ConfigurationErrorsException("Expected 'protect' to be 'true' or 'false'.");
                }
                this.protect = protect.Value == "true";
            }

            var cacheType = elem.Attributes["cacheType"];

            if (cacheType == null || String.IsNullOrWhiteSpace(cacheType.Value))
            {
                throw new ConfigurationErrorsException("Expected 'cacheType' attribute.");
            }

            var cacheDuration = elem.Attributes["cacheDuration"];

            if (cacheDuration == null || String.IsNullOrWhiteSpace(cacheDuration.Value))
            {
                this.cacheDuration = DefaultCacheDuration;
            }
            else
            {
                if (!Int32.TryParse(cacheDuration.Value, out this.cacheDuration))
                {
                    throw new ConfigurationErrorsException("Attribute 'cacheType' not a valid Int32.");
                }
            }

            var            type          = Type.GetType(cacheType.Value);
            var            xmlCtor       = type.GetConstructor(new Type[] { typeof(XmlNodeList) });
            IMetadataCache cacheInstance = null;

            if (xmlCtor != null)
            {
                cacheInstance = (IMetadataCache)Activator.CreateInstance(type, elem.ChildNodes);
            }
            else
            {
                cacheInstance = (IMetadataCache)Activator.CreateInstance(type);
            }
            SetCache(cacheInstance);
        }
Ejemplo n.º 28
0
 public MessageConsumerService(IOptions <MessageConsumerSettings> options, IMetadataCache cache)
 {
     _metadataCache = cache;
     Settings       = options.Value;
 }
Ejemplo n.º 29
0
 internal CacheBasedNotFilteredCollection(AdomdConnection connection, InternalObjectType objectType, IMetadataCache metadataCache) : base(connection, objectType, metadataCache)
 {
 }
Ejemplo n.º 30
0
 public MetadataCacheService(IMetadataCache cache)
 {
     _cache = cache;
 }