コード例 #1
0
        /// <summary>
        /// Converts the <see cref="PersistenceReadWriterElement"/> in a <see cref="PersistenceReadWriterElementCollection"/>
        /// to a <see cref="ResolvedParameter"/>, meaning persistence repository types referenced in configuration
        /// by name can be injected into the constructor of the parent provider.
        /// </summary>
        /// <remarks><see cref="ResolvedParameter"/> types allow for the deferred resolution of a type by using
        /// an <see cref="IComponentContext"/> to queue calls to resolve the instances, which would otherwise be
        /// tricky to do via chaining modules together</remarks>
        /// <returns>The parameters represented by this collection.</returns>
        public static IEnumerable <Parameter> ToParameters(this PersistenceReadWriterElementCollection collection)
        {
            foreach (PersistenceReadWriterElement parameter in collection)
            {
                PersistenceReadWriterElement localParameter = parameter;

                yield return(new ResolvedParameter(
                                 (p, c) =>
                                 (p.ParameterType == localParameter.ToType() || p.Name == "readWriter" ||
                                  localParameter.ToType().IsAssignableFrom(p.ParameterType)),
                                 (p, c) => ResolveNamedPersistenceRepositoryProvider(c, localParameter)));
            }
        }
コード例 #2
0
        //[TestMethod]
        public void TempGenerateConfigXmlFromTypes()
        {
            var instance = DependencyResolver.Current.Resolve <IFoundationConfigurationSection>();

            var providers = instance.PersistenceProviders;

            var writeable = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);

            instance = writeable.GetSection("rebel.foundation") as IFoundationConfigurationSection;

            providers = instance.PersistenceProviders;

            var provider1 = new PersistenceProviderElement();

            provider1.Key  = "in-memory-01";
            provider1.Type =
                "Sandbox.PersistenceProviders.InMemoryMocked.Provider, Sandbox.PersistenceProviders.InMemoryMocked";

            var reader1 = new PersistenceReaderElement();

            reader1.Key  = "reader";
            reader1.Type =
                "Sandbox.PersistenceProviders.MockedInMemory.ReadWriteRepository, Sandbox.PersistenceProviders.MockedInMemory";

            var writer1 = new PersistenceReadWriterElement();

            writer1.Key  = "writer";
            writer1.Type =
                "Sandbox.PersistenceProviders.MockedInMemory.ReadWriteRepository, Sandbox.PersistenceProviders.MockedInMemory";

            var writers = new PersistenceReadWriterElementCollection();

            provider1.Reader = reader1;

            provider1.ReadWriters.Add(writer1);

            providers.Add(provider1);

            var filename = System.IO.Path.Combine(Path.GetDirectoryName(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "test.config");

            System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None).
            SaveAs(filename);

            var a = ((FoundationConfigurationSection)instance).GetXml();

            Assert.Inconclusive(a);
        }
コード例 #3
0
    //[TestMethod]
    public void TempGenerateConfigXmlFromTypes()
    {
      var instance = DependencyResolver.Current.Resolve<IFoundationConfigurationSection>();

      var providers = instance.PersistenceProviders;

      var writeable = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
      instance = writeable.GetSection("rebel.foundation") as IFoundationConfigurationSection;

      providers = instance.PersistenceProviders;

      var provider1 = new PersistenceProviderElement();
      provider1.Key = "in-memory-01";
      provider1.Type =
        "Sandbox.PersistenceProviders.InMemoryMocked.Provider, Sandbox.PersistenceProviders.InMemoryMocked";

      var reader1 = new PersistenceReaderElement();
      reader1.Key = "reader";
      reader1.Type =
        "Sandbox.PersistenceProviders.MockedInMemory.ReadWriteRepository, Sandbox.PersistenceProviders.MockedInMemory";

      var writer1 = new PersistenceReadWriterElement();
      writer1.Key = "writer";
      writer1.Type =
        "Sandbox.PersistenceProviders.MockedInMemory.ReadWriteRepository, Sandbox.PersistenceProviders.MockedInMemory";

      var writers = new PersistenceReadWriterElementCollection();

      provider1.Reader = reader1;

      provider1.ReadWriters.Add(writer1);

      providers.Add(provider1);

      var filename = System.IO.Path.Combine(Path.GetDirectoryName(new System.Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), "test.config");

      System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None).
        SaveAs(filename);

      var a = ((FoundationConfigurationSection) instance).GetXml();
      
      Assert.Inconclusive(a);
    }