当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.Add方法代码示例

本文整理汇总了C#中Configuration.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Add方法的具体用法?C# Configuration.Add怎么用?C# Configuration.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration.Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseFile

        private void ParseFile(FileInfo file, Configuration configuration)
        {
            var lines = File.ReadAllLines(file.FullName);
            foreach (var line in lines)
            {
                if (line.IsEmpty())
                {
                    continue;
                }

                if (line.Contains(":"))
                {
                    var splat = line.Split(':');
                    var name = splat.First().Trim();
                    var value = splat.Skip(1).JoinAsString(":").Trim();
                    configuration.Add(new Configuration(name, value));
                    continue;
                }

                var newName = line.Trim();
                var newFile =
                    new FileInfo(Path.Combine(file.Directory.FullName, newName + "." + _subFileExtension));
                var newConfiguration = new Configuration(newName, c => c.BelongingTo(configuration));
                ParseFile(newFile, newConfiguration);
            }
        }
开发者ID:MACSkeptic,项目名称:ExpLorer,代码行数:26,代码来源:ConfigurationParser.cs

示例2: CreateContainer

 private ForceFieldUnityContainer CreateContainer()
 {
     var unityAdvisorConfiguration = new Configuration();
     unityAdvisorConfiguration.Add<TestAdvice>(ApplyAdvice.OnEveryMethod);
     var forceFieldUnityContainer = new ForceFieldUnityContainer(unityAdvisorConfiguration);
     forceFieldUnityContainer.RegisterType<ITestInterface, TestInterfaceExtended>();
     return forceFieldUnityContainer;
 }
开发者ID:JakobOoms,项目名称:ForceField,代码行数:8,代码来源:ContainerTests.cs

示例3: BelongingTo

 public ConfigurationParameters BelongingTo(Configuration configuration)
 {
     if (configuration != null)
     {
         configuration.Add(Configuration);
     }
     return this;
 }
开发者ID:MACSkeptic,项目名称:ExpLorer,代码行数:8,代码来源:ConfigurationParameters.cs

示例4: Should_Add_a_user_watching_an_exsisting_pipeline

        public void Should_Add_a_user_watching_an_exsisting_pipeline()
        {
            var skypename = "username";
            var pipeline = "somePipe";

            var configuration = new Configuration();
            configuration.Add(pipeline, skypename);
            Assert.That(configuration.Items[0].name, Is.EqualTo(pipeline));
            Assert.That(configuration.Items[0].users[0].skypeName, Is.EqualTo(skypename));
        }
开发者ID:perryofpeek,项目名称:CCSkype,代码行数:10,代码来源:With_AddUser.cs

示例5: AllAdvicesShouldBeAutomaticlyRegistered

        public void AllAdvicesShouldBeAutomaticlyRegistered()
        {
            //Arrange
            var configuration = new Configuration();
            configuration.Add<TestAdvice>(ApplyAdvice.OnEveryMethod);
            var container = new ForceFieldUnityContainer(configuration);

            //Act
            var resolvedAdvice = container.Resolve<TestAdvice>();

            //Assert
            Assert.IsNotNull(resolvedAdvice);
        }
开发者ID:JakobOoms,项目名称:ForceField,代码行数:13,代码来源:ConfigurationTests.cs

示例6: ImplementsIHaveConfiguration

        public void ImplementsIHaveConfiguration()
        {
            //Arrange
            var containerBuilder = new ContainerBuilder();
            var configuration = new Configuration();
            configuration.Add<TestAdvice>(ApplyAdvice.OnEveryMethod);

            //Act
            var forceFieldContainer = containerBuilder.Build(configuration);

            //Assert
            Assert.IsNotNull(forceFieldContainer as IHaveConfiguration);
        }
开发者ID:JakobOoms,项目名称:ForceField,代码行数:13,代码来源:ForceFieldAutofacContainerTests.cs

示例7: TestUnityIntegration

        private static void TestUnityIntegration()
        {
            var forceFieldConfiguration = new Configuration();
            forceFieldConfiguration.Add<CachingAdvice>(ApplyAdvice.OnEveryMethod);
            forceFieldConfiguration.Add<ExceptionHandlingAdvice>(new ApplyAdviceOnAllRepositories());
            forceFieldConfiguration.Add<LoggerAdvice>(new ApplyAdviceOnAllRepositories());
            forceFieldConfiguration.Add<EmptyAdvice>(ApplyAdvice.OnEveryMethod);

            var unity = new ForceFieldUnityContainer(forceFieldConfiguration);
            unity.RegisterType<ICacheProvider, RamCacheProvider>();
            unity.RegisterType<ILoggingService, LoggingService>();
            unity.RegisterType<IOtherService, OtherService>();
            unity.RegisterType<ICacheConfigurationService, ExampleOfCacheConfigurationService>();
            unity.RegisterType<IPersonRepository, PersonRepository>();

            var repository = unity.Resolve<IPersonRepository>();
            repository.Save(new Person { Key = 1, Age = 25, Name = "John" });
            repository.GetByName("John");
            repository.GetByName("John");

            var service = unity.Resolve<IOtherService>();
            var meaningOfLife = service.Bar();
        }
开发者ID:JakobOoms,项目名称:ForceField,代码行数:23,代码来源:Program.cs

示例8: ResolveComponentReturnsAProxy

        public void ResolveComponentReturnsAProxy()
        {
            //Arrange
            var containerBuilder = new ContainerBuilder();
            containerBuilder.Register(c => new TestInterfaceExtended()).As<ITestInterface>();
            var configuration = new Configuration();
            configuration.Add<TestAdvice>(ApplyAdvice.OnEveryMethod);
            var forceFieldContainer = containerBuilder.Build(configuration);

            //Act
            var resolvedInterface = forceFieldContainer.Resolve<ITestInterface>();

            //Assert
            Assert.IsNotNull(resolvedInterface as IDynamicProxy);
        }
