/// <summary> /// 제품메뉴중 사용자가 권한이 있는 메뉴목록 /// </summary> /// <param name="productId">제품Id</param> /// <param name="identity">요청자 정보</param> /// <returns>메뉴목록</returns> public override IEnumerable <MenuItem> FindAllMenuByProduct(string productId, IAccessIdentity identity) { if (IsDebugEnabled) { log.Debug("==>> S productId={0}, identity={1}", productId, identity); } productId.ShouldNotBeWhiteSpace("값이 없습니다."); //identity.ShouldNotBeNull("사용자 정보가 없습니다."); if (identity == null) { return(null); } var provider = SiteMap.Providers[productId]; if (IsDebugEnabled) { log.Debug("productId={0}, identity={1}, provider={2}", productId, identity, provider); } var menus = new List <MenuItem>(); if (provider != null) { if (IsDebugEnabled) { log.Debug("provider.RootNode={0}", provider.RootNode); } if (provider.RootNode != null) { var nodes = GetAuthMenus(provider.RootNode.GetAllNodes(), identity); foreach (SiteMapNode node in nodes) { var menu = new MenuItem(node.Title, node.Title, node.Url); menu.NodePosition.Level = 0; menu.NodePosition.Order = 0; menu.Parent = null; //AddNode(node, menu, 1); menus.Add(menu); } } } if (IsDebugEnabled) { log.Debug("==>> E menus={0}", menus.CollectionToString()); } return(menus); }
/// <summary> /// 메뉴중 사용자가 권한이 있는 루트메뉴목록 /// </summary> /// <param name="productId">제품Id</param> /// <param name="identity">요청자 정보</param> /// <returns>메뉴목록</returns> public override IEnumerable<MenuItem> GetRootMenu(string productId, IAccessIdentity identity) { if(IsDebugEnabled) log.Debug("==>> S productId={0}, identity={1}", productId, identity); productId.ShouldNotBeWhiteSpace("값이 없습니다."); //identity.ShouldNotBeNull("사용자 정보가 없습니다."); if(identity == null) return null; var provider = SiteMap.Providers[productId]; if(IsDebugEnabled) log.Debug("productId={0}, identity={1}, provider={2}", productId, identity, provider); var menus = new List<MenuItem>(); if(provider != null) { if(IsDebugEnabled) log.Debug("provider.RootNode={0}", provider.RootNode); if(provider.RootNode != null) { var nodes = GetAuthMenus(provider.RootNode.ChildNodes, identity); foreach(SiteMapNode node in nodes) { var menu = new MenuItem(node.Title, node.Title, node.Url); menu.NodePosition.Level = 0; menu.NodePosition.Order = 0; menu.Parent = null; AddNode(node, menu, 1); menus.Add(menu); } } } if(IsDebugEnabled) log.Debug("==>> E menus={0}", menus.CollectionToString()); return menus; }
static void Main(string[] args) { Console.Write("Enter even number: "); var input = Console.ReadLine(); if (Int32.TryParse(input, out int result)) { if (result.IsEven()) { Console.WriteLine($"{result} - Even"); } else { Console.WriteLine($"{result} - Not Even"); } } else { Console.WriteLine("You input not correct form"); } Console.WriteLine(result.IsDevideBy(10).ToString()); var list = new List <int>() { 1, 2, 3, 4, 5 }; Console.WriteLine(list.CollectionToString()); var PersonList = new List <Person>(); for (int i = 0; i < 10; i++) { Person person = new Person(); person.CreateRandomPerson(18, 60); PersonList.Add(person); } Console.WriteLine(PersonList.CollectionToString()); }
/// <summary> /// 원본 인스턴스의 속성 값을 읽어와 대상 인스턴스의 속성에 매핑합니다. /// </summary> /// <typeparam name="TTarget">대상 인스턴스 수형</typeparam> /// <param name="source">원본 인스턴스</param> /// <param name="targetFactory">대상 인스턴스 생성 함수</param> /// <param name="mapOptions">매핑 시의 옵션</param> /// <param name="propertyExprsToExclude">제외할 속성명</param> /// <result>매핑 대상 인스턴스</result> public static TTarget MapProperty <TTarget>(this object source, Func <TTarget> targetFactory, MapPropertyOptions mapOptions, params Expression <Func <TTarget, object> >[] propertyExprsToExclude) { targetFactory.ShouldNotBeNull("targetFactory"); var target = targetFactory(); target.ShouldNotBeDefault("target"); if (IsDebugEnabled) { log.Debug("소스 인스턴스의 속성 정보를 대상 인스턴스[{2}]의 속성 값에 설정합니다. source=[{0}], target=[{1}]", source, target, typeof(TTarget).FullName); } var sourceAccessor = DynamicAccessorFactory.CreateDynamicAccessor(source.GetType(), mapOptions.SuppressException); var targetAccessor = DynamicAccessorFactory.CreateDynamicAccessor <TTarget>(mapOptions.SuppressException); var propertyNamesToExclude = propertyExprsToExclude.Select(expr => LinqTool.FindPropertyName(expr.Body)); var excludes = new List <string>(propertyNamesToExclude); if (IsDebugEnabled) { log.Debug("속성 설젱에서 제외할 속성들=[{0}]", excludes.CollectionToString()); } var sourcePropertyNames = sourceAccessor.GetPropertyNames(); var targetPropertyNames = targetAccessor.GetPropertyNames().Except(excludes).ToList(); if (IsDebugEnabled) { log.Debug("설정할 속성들=[{0}]", targetPropertyNames.CollectionToString()); } var sourceTypeName = source.GetType().FullName; var targetTypeName = typeof(TTarget).FullName; foreach (var propertyName in targetPropertyNames) { var targetName = propertyName; if (excludes.Any(epn => StringTool.EqualTo(epn, targetName))) { continue; } var sourceName = sourcePropertyNames.FirstOrDefault(spn => StringTool.EqualTo(spn, targetName)); if (sourceName.IsNotWhiteSpace()) { if (mapOptions.SkipAlreadyExistValue) { var targetType = targetAccessor.GetPropertyType(targetName); var targetValue = targetAccessor.GetPropertyValue(target, targetName); if (Equals(targetValue, targetType.GetTypeDefaultValue()) == false) { if (IsDebugEnabled) { log.Debug("대상 객체의 속성[{0}]에 이미 값이 설정되어 있어, 설정을 건너뜁니다. 속성값=[{1}]", targetName, targetValue); } continue; } } if (IsDebugEnabled) { log.Debug("원본객체[{0}] => 대상객체[{1}]로 속성[{2}]의 값을 할당합니다...", sourceTypeName, targetTypeName, propertyName); } var propertyValue = sourceAccessor.GetPropertyValue(source, sourceName); targetAccessor.SetPropertyValue(target, targetName, propertyValue); if (IsDebugEnabled) { log.Debug("속성[{0}]에 할당된 값은 [{1}]입니다.", targetName, propertyValue); } } } return(target); }
private bool ValidateConnectionConfig(ConnectionConfig config) { var context = new ValidationContext(config, null, null); var results = new List<ValidationResult>(); bool result = Validator.TryValidateObject(config, context, results); if (!result) Authenticated(this, new AuthenticationEventArgs(ConnectionErrorKind.InvalidConfig, results.CollectionToString(i => i.ErrorMessage))); return result; }