コード例 #1
0
        public PEDeltaAssemblyBuilder(
            SourceAssemblySymbol sourceAssembly,
            string outputName,
            OutputKind outputKind,
            ModulePropertiesForSerialization serializationProperties,
            IEnumerable<ResourceDescription> manifestResources,
            Func<AssemblySymbol, AssemblyIdentity> assemblySymbolMapper,
            EmitBaseline previousGeneration,
            IEnumerable<SemanticEdit> edits)
            : base(sourceAssembly, outputName, outputKind, serializationProperties, manifestResources, assemblySymbolMapper, additionalTypes: ImmutableArray<NamedTypeSymbol>.Empty)
        {
            var context = new Context(this, null, new DiagnosticBag());
            var module = previousGeneration.OriginalMetadata;
            var compilation = sourceAssembly.DeclaringCompilation;
            var metadataAssembly = compilation.GetBoundReferenceManager().CreatePEAssemblyForAssemblyMetadata(AssemblyMetadata.Create(module), MetadataImportOptions.All);
            var metadataDecoder = new Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.MetadataDecoder(metadataAssembly.PrimaryModule);

            previousGeneration = EnsureInitialized(previousGeneration, metadataDecoder);

            var matchToMetadata = new SymbolMatcher(previousGeneration.AnonymousTypeMap, sourceAssembly, context, metadataAssembly);

            SymbolMatcher matchToPrevious = null;
            if (previousGeneration.Ordinal > 0)
            {
                var previousAssembly = ((CSharpCompilation)previousGeneration.Compilation).SourceAssembly;
                var previousContext = new Context((PEModuleBuilder)previousGeneration.PEModuleBuilder, null, new DiagnosticBag());
                matchToPrevious = new SymbolMatcher(previousGeneration.AnonymousTypeMap, sourceAssembly, context, previousAssembly, previousContext);
            }

            this.previousDefinitions = new DefinitionMap(previousGeneration.OriginalMetadata.Module, metadataDecoder, matchToMetadata, matchToPrevious, GenerateMethodMap(edits));
            this.previousGeneration = previousGeneration;
            this.changes = new SymbolChanges(this.previousDefinitions, edits);
        }
コード例 #2
0
        public void TestFixtureSetUp()
        {
            factory = new InterceptingProxyFactory();
            var map = new DefinitionMap();

            factory.Initialize(new[] { typeof(InterceptableItem), typeof(InterceptableInheritorItem), typeof(IgnoringItem) }.Select(t => map.GetOrCreateDefinition(t)));
        }
コード例 #3
0
 /// <summary>Stores dependencies</summary>
 /// <param name="finder"></param>
 /// <param name="repository"></param>
 /// <param name="activator"></param>
 public ContainerRepository(IRepository <ContentItem> repository, IHost host, ContentActivator activator, DefinitionMap map)
 {
     this.repository = repository;
     this.host       = host;
     this.activator  = activator;
     this.map        = map;
 }
コード例 #4
0
        public FluentDefinitionProvider(DefinitionMap map, IFluentRegisterer[] registerers)
        {
            var definitions = registerers
                              .OrderBy(r => Utility.InheritanceDepth(r.RegisteredType))
                              .SelectMany(r => r.Register(map));

            definitionsCache = definitions.ToArray();
        }
コード例 #5
0
        public virtual IEnumerable <ItemDefinition> Register(DefinitionMap map)
        {
            var registration = new ContentRegistration <T>(map.GetOrCreateDefinition(RegisteredType));

            registration.IsDefined = true;
            RegisterDefinition(registration);
            return(new [] { registration.Finalize() });
        }
コード例 #6
0
ファイル: DefinitionManager.cs プロジェクト: johants/n2cms
        public DefinitionManager(IDefinitionProvider[] definitionProviders, ContentActivator activator, StateChanger changer, DefinitionMap map)
        {
            this.definitionProviders = definitionProviders.OrderBy(dp => dp.SortOrder).ToArray();
            this.activator           = activator;
            this.stateChanger        = changer;
            this.map = map;

            activator.Initialize(GetDefinitions());
        }
コード例 #7
0
        public static IDefinitionProvider[] SetupDefinitionProviders(DefinitionMap map, params Type[] itemTypes)
        {
            IDefinitionProvider[] definitionProviders;
            ITypeFinder           typeFinder = new Fakes.FakeTypeFinder(itemTypes.Select(t => t.Assembly).FirstOrDefault() ?? Assembly.GetExecutingAssembly(), itemTypes);

            var definitionBuilder = new DefinitionBuilder(map, typeFinder, new TransformerBase <IUniquelyNamed> [0], SetupEngineSection());

            definitionProviders = new IDefinitionProvider[] { new DefinitionProvider(definitionBuilder) };
            return(definitionProviders);
        }
コード例 #8
0
        public static void Setup(out IDefinitionProvider[] definitionProviders, out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out InterceptingProxyFactory proxyFactory, params Type[] itemTypes)
        {
            var map = new DefinitionMap();

            definitionProviders = SetupDefinitionProviders(map, itemTypes);
            notifier            = new ItemNotifier();
            proxyFactory        = new InterceptingProxyFactory();
            activator           = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, proxyFactory);
            definitions         = new DefinitionManager(definitionProviders, activator, new StateChanger(), new DefinitionMap());
            ((DefinitionManager)definitions).Start();
        }
