예제 #1
0
파일: Layer.cs 프로젝트: malain/candle
        /// <summary>
        /// Gets the references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            if (context.Scope == ReferenceScope.Compilation && LayerPackage.InterfaceLayer != null
                /* (loop avec interfacelayer) || context.Scope == ReferenceScope.All*/)
            {
                yield return(new ReferenceItem(this, LayerPackage.InterfaceLayer, context.IsExternal));
            }

            // La couche modèle
            if (SoftwareComponent.IsDataLayerExists)
            {
                yield return(new ReferenceItem(this, SoftwareComponent.DataLayer, context.IsExternal));
            }

            // Ref couche en dessous
            if (context.Scope != ReferenceScope.Publish)
            {
                List <Guid> layers = new List <Guid>();
                foreach (ReferenceItem ri in GetServiceReferences(context, layers))
                {
                    yield return(ri);
                }
            }

            foreach (ReferenceItem ri in base.GetReferences(context))
            {
                yield return(ri);
            }
        }
예제 #2
0
        void ParseFile(string projectDirectory, string filePath, ConcurrentDictionary <string, TemplateItem> templateItems)
        {
            var referencePath = PathNormalizer.MakeRelativePath(projectDirectory, filePath);

            DebugHelpers.WriteLine("FileNuggetFinder.ParseFile -- {0}", filePath);
            // Lookup any/all nuggets in the file and for each add a new template item.
            using var fs           = I18NUtility.Retry(() => File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read), 3);
            using var streamReader = new StreamReader(fs);

            _nuggetParser.ParseString(streamReader.ReadToEnd(), delegate(string nuggetString, int pos, Nugget nugget, string iEntity)
            {
                var referenceContext = _localizationOptions.DisableReferences
                    ? ReferenceContext.Create("Disabled references", iEntity, 0)
                    : ReferenceContext.Create(referencePath, iEntity, pos);
                var fileName = Path.GetFileNameWithoutExtension(filePath);
                // If we have a file like "myfile.aspx.vb" then the fileName will be "myfile.aspx" resulting in split
                // .pot files. So remove all extensions, so that we just have the actual name to deal with.
                fileName = fileName.IndexOf('.') > -1 ? fileName.Split('.')[0] : fileName;

                AddNewTemplateItem(
                    fileName,
                    referenceContext,
                    nugget,
                    templateItems);
                // Done.
                return(null); // null means we are not modifying the entity.
            });
        }
        public ShoppingCartServiceTests()
        {
            _context    = new ShoppingCartContext();
            _refContext = new ReferenceContext();

            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <ShoppingCartContext>());
        }
예제 #4
0
        /// <summary>
        /// Gets the references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            if ((context.Scope == ReferenceScope.Runtime && context.IsExternal == false) ||
                context.Scope == ReferenceScope.All)
            {
                //Layers d'en dessous
                List <Guid> layers = new List <Guid>();
                foreach (ServiceContract contract in ServiceContracts)
                {
                    foreach (Implementation impl in Implementation.GetLinksToImplementations(contract))
                    {
                        if (context.Mode.CheckConfigurationMode(impl.ConfigurationMode) &&
                            !layers.Contains(impl.ClassImplementation.Layer.Id))
                        {
                            Layer layer = impl.ClassImplementation.Layer;
                            layers.Add(layer.Id);
                            yield return(new ReferenceItem(this, layer, context.IsExternal));
                        }
                    }
                }
            }

            // La couche modèle
            if (SoftwareComponent.IsDataLayerExists)
            {
                yield return(new ReferenceItem(this, SoftwareComponent.DataLayer, context.IsExternal));
            }

            foreach (ReferenceItem ri in base.GetReferences(context))
            {
                yield return(ri);
            }
        }
