Пример #1
0
        /// <inheritdoc />
        public void VisitChunk([NotNull] Chunk chunk)
        {
            var injectChunk = ChunkHelper.EnsureChunk <InjectChunk>(chunk);

            injectChunk.TypeName = ChunkHelper.ReplaceTModel(injectChunk.TypeName, _modelType);
            _addedMemberNames.Add(injectChunk.MemberName);
        }
Пример #2
0
        /// <inheritdoc />
        public void VisitChunk([NotNull] Chunk chunk)
        {
            var setBaseTypeChunk = ChunkHelper.EnsureChunk <SetBaseTypeChunk>(chunk);

            setBaseTypeChunk.TypeName = ChunkHelper.ReplaceTModel(setBaseTypeChunk.TypeName, _modelType);
            _isBaseTypeSet            = true;
        }
Пример #3
0
        /// <inheritdoc />
        public void Merge([NotNull] CodeTree codeTree, [NotNull] Chunk chunk)
        {
            var namespaceChunk = ChunkHelper.EnsureChunk <UsingChunk>(chunk);

            if (!_currentUsings.Contains(namespaceChunk.Namespace))
            {
                _currentUsings.Add(namespaceChunk.Namespace);
                codeTree.Chunks.Add(namespaceChunk);
            }
        }
Пример #4
0
        /// <inheritdoc />
        public void Merge([NotNull] CodeTree codeTree, [NotNull] Chunk chunk)
        {
            var injectChunk = ChunkHelper.EnsureChunk <InjectChunk>(chunk);

            if (!_addedMemberNames.Contains(injectChunk.MemberName))
            {
                _addedMemberNames.Add(injectChunk.MemberName);
                codeTree.Chunks.Add(TransformChunk(injectChunk));
            }
        }
Пример #5
0
        private static Dictionary <Type, IChunkMerger> GetMergerMappings(CodeTree codeTree, string defaultModel)
        {
            var modelType = ChunkHelper.GetModelTypeName(codeTree, defaultModel);

            return(new Dictionary <Type, IChunkMerger>
            {
                { typeof(UsingChunk), new UsingChunkMerger() },
                { typeof(InjectChunk), new InjectChunkMerger(modelType) },
                { typeof(SetBaseTypeChunk), new SetBaseTypeChunkMerger(modelType) }
            });
        }
        private static IChunkMerger[] GetChunkMergers(ChunkTree chunkTree, string defaultModel)
        {
            var modelType = ChunkHelper.GetModelTypeName(chunkTree, defaultModel);

            return(new IChunkMerger[]
            {
                new UsingChunkMerger(),
                new InjectChunkMerger(modelType),
                new SetBaseTypeChunkMerger(modelType)
            });
        }
Пример #7
0
        /// <inheritdoc />
        public void Merge([NotNull] CodeTree codeTree, [NotNull] Chunk chunk)
        {
            if (!_isBaseTypeSet)
            {
                var baseTypeChunk = ChunkHelper.EnsureChunk <SetBaseTypeChunk>(chunk);

                // The base type can set exactly once and the first one we encounter wins.
                _isBaseTypeSet = true;

                codeTree.Chunks.Add(TransformChunk(baseTypeChunk));
            }
        }
Пример #8
0
        private InjectChunk TransformChunk(InjectChunk injectChunk)
        {
            var typeName = ChunkHelper.ReplaceTModel(injectChunk.TypeName, _modelType);

            if (typeName != injectChunk.TypeName)
            {
                return(new InjectChunk(typeName, injectChunk.MemberName)
                {
                    Start = injectChunk.Start,
                    Association = injectChunk.Association
                });
            }
            return(injectChunk);
        }
Пример #9
0
        private SetBaseTypeChunk TransformChunk(SetBaseTypeChunk setBaseTypeChunk)
        {
            var typeName = ChunkHelper.ReplaceTModel(setBaseTypeChunk.TypeName, _modelType);

            if (typeName != setBaseTypeChunk.TypeName)
            {
                return(new SetBaseTypeChunk
                {
                    TypeName = typeName,
                    Start = setBaseTypeChunk.Start,
                    Association = setBaseTypeChunk.Association
                });
            }
            return(setBaseTypeChunk);
        }
Пример #10
0
        /// <inheritdoc />
        public void VisitChunk(Chunk chunk)
        {
            if (chunk == null)
            {
                throw new ArgumentNullException(nameof(chunk));
            }

            var setBaseTypeChunk = chunk as SetBaseTypeChunk;

            if (setBaseTypeChunk != null)
            {
                setBaseTypeChunk.TypeName = ChunkHelper.ReplaceTModel(setBaseTypeChunk.TypeName, _modelType);
                _isBaseTypeSet            = true;
            }
        }
Пример #11
0
        /// <inheritdoc />
        public void VisitChunk(Chunk chunk)
        {
            if (chunk == null)
            {
                throw new ArgumentNullException(nameof(chunk));
            }

            var injectChunk = chunk as InjectChunk;

            if (injectChunk != null)
            {
                injectChunk.TypeName = ChunkHelper.ReplaceTModel(injectChunk.TypeName, _modelType);
                _addedMemberNames.Add(injectChunk.MemberName);
            }
        }
Пример #12
0
        /// <inheritdoc />
        public void VisitChunk([NotNull] Chunk chunk)
        {
            var namespaceChunk = ChunkHelper.EnsureChunk <UsingChunk>(chunk);

            _currentUsings.Add(namespaceChunk.Namespace);
        }