コード例 #9
0
ファイル: InstallationManager.cs プロジェクト: amarwadi/n2cms
 public InstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext)
 {
     this.host                 = host;
     this.map                  = map;
     this.activator            = activator;
     this.importer             = importer;
     this.persister            = persister;
     this.sessionProvider      = sessionProvider;
     this.configurationBuilder = configurationBuilder;
     this.webContext           = webContext;
 }
コード例 #10
0
        public static void Setup(out IDefinitionManager definitions, out ITemplateAggregator templates, out ContentActivator activator, params Type[] itemTypes)
        {
            var map = new DefinitionMap();
            var definitionProviders = SetupDefinitionProviders(map, itemTypes);
            var notifier            = new ItemNotifier();
            var proxyFactory        = new InterceptingProxyFactory();

            activator   = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, proxyFactory);
            definitions = new DefinitionManager(definitionProviders, activator, new StateChanger(), new DefinitionMap());
            templates   = new TemplateAggregator(definitions, new[] { new TemplateProvider(activator, map) });
            ((IAutoStart)definitions).Start();
            ((IAutoStart)templates).Start();
        }
コード例 #11
0
 public InstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext, ConnectionMonitor connectionContext, DatabaseSection config)
 {
     this.host                       = host;
     this.map                        = map;
     this.activator                  = activator;
     this.importer                   = importer;
     this.persister                  = persister;
     this.sessionProvider            = sessionProvider;
     this.configurationBuilder       = configurationBuilder;
     this.webContext                 = webContext;
     this.connectionContext          = connectionContext;
     this.isDatabaseFileSystemEnbled = config.Files.StorageLocation == FileStoreLocation.Database;
 }
コード例 #12
0
        public static void Setup(out IDefinitionProvider[] definitionProviders, out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out InterceptingProxyFactory proxyFactory, params Type[] itemTypes)
        {
            ITypeFinder typeFinder = new Fakes.FakeTypeFinder(itemTypes.Select(t => t.Assembly).FirstOrDefault() ?? Assembly.GetExecutingAssembly(), itemTypes);

            var map = new DefinitionMap();
            var definitionBuilder = new DefinitionBuilder(map, typeFinder, new TransformerBase <IUniquelyNamed> [0], SetupEngineSection());

            notifier            = new ItemNotifier();
            proxyFactory        = new InterceptingProxyFactory();
            activator           = new ContentActivator(new N2.Edit.Workflow.StateChanger(), notifier, proxyFactory);
            definitionProviders = new IDefinitionProvider[] { new DefinitionProvider(definitionBuilder) };
            definitions         = new DefinitionManager(definitionProviders, new [] { new TemplateProvider(activator, map) }, activator, new StateChanger());
            ((DefinitionManager)definitions).Start();
        }
コード例 #13
0
        public override void SetUp()
        {
            base.SetUp();

            user = CreatePrincipal("SomeSchmuck");

            map = new DefinitionMap();
            DefinitionBuilder builder  = new DefinitionBuilder(map, typeFinder, new TransformerBase <IUniquelyNamed> [0], new EngineSection());
            IItemNotifier     notifier = mocks.DynamicMock <IItemNotifier>();

            mocks.Replay(notifier);
            var changer = new N2.Edit.Workflow.StateChanger();

            activator   = new ContentActivator(changer, notifier, new EmptyProxyFactory());
            definitions = new DefinitionManager(new[] { new DefinitionProvider(builder) }, activator, changer, new DefinitionMap());
        }
コード例 #14
0
        public static void Setup(out IDefinitionManager definitions, out ContentActivator activator, out IItemNotifier notifier, out FakeSessionProvider sessionProvider, out ItemFinder finder, out SchemaExport schemaCreator, out InterceptingProxyFactory proxyFactory, IWebContext context, DatabaseSection config, ConfigurationBuilderParticipator[] participators, params Type[] itemTypes)
        {
            IDefinitionProvider[] definitionProviders;
            Setup(out definitionProviders, out definitions, out activator, out notifier, out proxyFactory, itemTypes);

            var connectionStrings = (ConnectionStringsSection)ConfigurationManager.GetSection("connectionStrings");
            var map = new DefinitionMap();
            var configurationBuilder = new ConfigurationBuilder(definitionProviders, new ClassMappingGenerator(map), new ThreadContext(), participators, config, connectionStrings);
            var configurationSource  = new ConfigurationSource(configurationBuilder);

            sessionProvider = new FakeSessionProvider(configurationSource, new NHInterceptorFactory(proxyFactory, notifier), context);
            sessionProvider.CurrentSession = null;

            finder = new ItemFinder(sessionProvider, map);

            schemaCreator = new SchemaExport(configurationSource.BuildConfiguration());
        }
