/// <summary>获取类型</summary> /// <param name="name">名称</param> /// <returns></returns> public Type GetType(String name) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } // 第一次使用时编译 if (Assembly == null) { Compile(); } if (Assembly == null) { throw new Exception("未编译!"); } var asmx = AssemblyX.Create(Assembly); if (TypeMaps.TryGetValue(name, out var typeName)) { return(asmx.GetType(typeName)); } else { return(asmx.GetType(name)); } }
/// <summary> /// Return the map for type, if not found will return a map with Type.Name in camelcase for index name and indexType and use the ElasticsearchTypeAttribute /// </summary> /// <param name="type"></param> /// <returns>The Map for type<see cref="ElasticIndexMap"/></returns> public static ElasticIndexMap GetMap(Type type) { ElasticIndexMap map = null; if (TypeMaps.TryGetValue(type, out map)) { return(map); } else { var typeNames = new List <string>(); typeNames.Add(type.Name.ToLower()); var attrs = type.GetCustomAttributes() .Where(w => w is ElasticsearchTypeAttribute) .Select(s => s as ElasticsearchTypeAttribute); if (attrs.Any()) { typeNames.AddRange(attrs.Select(s => s.Name.ToLower())); } return(new ElasticIndexMap(type.Name.ToLower(), typeNames.Distinct().ToArray())); }; }
/// <summary>获取类型</summary> /// <param name="name"></param> /// <returns></returns> public Type GetType(String name) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (Assembly == null) { throw new Exception("未编译!"); } var asmx = AssemblyX.Create(Assembly); String typeName = null; if (TypeMaps.TryGetValue(name, out typeName)) { return(asmx.GetType(typeName)); } else { return(asmx.GetType(name)); } }
private bool FindTypeMap(string name, out TypeMap typeMap) { return(TypeMaps.TryGetValue(name, out typeMap) && typeMap.IsEnabled); }
internal ShipOverviewViewModel() { TypeMaps = KanColleGame.Current.MasterInfo.ShipTypes.Values.Where(r => r.ID != 12 && r.ID != 15).ToDictionary(IdentityFunction <ShipTypeInfo> .Instance, r => new FilterTypeViewModel <ShipTypeInfo>(r)); Types = TypeMaps.Values.ToArray(); r_Ships = new ShipCollectionView(this); Ships = r_Ships; var rSelectedTypes = Preference.Instance.Game.SelectedShipTypes.Value; if (rSelectedTypes != null) { foreach (var rID in rSelectedTypes) { ShipTypeInfo rShipType; FilterTypeViewModel <ShipTypeInfo> rTypeVM; if (KanColleGame.Current.MasterInfo.ShipTypes.TryGetValue(rID, out rShipType) && TypeMaps.TryGetValue(rShipType, out rTypeVM)) { rTypeVM.IsSelected = true; } } } r_UpdateSubscription = r_UpdateObservable .Do(_ => IsLoading = true) .Throttle(TimeSpan.FromSeconds(.5)) .Do(_ => r_Ships.Refresh()) .Do(_ => IsLoading = false) .Subscribe(); UpdateSelectionCore(); r_HomeportSubscription = ApiService.Subscribe("api_port/port", _ => Refresh()); }