예제 #5
0
        /// <summary>
        /// Gets the references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public System.Collections.Generic.IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            // Si il y a des ports sélectionnés, on ne prend que ceux la + le modelsLayer
            // sauf si on est en Runtime et que le modèle est une library (si cette library est dans le GAC, le layer n'a pas du proposer cette dépendance en runtime cf AbstractLayer).
            if (context.Ports != null && ((context.Scope != ReferenceScope.Runtime || !this.Model.IsLibrary) || context.Scope == ReferenceScope.All))
            {
                foreach (Guid portId in context.Ports)
                {
                    ServiceContract contract = this.Store.ElementDirectory.FindElement(portId) as ServiceContract;
                    if (contract != null)
                    {
                        yield return(new ReferenceItem(this, contract.Layer, context.IsExternal));
                    }
                }

                if (IsDataLayerExists)
                {
                    yield return(new ReferenceItem(this, this.DataLayer, context.IsExternal));
                }
            }
            // Sinon on prend tout
            else
            {
                foreach (SoftwareLayer layer in this.Layers)
                {
                    yield return(new ReferenceItem(this, layer, context.IsExternal));
                }
            }
        }
예제 #6
0
 public MockedShoppingCartIntegrationTests()
 {
     _cartsInMemory    = new List <NewCart>();
     _scMockingContext = new ShoppingCartContext {
         Carts = TestHelpers.MockDbSet(_cartsInMemory)
     };
     _refMockingContext = new ReferenceContext();
 }
 public ShoppingCartIntegrationTests()
 {
     Database.SetInitializer(new DropCreateDatabaseIfModelChanges <ShoppingCartContext>());
     _context    = new ShoppingCartContext();
     _refContext = new ReferenceContext();
     _context.Database.Initialize(force: true);//get this out of the way before logging
     SetupLogging();
 }
예제 #8
0
        private static void AssertExpectedContext(int position, ReferenceContext expected, string reason)
        {
            var actual = ReferenceContext.Create(Path, Content, position);

            Assert.AreEqual(expected.Path, actual.Path, "Path: " + reason);
            Assert.AreEqual(expected.LineNumber, actual.LineNumber, "LineNumber: " + reason);
            Assert.AreEqual(expected.Context, actual.Context, "Context:" + reason);
        }
예제 #9
0
 /// <summary>
 /// Gets the references.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
 {
     if (Store != null && Component != null)
     {
         yield return
             (new ReferenceItem(this, Component, ReferenceScope.Compilation, context.Ports, context.IsExternal));
     }
 }
 public ShoppingCartIntegrationTests()
 {
     Database.SetInitializer(new NullDatabaseInitializer <ShoppingCartContext>());
     _context    = new ShoppingCartContext();
     _refContext = new ReferenceContext();
     _context.Database.Initialize(true); //get this out of the way before logging
     SetupLogging();
 }
예제 #11
0
        /// <summary>
        /// Gets the references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            CandleModel model = ReferencedModel;

            if (model != null)
            {
                yield return(new ReferenceItem(this, model, ReferenceScope.Compilation, context.Ports, true));
            }
        }
예제 #12
0
        private void AddNewTemplateItem(
            string fileName,
            ReferenceContext referenceContext,
            Nugget nugget,
            ConcurrentDictionary <string, TemplateItem> templateItems)
        {
            string msgid = nugget.MsgId.Replace("\r\n", "\n").Replace("\r", "\\n");
            // NB: In memory msgids are normalized so that LFs are converted to "\n" char sequence.
            string        key = TemplateItem.KeyFromMsgidAndComment(msgid, nugget.Comment, _settings.MessageContextEnabledFromComment);
            List <string> tmpList;

            //
            templateItems.AddOrUpdate(
                key,
                // Add routine.
                k => {
                TemplateItem item = new TemplateItem();
                item.MsgKey       = key;
                item.MsgId        = msgid;
                item.FileName     = fileName;

                item.References = new List <ReferenceContext> {
                    referenceContext
                };

                if (nugget.Comment.IsSet())
                {
                    tmpList = new List <string>();
                    tmpList.Add(nugget.Comment);
                    item.Comments = tmpList;
                }

                return(item);
            },
                // Update routine.
                (k, v) =>
            {
                if (!_settings.DisableReferences)
                {
                    var newReferences = new List <ReferenceContext>(v.References.ToList());
                    newReferences.Add(referenceContext);
                    v.References = newReferences;
                }

                if (nugget.Comment.IsSet())
                {
                    tmpList = v.Comments != null ? v.Comments.ToList() : new List <string>();
                    if (!_settings.DisableReferences || !tmpList.Contains(nugget.Comment))
                    {
                        tmpList.Add(nugget.Comment);
                    }
                    v.Comments = tmpList;
                }

                return(v);
            });
        }