コード例 #15
0
        public void ExportedImportedItem_AutoGeneratedProperties_AreImported()
        {
            var item = definitions.CreateInstance <XmlableItem2>(null);

            item.AutoPropertyString = "Hello World!";

            // simulate saving proxied items - this is most likely the case in normal operation
            var pf  = new N2.Persistence.Proxying.InterceptingProxyFactory();
            var map = new DefinitionMap();

            pf.Initialize(new [] { map.GetOrCreateDefinition(typeof(XmlableItem2)) });
            pf.OnSaving(item);

            var readItem = ExportAndImport(item, ExportOptions.Default);

            Assert.That(readItem.AutoPropertyString, Is.EqualTo(item.AutoPropertyString));
        }
コード例 #16
0
ファイル: EditableItemTest.cs プロジェクト: johants/n2cms
        public void NewChild_IsSaved()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            var ctx = new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User);

            enclosingEditor.UpdateObject(ctx);

            ctx.GetItemsToSave().ShouldContain(item.TheItem);
        }
コード例 #17
0
ファイル: EditableItemTest.cs プロジェクト: johants/n2cms
        public void ItemEditor_AddsNewChild()
        {
            var item       = new DecoratedItem();
            var definition = new DefinitionMap().GetOrCreateDefinition(item);
            var editable   = (EditableItemAttribute)definition.Properties["TheItem"].Editable;

            var page            = new Page();
            var enclosingEditor = new ItemEditor();
            var editor          = AddEditorAndInit(item, editable, page, enclosingEditor);

            editable.UpdateEditor(item, editor);

            ItemUtility.FindInChildren <N2.Web.UI.WebControls.NameEditor>(editor).Single().Text = "Hello child";

            enclosingEditor.UpdateObject(new N2.Edit.Workflow.CommandContext(definition, item, Interfaces.Editing, engine.RequestContext.User));

            item.Children.Single().ShouldBe(item.TheItem);
        }
コード例 #18
0
 public ContentTemplateRepository(IPersister persister, DefinitionMap map, ContainerRepository <TemplateContainer> container)
 {
     this.persister = persister;
     this.map       = map;
     this.container = container;
 }
コード例 #19
0
 public CrossLinkDefinitionBuilder(DefinitionMap staticDefinitions, CrossLinkTypeFinder typeFinder, TransformerBase <IUniquelyNamed>[] transformers, EngineSection config)
     : base(staticDefinitions, typeFinder, transformers, config)
 {
 }
コード例 #20
0
 public void SetUp()
 {
     Context.Replace(engine = new Fakes.FakeEngine(new[] { typeof(DecoratedItem), typeof(DecoratedItem2) }));
     engine.AddComponentInstance <ITemplateAggregator>(new TemplateAggregator(engine.Definitions, new ITemplateProvider[] { new TemplateProvider(TestSupport.SetupContentActivator(), map = new DefinitionMap()) }));
 }
コード例 #21
0
 public FakePartsAdapter(DefinitionMap map)
 {
     this.map = map;
 }
コード例 #22
0
 public ViewTemplateAnalyzer(IProvider <ViewEngineCollection> viewEnginesProvider, DefinitionMap map, DefinitionBuilder builder)
 {
     this.viewEnginesProvider = viewEnginesProvider;
     this.map     = map;
     this.builder = builder;
 }
コード例 #23
0
 public ClassMappingGenerator(DefinitionMap map)
 {
     this.map = map;
 }
コード例 #24
0
 public BehaviorInvoker(IPersister persister, DefinitionMap definitionMap, params IBehavior[] generalBehaviors)
 {
     this.persister        = persister;
     this.definitionMap    = definitionMap;
     this.generalBehaviors = generalBehaviors;
 }
コード例 #25
0
ファイル: ChildGroupSource.cs プロジェクト: nikita239/Aspect
 public ChildGroupSource(DefinitionMap map)
 {
     this.map = map;
 }
コード例 #26
0
ファイル: ItemFinder.cs プロジェクト: zeeshananjum/n2cms
 public ItemFinder(ISessionProvider sessionProvider, DefinitionMap map)
 {
     this.sessionProvider = sessionProvider;
     this.map             = map;
 }
コード例 #27
0
ファイル: QueryBuilder.cs プロジェクト: amarwadi/n2cms
 public QueryBuilder(ISessionProvider sessionProvider, DefinitionMap map)
 {
     this.sessionProvider = sessionProvider;
     this.map             = map;
 }
コード例 #28
0
 public ContentTemplateRepository(IRepository <ContentItem> repository, DefinitionMap map, ContainerRepository <TemplateContainer> container)
 {
     this.repository = repository;
     this.map        = map;
     this.container  = container;
 }
コード例 #29
0
 public RavenInstallationManager(IHost host, DefinitionMap map, ContentActivator activator, Importer importer, IPersister persister, ISessionProvider sessionProvider, IConfigurationBuilder configurationBuilder, IWebContext webContext, ConnectionMonitor connectionContext, DatabaseSection config, RavenConnectionProvider cp)
     : base(connectionContext, importer, webContext, persister, activator)
 {
     this.cp = cp;
 }