开发者ID:JakobOoms,项目名称:ForceField,代码行数:15,代码来源:ForceFieldAutofacContainerTests.cs

示例9: ParseConfiguration

        /// <summary>
        /// Parse a configuration command user.name='hola' user.password=what
        /// </summary>
        /// <param name="configCommand"></param>
        /// <returns></returns>
        public static IEnumerable<IConfiguration> ParseConfiguration(string configCommand)
        {
            Dictionary<string, IConfiguration> result = new Dictionary<string, IConfiguration>();
            MatchCollection matches = CommandExpression.Matches(configCommand);

            foreach (Match match in matches)
            {
                string config = match.Value;
                int firstDotIndex = config.IndexOf('.');

                // getting the category name of the command
                string category = config.Substring(0, firstDotIndex);

                //geting the property without the dot(.)
                string property = config.Substring(firstDotIndex + 1, (config.Length - firstDotIndex) - 1);

                var propertyInfo = ParseProperty(property);

                if (result.ContainsKey(category))
                {
                    result[category].Add(propertyInfo.Key, propertyInfo.Value);
                }
                else
                {
                    Configuration c = new Configuration(category);
                    c.Add(propertyInfo.Key, propertyInfo.Value);

                    result.Add(category, c);
                }
            }

            foreach (var item in result)
            {
                yield return item.Value;
            }
        }
开发者ID:einer20,项目名称:MyConfig,代码行数:41,代码来源:MyConfigParser.cs

示例10: Edit

        public ActionResult Edit([Bind(Include = "ClassroomId,CourseId,DataCenterId,UserId,Start,Name")] Classroom classroom, string sessionId)
        {
            if (ModelState.IsValid)
            {
                DataCenter dc = this.db.Query<DataCenter>().Where(d => d.DataCenterId == classroom.DataCenterId).FirstOrDefault();
                if (dc != null)
                {
                    Course crs = this.db.Query<Course>().Where(c => c.CourseId == classroom.CourseId).FirstOrDefault();
                    if (crs != null)
                    {
                        Project projectObject = new Project(this.st);
                        if (classroom.ClassroomId == 0)
                        {
                            projectObject.name = crs.Name + "-" + classroom.Start.ToShortDateString();
                            projectObject.region = dc.Region;
                            projectObject.Add();
                            if (projectObject.id != null)
                            {
                                classroom.Project = projectObject.id;
                                this.db.Add<Classroom>(classroom);
                                Log.Write(this.db, ControllerContext.HttpContext, new Log() { Message = LogMessages.create, Detail = "Classroom created for " + crs.Name + " on " + classroom.JSDate });
                            }
                        }
                        else
                        {
                            this.db.Update<Classroom>(classroom);
                            Log.Write(this.db, ControllerContext.HttpContext, new Log() { Message = LogMessages.update, Detail = "Classroom updated for  " + crs.Name + " on " + classroom.JSDate });
                        }

                        List<SeatTemp> sts = this.db.Query<SeatTemp>().Where(st => st.SessionId == sessionId).ToList();
                        List<int> stids = sts.Select(s => s.SeatId).ToList();
                        List<Seat> seatsToRemove = this.db.Query<Seat>().Where(s => !stids.Contains(s.SeatId)).ToList();
                        Configuration configuration = new Configuration(this.st);
                        foreach (Seat s in seatsToRemove)
                        {
                            this.db.Remove<Seat>(s);
                            configuration.Id = s.ConfigurationId;
                            configuration.Delete();
                        }

                        foreach (SeatTemp st in sts)
                        {
                            Seat s = st.ToSeat();
                            if (s.SeatId == 0)
                            {
                                if (s.ClassroomId == 0)
                                {
                                    s.ClassroomId = classroom.ClassroomId;
                                }

                                User usr = this.db.Query<User>().Where(u => u.UserId == s.UserId).FirstOrDefault();
                                configuration.Name = usr.EmailAddress + "-" + crs.Name;
                                configuration.Add(classroom.Project, classroom.Course.Template, dc.GateWayBackboneId, dc.Region);
                                if (configuration.Id != null)
                                {
                                    s.ConfigurationId = configuration.Id;
                                    this.db.Add<Seat>(s);
                                }
                            }

                            this.db.Remove<SeatTemp>(st);
                        }

                        this.db.SaveChanges();
                    }
                }

                return this.RedirectToAction("Index", "Home");
            }

            ViewBag.Session = sessionId;
            this.PopulateTemp(classroom.ClassroomId, ViewBag.Session);
            ViewBag.CourseId = new SelectList(this.db.Query<Course>(), "CourseId", "Name", classroom.CourseId);
            ViewBag.UserId = new SelectList(this.db.Query<User>(), "UserId", "EmailAddress", classroom.UserId);
            return this.View(classroom);
        }
开发者ID:Wierdbeard65,项目名称:Labinator2016,代码行数:76,代码来源:ClassroomsController.cs

示例11: GetDefault

        public static Configuration GetDefault(string rootPath)
        {
            Configuration res = new Configuration();
            res.DefaultConfiguration = "Default";

            MappingInfo mapping = GetDefaultMapping(rootPath, "Default");
            res.Add(mapping);

            return res;
        }
开发者ID:mvlasenko,项目名称:TridionVSRazorExtension,代码行数:10,代码来源:Service.cs


注:本文中的Configuration.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。