예제 #13
0
 public ShoppingCartIntegrationTests()
 {
     //app.config points to a special testing database:GeekSalesStuffTester
     Database.SetInitializer(new DropCreateDatabaseAlways <ShoppingCartContext>());
     _context    = new ShoppingCartContext();
     _refContext = new ReferenceContext();
     _context.Database.Initialize(true); //get this out of the way before logging
     SetupLogging();
 }
예제 #14
0
 static void Main(string[] args)
 {
     using (var db = new ReferenceContext())
     {
         db.Add(new Reference {
             xPoint = 0, yPoint = 0, RSSI = 0
         });
     }
 }
예제 #15
0
파일: Layer.cs 프로젝트: malain/candle
 /// <summary>
 /// Gets the service references.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="layers">The layers.</param>
 /// <returns></returns>
 protected virtual IEnumerable <ReferenceItem> GetServiceReferences(ReferenceContext context, List <Guid> layers)
 {
     foreach (ClassImplementation clazz in Classes)
     {
         foreach (ReferenceItem ri in GetServiceReferences(clazz, context, layers))
         {
             yield return(ri);
         }
     }
 }
예제 #16
0
        public ReferenceController(ReferenceContext context)
        {
            _context = context;

            // if (_context.tblProductInfo.Count() == 0)
            // {
            //     _context.tblProductInfo.Add(new TodoItem { Name = "Item1" });
            //     _context.SaveChanges();
            // }
        }
예제 #17
0
        private void Setup()
        {
            var mockMapper = new Mock <IMapper>();
            var config     = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapping());
            });
            var mapper     = config.CreateMapper();
            var refContext = new ReferenceContext();

            _gasStationRepository = new GasStationRepository(refContext, mapper);
        }
