/// <summary> /// Initialises a new instance of <see cref="ComposablePartCatalog"/>. /// </summary> /// <param name="catalog">The inner catalog.</param> internal GlimpseCatalog(ComposablePartCatalog catalog) { if (catalog == null) throw new ArgumentNullException("catalog"); _catalog = catalog; }
public ModuleCatalog(ComposablePartCatalog inner_catalog) { _inner_catalog = inner_catalog; RefreshModules(); RefreshParts(); }
public MEFedMVVMCatalog(ComposablePartCatalog inner, bool designTime) { _inner = inner; if (designTime) _partsQuery = inner.Parts.Where(p => p.ExportDefinitions.Any(ed => !ed.Metadata.ContainsKey("IsDesignTimeService") || ed.Metadata.ContainsKey("IsDesignTimeService") && (ed.Metadata["IsDesignTimeService"].Equals(ServiceType.DesignTime) || ed.Metadata["IsDesignTimeService"].Equals(ServiceType.Both)))); else _partsQuery = inner.Parts.Where(p => p.ExportDefinitions.Any(ed => !ed.Metadata.ContainsKey("IsDesignTimeService") || ed.Metadata.ContainsKey("IsDesignTimeService") && (ed.Metadata["IsDesignTimeService"].Equals(ServiceType.Runtime) || ed.Metadata["IsDesignTimeService"].Equals(ServiceType.Both)))); }
/// <summary> /// Registers a MEF catalog within an Autofac container. /// </summary> /// <param name = "container">Autofac container instance.</param> /// <param name = "catalog">MEF catalog to be registered.</param> public static void RegisterCatalog(this IComponentContext container, ComposablePartCatalog catalog) { lock (container) { var compositionIntegration = EnableCompositionIntegration(container); compositionIntegration.Catalogs.Add(catalog); } }
private Application(ComposablePartCatalog catalog) { _commandQueue = new CommandQueue(_exitEvent); InitializePlugins(catalog); StartCommandProcessor(); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="parent"></param> /// <param name="filter"></param> public FilteredCatalog(ComposablePartCatalog parent, Expression<Func<ComposablePartDefinition, bool>> filter) { Contract.Requires<ArgumentNullException>(parent != null); Contract.Requires<ArgumentNullException>(filter != null); this.parent = parent; this.filter = filter; this.parts = new Lazy<IEnumerable<ComposablePartDefinition>>(() => parent.Parts.Where(filter).ToList()); }
public SauceCatalog(ComposablePartCatalog cat) { if (cat == null) { throw new ArgumentNullException("cat"); } this.catalog = cat; }
public EmbeddableDocumentStore NewDocumentStore( bool runInMemory = true, string requestedStorage = null, ComposablePartCatalog catalog = null, bool deleteDirectory = true, bool deleteDirectoryOnDispose = true) { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(RavenTestBase)).CodeBase); path = Path.Combine(path, DataDir).Substring(6); var storageType = GetDefaultStorageType(requestedStorage); var documentStore = new EmbeddableDocumentStore { Configuration = { DefaultStorageTypeName = storageType, DataDirectory = path, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory, Port = 8079 } }; if (catalog != null) documentStore.Configuration.Catalog.Catalogs.Add(catalog); try { ModifyStore(documentStore); ModifyConfiguration(documentStore.Configuration); if (deleteDirectory) IOExtensions.DeleteDirectory(path); documentStore.Initialize(); CreateDefaultIndexes(documentStore); if (deleteDirectoryOnDispose) documentStore.Disposed += ClearDatabaseDirectory; return documentStore; } catch { // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests. documentStore.Dispose(); throw; } finally { stores.Add(documentStore); } }
public EmbeddableDocumentStore NewDocumentStore( bool runInMemory = true, string requestedStorage = null, ComposablePartCatalog catalog = null, string dataDir = null, bool enableAuthentication = false) { var storageType = GetDefaultStorageType(requestedStorage); var documentStore = new EmbeddableDocumentStore { Configuration = { DefaultStorageTypeName = storageType, DataDirectory = dataDir ?? NewDataPath(), RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory, Port = 8079 } }; if (catalog != null) documentStore.Configuration.Catalog.Catalogs.Add(catalog); try { ModifyStore(documentStore); ModifyConfiguration(documentStore.Configuration); documentStore.Initialize(); if (enableAuthentication) { EnableAuthentication(documentStore.DocumentDatabase); ModifyConfiguration(documentStore.Configuration); } CreateDefaultIndexes(documentStore); return documentStore; } catch { // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests. documentStore.Dispose(); throw; } finally { stores.Add(documentStore); } }
private IQueryable<ComposablePartDefinition> FilterCatalog() { var trueSet = new List<ComposablePartDefinition>(); var falseSet = new List<ComposablePartDefinition>(); foreach(var part in _source.Parts) { if (_filter(part)) trueSet.Add(part); else falseSet.Add(part); } _complement = new BasicCatalog(falseSet.AsQueryable()); return trueSet.AsQueryable(); }
public WebScopedCatalog(ComposablePartCatalog partCatalog) { if (partCatalog == null) throw new ArgumentNullException("partCatalog"); var webScopedParts = from part in partCatalog.Parts let exportDef = part.ExportDefinitions.First() where exportDef.Metadata.ContainsKey("WebCreationPolicy") select part; var nonScopedParts = partCatalog.Parts.Except(webScopedParts); _parts = webScopedParts.Select(p => new WebScopedComposablePartDefinition(p)) .Union(nonScopedParts) .AsQueryable(); }
/// <summary> /// Creates a new Embeddable document store. /// </summary> /// <param name="runInMemory">Whatever the database should run purely in memory. When running in memory, nothing is written to disk and if the server is restarted all data will be lost.<br/>Default: <b>true</b></param> /// <param name="requestedStorage">What storage type to use (see: RavenDB Storage engines).<br/>Allowed values: <b>vornon</b>, <b>esent</b>.<br/>Default: <b>voron</b></param> /// <param name="catalog">Custom bundles that are not provided by RavenDb.</param> /// <param name="dataDir">The path for the database directory. Can use ~\ as the root, in which case the path will start from the server base directory. <br/>Default: <b>~\Databases\System</b></param> /// <param name="enableAuthentication"></param> /// <param name="activeBundles">Semicolon separated list of bundles names, such as: 'Replication;Versioning'.<br/>Default: no bundles turned on.</param> /// <param name="port">The port to use when creating the http listener. Allowed: 1 - 65,536 or * (find first available port from 8079 and upward).<br/>Default: <b>8079</b></param> /// <param name="anonymousUserAccessMode">Determines what actions an anonymous user can do. Get - read only, All - read & write, None - allows access to only authenticated users, Admin - all (including administrative actions).<br/>Default: <b>Get</b></param> /// <param name="configureStore">An action delegate which allows you to configure the document store instance that is returned. eg. <code>configureStore: store => store.DefaultDatabase = "MasterDb"</code></param> /// <param name="databaseName">Name of the server that will show up on /admin/stats endpoint.</param> /// <param name="indexes">A collection of indexes to execute.</param> /// <param name="transformers">A collection of transformers to execute.</param> /// <param name="seedData">A collection of some fake data that will be automatically stored into the document store.</param> /// <param name="noStaleQueries">When you query an index, the query will wait for the index to complete it's indexing and not be stale -before- the query is executed.</param> /// <param name="conventions">The conventions to be used when creating a new embeddable document store</param> /// <remarks>Besides the document store being instantiated, it is also Initialized.<br/>Also, if you provide some indexes to be used, make sure you understand that they might be stale when you query them. To make sure you're querying against indexes that have completed their indexing (ie. index is not stale), use the <code>noStaleQueries</code> parameter to determine if you wish to query against a stale or not-stale query.</remarks> /// <returns>A new instance of an EmbeddableDocumentStore.</returns> public EmbeddableDocumentStore NewDocumentStore( bool runInMemory = true, string requestedStorage = null, ComposablePartCatalog catalog = null, string dataDir = null, bool enableAuthentication = false, string activeBundles = null, int? port = null, AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin, Action<EmbeddableDocumentStore> configureStore = null, [CallerMemberName] string databaseName = null, IEnumerable<AbstractIndexCreationTask> indexes = null, IEnumerable<AbstractTransformerCreationTask> transformers = null, IEnumerable<IEnumerable> seedData = null, bool noStaleQueries = false, DocumentConvention conventions = null) { databaseName = NormalizeDatabaseName(databaseName); var storageType = GetDefaultStorageType(requestedStorage); var dataDirectory = dataDir ?? NewDataPath(databaseName); var documentStore = new EmbeddableDocumentStore { UseEmbeddedHttpServer = port.HasValue, Conventions = conventions ?? new DocumentConvention() }; ConfigurationHelper.ApplySettingsToConfiguration(documentStore.Configuration); documentStore.Configuration.DefaultStorageTypeName = storageType; documentStore.Configuration.DataDirectory = Path.Combine(dataDirectory, "System"); documentStore.Configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true; documentStore.Configuration.RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory; documentStore.Configuration.Port = port ?? 8079; documentStore.Configuration.AnonymousUserAccessMode = anonymousUserAccessMode; documentStore.Configuration.FileSystem.DataDirectory = Path.Combine(dataDirectory, "FileSystem"); documentStore.Configuration.Encryption.UseFips = ConfigurationHelper.UseFipsEncryptionAlgorithms; if (activeBundles != null) { documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles; } if (catalog != null) { documentStore.Configuration.Catalog.Catalogs.Add(catalog); } try { if (configureStore != null) { configureStore(documentStore); } ModifyStore(documentStore); ModifyConfiguration(documentStore.Configuration); documentStore.Configuration.PostInit(); documentStore.Initialize(); if (enableAuthentication) { EnableAuthentication(documentStore.SystemDatabase); } CreateDefaultIndexes(documentStore); if (indexes != null) { ExecuteIndexes(indexes, documentStore); } if (noStaleQueries) { documentStore.Listeners.RegisterListener(new NoStaleQueriesListener()); } if (transformers != null) { ExecuteTransformers(transformers, documentStore); } if (seedData != null) { StoreSeedData(seedData, documentStore); } return documentStore; } catch { // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests. documentStore.Dispose(); throw; } finally { stores.Add(documentStore); } }
public EmbeddableDocumentStore NewDocumentStore(bool runInMemory = true, string requestedStorage = null, ComposablePartCatalog catalog = null, bool deleteDirectory = true, bool deleteDirectoryOnDispose = true);
/// <summary> /// Tries to ge the catalog for the specified module info. /// </summary> /// <param name="moduleInfo">The module info.</param> /// <param name="catalog">The catalog.</param> /// <returns>true if found; otherwise false;</returns> public bool TryGet(ModuleInfo moduleInfo, out ComposablePartCatalog catalog) { return this.catalogs.TryGetValue(moduleInfo, out catalog); }
public void Initialize(ComposablePartCatalog interceptedCatalog) { }
public BuiltinFilteringCatalog(ComposablePartCatalog catalogToFilter) : base(catalogToFilter) { }
/// <summary> /// Adds the specified catalog using the module info as a key. /// </summary> /// <param name="moduleInfo">The module info.</param> /// <param name="catalog">The catalog.</param> public void Add(ModuleInfo moduleInfo, ComposablePartCatalog catalog) { catalogs.Add(moduleInfo, catalog); }
public EmbeddableDocumentStore NewDocumentStore( bool runInMemory = true, string requestedStorage = null, ComposablePartCatalog catalog = null, string dataDir = null, bool enableAuthentication = false, string activeBundles = null, int? port = null, AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin, Action<EmbeddableDocumentStore> configureStore = null, [CallerMemberName] string databaseName = null) { databaseName = NormalizeDatabaseName(databaseName); var storageType = GetDefaultStorageType(requestedStorage); var dataDirectory = dataDir ?? NewDataPath(databaseName); var documentStore = new EmbeddableDocumentStore { UseEmbeddedHttpServer = port.HasValue, Configuration = { DefaultStorageTypeName = storageType, DataDirectory = Path.Combine(dataDirectory, "System"), FileSystemDataDirectory = Path.Combine(dataDirectory, "FileSystem"), RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory, Port = port == null ? 8079 : port.Value, UseFips = SettingsHelper.UseFipsEncryptionAlgorithms, AnonymousUserAccessMode = anonymousUserAccessMode, } }; if (activeBundles != null) { documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles; } if (catalog != null) documentStore.Configuration.Catalog.Catalogs.Add(catalog); try { if (configureStore != null) configureStore(documentStore); ModifyStore(documentStore); ModifyConfiguration(documentStore.Configuration); documentStore.Configuration.PostInit(); documentStore.Initialize(); if (enableAuthentication) { EnableAuthentication(documentStore.DocumentDatabase); } CreateDefaultIndexes(documentStore); return documentStore; } catch { // We must dispose of this object in exceptional cases, otherwise this test will break all the following tests. documentStore.Dispose(); throw; } finally { stores.Add(documentStore); } }
/// <summary> /// Initializes a new instance. /// </summary> public SafeApplicationCatalog() { this.catalog = new SafeDirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory); }
public MahTweetsBuilder(ComposablePartCatalog catalog) { Catalog = catalog; Assembly currentAssembly = Assembly.GetExecutingAssembly(); Assembly coreAssembly = typeof (IEventAggregator).Assembly; // defaults - find interfaces and concrete types and marry them up this.RegisterAssemblyTypes(currentAssembly, coreAssembly) .AsImplementedInterfaces(); this.RegisterType<AccountSettingsProvider>() .As<IAccountSettingsProvider>() .SingleInstance(); this.RegisterType<ColumnsSettingsProvider>() .As<IColumnsSettingsProvider>() .SingleInstance(); this.RegisterType<ApplicationSettingsProvider>() .As<IApplicationSettingsProvider>() .Exported(x => x.As<IApplicationSettingsProvider>()) // make this part visible to MEF components .SingleInstance(); this.RegisterType<PluginSettingsProvider>() .As<IPluginSettingsProvider>() .Exported(x => x.As<IPluginSettingsProvider>()) .SingleInstance(); this.RegisterType<XmlSettingsProvider>() .As<ISettingsProvider>() .SingleInstance(); this.RegisterType<EventAggregator>() .As<IEventAggregator>() .Exported(x => x.As<IEventAggregator>()) // make this part visible to MEF components .SingleInstance(); this.RegisterType<PluginRepository>() .As<IPluginRepository>() .Exported(x => x.As<IPluginRepository>()) .SingleInstance(); this.RegisterType<LongUrlPleaseService>() .As<IUrlExpandService>() .SingleInstance(); this.RegisterType<GlobalExcludeSettingProvider>() .As<IGlobalExcludeSettings>() .SingleInstance(); this.RegisterType<GlobalExcludeSettingProvider>() .As<IGlobalExcludeSettings>() .SingleInstance(); this.RegisterType<AcronymSettingsProvider>() .As<IAcronymSettingsProvider>() .SingleInstance(); this.RegisterType<AdditonalSmartsSettingsProvider>() .As<IAdditonalSmartsSettingsProvider>() .SingleInstance(); this.RegisterType<ManualLongUrlRetrieverService>() .As<IManualLongUrlRetrieverService>() .InstancePerDependency(); this.RegisterType<Storage>() .As<IStorage>() .SingleInstance(); this.RegisterType<TextProcessorEngine>() .As<ITextProcessorEngine>() .SingleInstance(); this.RegisterType<CurrentVersion>() .As<ICurrentVersionCheck>() .SingleInstance(); this.RegisterType<AutoNotifyPropertyChangedInterceptor>(); this.RegisterAssemblyTypes(coreAssembly) .Where(t => t.Name.EndsWith("ViewModel")) .EnableClassInterceptors() .InterceptedBy(typeof (AutoNotifyPropertyChangedInterceptor)); this.RegisterAssemblyTypes(currentAssembly) .Where(t => t.Name.EndsWith("ViewModel")) .EnableClassInterceptors() .InterceptedBy(typeof (AutoNotifyPropertyChangedInterceptor)); this.RegisterType<AppViewModel>() .SingleInstance(); this.RegisterType<MainViewModel>() .As<IMainViewModel>() .SingleInstance() .EnableClassInterceptors() .InterceptedBy(typeof (AutoNotifyPropertyChangedInterceptor)) .OnActivated(a => { var viewModel = a.Instance; // commands that are not dependent on external members viewModel.AddColumnCommand = new DelegateCommand(viewModel.CreateBlankStream); viewModel.SearchCommand = new DelegateCommand(viewModel.CreateNewSearch); viewModel.RefreshCommand = new DelegateCommand(viewModel.Refresh); viewModel.ClearAllCommand = new DelegateCommand(viewModel.ClearAll); viewModel.AboutCommand = new DelegateCommand(viewModel.ShowAbout); viewModel.SetupCommand = new DelegateCommand(viewModel.ShowSetup); viewModel.NewUpdateCommand = new DelegateCommand(viewModel.NewUpdate); // are we not using the commands here viewModel.CloseCommand = new DelegateCommand(viewModel.Close); viewModel.SendMessageCommand = new SendMessageCommand((obj, src) => viewModel.SendMessage(obj)); }); this.RegisterType<StreamViewModel>() .EnableClassInterceptors() .InterceptedBy(typeof (AutoNotifyPropertyChangedInterceptor)) .OnActivated(a => { var viewmodel = a.Instance; viewmodel.ClearCommand = new DelegateCommand(() => viewmodel.ClearBeforeDate(DateTime.Now)); }); this.RegisterType<SetupViewModel>() .SingleInstance(); this.RegisterType<ResourcesViewModel>() .As<IResourcesViewModel>() .SingleInstance(); this.RegisterType<HashtagService>() .AsImplementedInterfaces() .SingleInstance(); this.RegisterType<ContactService>() .AsImplementedInterfaces() .Exported(x => x.As<IContactsRepository>()) // make this part visible to MEF components .SingleInstance(); this.RegisterType<PluginLoader>() .As<IPluginLoader>() .SingleInstance(); // StatusUpdateManager defined under two interfaces // one for plugins to use, the other for application to use var statusManager = new StatusUpdateService(); this.RegisterType<StatusUpdateService>() .AsImplementedInterfaces() .Exported(x => x.As<IStatusUpdateRepository>()) // make this part visible to MEF components .SingleInstance(); // register MEF plugins for consumption this.RegisterComposablePartCatalog(catalog); // default behaviour - just use the damn window this.RegisterType<MainWindow>() .As<MainWindow>() .As<IShell>() .SingleInstance(); this.RegisterInstance(Application.Current.Resources) .ExternallyOwned() .SingleInstance(); // MahTweets Scripting // order is important this.RegisterType<ScriptingManager>() .As<IScriptingManager>() .SingleInstance(); this.RegisterType<ScriptingConfiguration>() .As<IScriptingConfiguration>() .SingleInstance(); this.RegisterType<ScriptingHelper>() .As<IScriptingHelper>() .SingleInstance(); this.RegisterType<ScriptingUIHelper>() .As<IScriptingUIHelper>() .SingleInstance(); this.RegisterType<DynamicLanguagesScriptEngine>() .As<IScriptingEngine>() .SingleInstance(); this.RegisterType<ScriptLibrarian>() .As<IScriptingLibrarian>() .SingleInstance(); }
public FilteredCatalog(ComposablePartCatalog catalogToFilter, ApplicationType applicationType) { _catalogToFilter = catalogToFilter; _applicationType = applicationType; }
public BundlesFilteredCatalog(ComposablePartCatalog catalogToFilter, string[] bundles) : base(catalogToFilter) { Bundles = bundles; }
public ComposablePartCatalogDebuggerProxy(ComposablePartCatalog catalog) { Requires.NotNull(catalog, "catalog"); this._catalog = catalog; }
public PartitionedCatalog(ComposablePartCatalog source, Predicate<ComposablePartDefinition> filter) { _source = source; _filter = filter; }
/// <summary> /// Registers a MEF catalog within an Autofac container. /// </summary> /// <param name = "builder">The builder.</param> /// <param name = "catalog">MEF catalog to be registered.</param> public static void RegisterCatalog(this ContainerBuilder builder, ComposablePartCatalog catalog) { builder.RegisterInstance(catalog).OwnedByLifetimeScope(); }
protected FilteredCatalog(ComposablePartCatalog catalogToFilter) { _catalogToFilter = catalogToFilter; }
public static MEFedMVVMCatalog CreateCatalog(ComposablePartCatalog inner) { return new MEFedMVVMCatalog(inner, Designer.IsInDesignMode); }
public HijackedPartCatalog(ComposablePartCatalog InnerCatalog, params string[] NamesToHide) { innerCatalog = InnerCatalog; HiddenPartNames = NamesToHide.Select(x => new Regex(x)).ToList(); }
public static IPluginManager Create(ComposablePartCatalog catalog) { return new MEFBasedPluginManager(catalog); }
/// <summary> /// Adds the specified catalog to the list of available plugins. /// </summary> /// <param name="catalog"></param> public void AddPluginsCatalog(ComposablePartCatalog catalog) { PluginsManager.IfNotNull(i => i.AddCatalog(catalog)); }