예제 #18
0
        public void SimpleTest(string expected)
        {
            var model = new ReferenceContext {
                IncludeDeclaration = true
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new LspSerializer(ClientVersion.Lsp3).DeserializeObject <ReferenceContext>(expected);

            deresult.Should().BeEquivalentTo(model);
        }
예제 #19
0
        public void SimpleTest(string expected)
        {
            var model = new ReferenceContext()
            {
                IncludeDeclaration = true
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = JsonConvert.DeserializeObject <ReferenceContext>(expected);

            deresult.ShouldBeEquivalentTo(model);
        }
예제 #20
0
        public async Task CanGetProductAsyncMocked()
        {
            var productsInMemory = new List <Product> {
                new Product(), new Product()
            };

            _refMockingContext = new ReferenceContext {
                Products = TestHelpers.MockDbSet(productsInMemory)
            };
            var repo   = new WebSiteOrderData(_scMockingContext, _refMockingContext);
            var result = await repo.GetFirstProductWithCategoryForShoppingAsync();

            Assert.IsNotNull(result);
        }
예제 #21
0
        /// <summary>
        /// Gets the service references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="layers">The layers.</param>
        /// <returns></returns>
        protected override IEnumerable <ReferenceItem> GetServiceReferences(ReferenceContext context, List <Guid> layers)
        {
            foreach (Scenario scenario in Scenarios)
            {
                foreach (ReferenceItem ri in GetServiceReferences(scenario, context, layers))
                {
                    yield return(ri);
                }
            }

            foreach (ReferenceItem ri in base.GetServiceReferences(context, layers))
            {
                yield return(ri);
            }
        }
예제 #22
0
        private void ParseString(string projectDirectory, string content, string context, ConcurrentDictionary <string, TemplateItem> templateItems)
        {
            // Lookup any/all nuggets in the file and for each add a new template item.
            _nuggetParser.ParseString(content, delegate(string nuggetString, int pos, Nugget nugget, string i_entity)
            {
                var referenceContext = ReferenceContext.Create(context, i_entity, pos);

                AddNewTemplateItem(
                    referenceContext,
                    nugget,
                    templateItems);
                // Done.
                return(null); // null means we are not modifying the entity.
            });
        }
        public void InitializeCartWithKnownCustomerStoresValueInCustomerId()
        {
            var newCartsInMemory = new List <NewCart>();
            var mockCustomer     = new Mock <Customer>();

            mockCustomer.SetupGet(c => c.CustomerCookie).Returns("CustomerCookieABCDE");
            mockCustomer.SetupGet(c => c.CustomerId).Returns(1);
            var customersInMemory = new List <Customer> {
                mockCustomer.Object
            };
            var scContext = new ShoppingCartContext {
                Carts = TestHelpers.MockDbSet(newCartsInMemory)
            };
            var refcontext = new ReferenceContext {
                Customers = TestHelpers.MockDbSet(customersInMemory)
            };
            var service = new WebSiteOrderingService(new WebSiteOrderData(scContext, refcontext));

            service.ItemSelected(1, 1, 9.99m, theUri, "CustomerCookieABCDE", 0);
            Assert.AreNotEqual(0, newCartsInMemory.FirstOrDefault().CustomerId);
        }
예제 #24
0
        private void ParseFile(string projectDirectory, string filePath, ConcurrentDictionary <string, TemplateItem> templateItems)
        {
            var referencePath = PathNormalizer.MakeRelativePath(projectDirectory, filePath);

            DebugHelpers.WriteLine("FileNuggetFinder.ParseFile -- {0}", filePath);
            // Lookup any/all nuggets in the file and for each add a new template item.
            using (var fs = File.OpenText(filePath))
            {
                _nuggetParser.ParseString(fs.ReadToEnd(), delegate(string nuggetString, int pos, Nugget nugget, string i_entity)
                {
                    var referenceContext = ReferenceContext.Create(referencePath, i_entity, pos);

                    AddNewTemplateItem(
                        referenceContext,
                        nugget,
                        templateItems);
                    // Done.
                    return(null); // null means we are not modifying the entity.
                });
            }
        }
예제 #25
0
        /// <summary>
        /// Gets the references.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public override IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            foreach (
                AssemblyReferencesAssemblies link in
                AssemblyReferencesAssemblies.GetLinksToInternalAssemblyReferences(this))
            {
                if (context.CheckScope(link.Scope))
                {
                    if (context.Scope != ReferenceScope.Runtime || link.SourceAssembly.IsInGac == false ||
                        context.Scope == ReferenceScope.All)
                    {
                        yield return(new ReferenceItem(this, link.SourceAssembly, context.IsExternal));
                    }
                }
            }

            foreach (ReferenceItem ri in base.GetReferences(context))
            {
                yield return(ri);
            }
        }
예제 #26
0
        private void AddRef()
        {
            ReferenceContext context = new ReferenceContext();

            context.injection(PrjCmdId.Infrastructure, PrjCmdId.DomainContext, PrjCmdId.DomainEntity, "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Infrastruct.CodeFirst.Seedwork.dll", "EntityFramework.dll", "System.Data.Entity", "System.ComponentModel.DataAnnotations");

            context.injection(PrjCmdId.DomainContext, PrjCmdId.DomainEntity, "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll", "System.Data.Entity");

            context.injection(PrjCmdId.DomainEntity, "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll");

            context.injection(PrjCmdId.Application, PrjCmdId.Data2Object, PrjCmdId.DomainContext, PrjCmdId.DomainEntity, PrjCmdId.IApplication, "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Infrastruct.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Application.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Infrastructure.CrossCutting.dll");
            context.injection(PrjCmdId.IApplication, PrjCmdId.DomainEntity, PrjCmdId.Data2Object);
            context.injection(PrjCmdId.Data2Object, PrjCmdId.DomainEntity, "System.Runtime.Serialization", "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll", "AutoMapper.dll", "AutoMapper.Net4.dll");
            context.injection(PrjCmdId.Service, PrjCmdId.Infrastructure, PrjCmdId.Application, PrjCmdId.IApplication, PrjCmdId.DomainContext, PrjCmdId.Data2Object, "System.Runtime.Serialization", "System.ServiceModel", "EntityFramework.dll", "iTelluro.Explorer.Domain.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Infrastruct.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Application.CodeFirst.Seedwork.dll", "iTelluro.Explorer.Infrastructure.CrossCutting.dll", "AutoMapper.dll", "AutoMapper.Net4.dll", "iTelluro.Explorer.Infrastructure.CrossCutting.NetFramework.dll", "iTelluro.SSO.dll", "iTelluro.SSO.Common.dll", "iTelluro.SSO.WebServices.dll", "iTelluro.SYS.Entity.dll", "iTelluro.Utility.dll", "log4net.dll", "Microsoft.Practices.Unity.dll");
            context.HandledOne  += context_HandledOne;
            _totalPercent        = 1;
            _processCurrentCount = 1;
            _processTotalCount   = 1;
            _currentTotalCount   = context.Count;
            context.Commit();
        }
    public ReferenceContext reference()
    {
        ReferenceContext _localctx = new ReferenceContext(Context, State);

        EnterRule(_localctx, 4, RULE_reference);
        int _la;

        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 22; Match(REF_OPEN);
                State = 24;
                ErrorHandler.Sync(this);
                _la = TokenStream.LA(1);
                do
                {
                    {
                        {
                            State = 23; reference_internals();
                        }
                    }
                    State = 26;
                    ErrorHandler.Sync(this);
                    _la = TokenStream.LA(1);
                } while (_la == REF_CMND_NAME || _la == REF_CMND_VAL);
                State = 28; Match(REF_CLOSE);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
예제 #28
0
        public ReferenceContext reference()
        {
            ReferenceContext _localctx = new ReferenceContext(_ctx, State);

            EnterRule(_localctx, 8, RULE_reference);
            int _la;

            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 85;
                    _la   = _input.La(1);
                    if (!(_la == EntityRef || _la == CharRef))
                    {
                        _errHandler.RecoverInline(this);
                    }
                    else
                    {
                        if (_input.La(1) == TokenConstants.Eof)
                        {
                            matchedEOF = true;
                        }

                        _errHandler.ReportMatch(this);
                        Consume();
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
예제 #29
0
        //public void RetrieveReferences(ReferenceContext ctx) { }

        #region IHasReferences Members

        /// <summary>
        /// Liste des références
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public IEnumerable <ReferenceItem> GetReferences(ReferenceContext context)
        {
            // Compilation
            if (context.Scope == ReferenceScope.Compilation)
            {
                foreach (DotNetAssembly assembly in Assemblies)
                {
                    if (context.CheckPort(assembly.Id))
                    {
                        yield return(new ReferenceItem(this, assembly, context.IsExternal));
                    }
                }
            }

            // Tout
            if (context.Scope == ReferenceScope.Runtime || context.Scope == ReferenceScope.Publish ||
                context.Scope == ReferenceScope.All)
            {
                foreach (DotNetAssembly layer in Assemblies)
                {
                    yield return(new ReferenceItem(this, layer, context.IsExternal));
                }
            }
        }
예제 #30
0
 /// <summary>
 /// Returns an array with all locations where the symbol at the given position - if any - is referenced.
 /// Returns null if some parameters are unspecified (null),
 /// or if the specified position is not a valid position within the currently processed file content,
 /// or if no symbol exists at the specified position at this time.
 /// </summary>
 public static Location[] SymbolReferences(this FileContentManager file, CompilationUnit compilation, Position position, ReferenceContext context)
 {
     if (file == null)
     {
         return(null);
     }
     if (!file.TryGetReferences(compilation, position, out var declLocation, out var locations))
     {
         return(null);
     }
     return((context?.IncludeDeclaration ?? true) && declLocation != null
         ? new[] { declLocation }.Concat(locations).ToArray()
         : locations.ToArray());
 }
예제 #31
0
 public ModelBusReference DeserializeReference(string serializedReference, ReferenceContext context)
 {
     throw new System.NotImplementedException();
 }
 protected override string SerializeAdapterReference(ModelBusAdapterReference reference, ReferenceContext context)
 {
     throw new NotImplementedException();
 }
예제 #33
0
		private BacktrackDetector(ReferenceContext context) {
			this.context = context;
			this.borrowId = context.borrowId;
			this.touchId = context.touchId;
		}