private void InitObjects(IContainer container) { _server = (McServer)container.Resolve<IServer>(); _config = container.Resolve<IMcManageConfig>(); _config.Load("config.ini",Properties.Resources.defaultconfig); _coreMap = container.Resolve<FilterMap>(); }
// tag::validateFilterMap[] private void ValidateFilterMap(FilterMap filterMap) { // Validate the proposed filter mapping string filterName = filterMap.GetFilterName(); string[] servletNames = filterMap.GetServletNames(); string[] urlPatterns = filterMap.GetURLPatterns(); if (FindFilterDef(filterName) == null) throw new Exception( sm.GetString("standardContext.filterMap.name", filterName)); if (!filterMap.GetMatchAllServletNames() && !filterMap.GetMatchAllUrlPatterns() && (servletNames.Length == 0) && (urlPatterns.Length == 0)) throw new Exception( sm.GetString("standardContext.filterMap.either")); // FIXME: Older spec revisions may still check this /* if ((servletNames.length != 0) && (urlPatterns.length != 0)) throw new IllegalArgumentException (sm.getString("standardContext.filterMap.either")); */ for (int i = 0; i < urlPatterns.Length; i++) { if (!ValidateURLPattern(urlPatterns[i])) { throw new Exception( sm.GetString("standardContext.filterMap.pattern", urlPatterns[i])); } } }
/// <summary> /// Return an indicative size for memory consumption of this class to be used in cache tracking /// </summary> public virtual int IndicativeSizeInBytes() { var filterMapSize = FilterMap?.IndicativeSizeInBytes() ?? 0; var prodDataMapSize = ProdDataMap?.IndicativeSizeInBytes() ?? 0; return(filterMapSize + prodDataMapSize); }
/// <exception cref="System.Exception"/> protected internal virtual void StartTomcat() { tomcat = new Tomcat(); FilePath @base = new FilePath(Runtime.GetProperty("java.io.tmpdir")); Context ctx = tomcat.AddContext("/foo", @base.GetAbsolutePath()); FilterDef fd = new FilterDef(); fd.SetFilterClass(typeof(AuthenticatorTestCase.TestFilter).FullName); fd.SetFilterName("TestFilter"); FilterMap fm = new FilterMap(); fm.SetFilterName("TestFilter"); fm.AddURLPattern("/*"); fm.AddServletName("/bar"); ctx.AddFilterDef(fd); ctx.AddFilterMap(fm); Tomcat.AddServlet(ctx, "/bar", typeof(AuthenticatorTestCase.TestServlet).FullName ); ctx.AddServletMapping("/bar", "/bar"); host = "localhost"; port = GetLocalPort(); tomcat.SetHostname(host); tomcat.SetPort(port); tomcat.Start(); }
/// <summary> /// 获取或新增属性映射 /// </summary> /// <param name="type">filter类型</param> /// <returns></returns> private List <FilterMap> GetOrAddMap(Type type) { if (!_cache.TryGetValue(type, out List <FilterMap> mapList)) { PropertyInfo[] properties = type.GetProperties(BindFlags); FilterMap map = null; mapList = new List <FilterMap>(); foreach (PropertyInfo prop in properties) { PropFilterAttribute attr = prop.GetCustomAttribute <PropFilterAttribute>(); if (attr == null) { continue; } map = new FilterMap { FieldName = (string.IsNullOrWhiteSpace(attr.FieldName) ? prop.Name : attr.FieldName).Split(',').ToList(), Operator = attr.Operator, IgnoreCase = attr.IgnoreCase, PInfo = prop }; mapList.Add(map); } _cache.TryAdd(type, mapList); } return(mapList); }
/// <summary> /// Write the contents of the Items array using the supplied writer /// </summary> public override void Write(BinaryWriter writer) { base.Write(writer); writer.Write((int)GridDataType); writer.Write(CellSize); writer.Write(IndexOriginOffset); ProdDataMap.Write(writer); FilterMap.Write(writer); }
public PullSubscriptionClientImpl(Uri endpointUri, Binding binding, FilterMap filterMap, EnumerationContextKey context, string resourceUri, //IChannelFactory<IWSEnumerationContract> enumerationProxyFactory, IChannelFactory <IWSEventingContract> eventingProxyFactory) { _endpointUri = endpointUri; _resourceUri = resourceUri; _eventingProxyFactory = eventingProxyFactory; _context = context; _filterMap = filterMap; _binding = binding; _enumerationProxyFactory = new ChannelFactory <IWSEventingPullDeliveryContract>(binding); }
/// <summary> /// Assigns the state of one client leaf sub grid to this client leaf sub grid /// Note: The cell values are explicitly NOT copied in this operation /// </summary> public void Assign(IClientLeafSubGrid source) { level = source.Level; originX = source.OriginX; originY = source.OriginY; // Grid data type is never assigned from one client grid to another... //GridDataType = source.GridDataType; CellSize = source.CellSize; IndexOriginOffset = source.IndexOriginOffset; ProdDataMap.Assign(source.ProdDataMap); FilterMap.Assign(source.FilterMap); }
/// <summary> /// Fill the items array by reading the binary representation using the provided reader. /// </summary> /// <param name="reader"></param> public override void Read(BinaryReader reader) { base.Read(reader); if ((GridDataType)reader.ReadInt32() != GridDataType) { throw new TRexSubGridIOException("GridDataType in stream does not match GridDataType of local sub grid instance"); } CellSize = reader.ReadDouble(); IndexOriginOffset = reader.ReadInt32(); ProdDataMap.Read(reader); FilterMap.Read(reader); }
public static Definition GetInstance(DefinitionConfig configuration, FilterMap coreFilterMap, FilterMap pluginFilterMap) { var def = new Definition(); if (configuration.Items.ContainsKey(CORESECTION)) def._filters.AddRange(configuration.Items[CORESECTION].Select(item => new Filter(item.Key, item.Value, new List<IFilterResult>{coreFilterMap.Get(item.Key)}))); if (configuration.Items.ContainsKey(PLUGINSECTION)) def._filters.AddRange(configuration.Items[PLUGINSECTION].Select(item => new Filter(item.Key, item.Value, new List<IFilterResult>{pluginFilterMap.Get(item.Key)}))); if (configuration.Items.ContainsKey(USERSECTION)) def._filters.AddRange(configuration.Items[USERSECTION].Select(item => new Filter(item.Key, item.Value, new List<IFilterResult>{new EmptyResult()}))); def.Version = configuration.GetValue("version", INFOSECTION); def.ModRequired = Convert.ToBoolean(configuration.GetValue("mod_required", INFOSECTION)); def.Label = configuration.GetValue("label", INFOSECTION); def.FullName = string.Format("{0}{1}", !string.IsNullOrWhiteSpace(def.Label) ? def.Label + " " : "", def.Version); return def; }
// Save movie model changes and filter changes private async void buttonSave_Click(object sender, RoutedEventArgs e) { await showLoading(); await Task.Factory.StartNew(async() => { var movies = MovieMap.MapToMovieList(movieViewModels); await movieService.UpdateAllMovieAsync(movies).ContinueWith(moviesResult => { socketServer.CloseClientConnection("Kapcsolat bezárása..."); // Start Socket Server after new movies socketServer.StartServer(settingViewModel); }); var filter = FilterMap.MapFilterViewModelToFilter(filterViewModel); await filterService.UpdateFilterAsync(filter); await hideLoading(); }); }
// tag::validateFilterMap[] private void ValidateFilterMap(FilterMap filterMap) { // Validate the proposed filter mapping string filterName = filterMap.GetFilterName(); string[] servletNames = filterMap.GetServletNames(); string[] urlPatterns = filterMap.GetURLPatterns(); if (FindFilterDef(filterName) == null) { throw new Exception( sm.GetString("standardContext.filterMap.name", filterName)); } if (!filterMap.GetMatchAllServletNames() && !filterMap.GetMatchAllUrlPatterns() && (servletNames.Length == 0) && (urlPatterns.Length == 0)) { throw new Exception( sm.GetString("standardContext.filterMap.either")); } // FIXME: Older spec revisions may still check this /* * if ((servletNames.length != 0) && (urlPatterns.length != 0)) * throw new IllegalArgumentException * (sm.getString("standardContext.filterMap.either")); */ for (int i = 0; i < urlPatterns.Length; i++) { if (!ValidateURLPattern(urlPatterns[i])) { throw new Exception( sm.GetString("standardContext.filterMap.pattern", urlPatterns[i])); } } }
protected void AddFilter(U grp) { FilterMap.Add(grp.SearchType, grp); }
private async Task <ObservableCollection <MovieViewModel> > setViewModel() { // We just update Setting and Filter models, no delete - no insert var setting = await settingService.GetSettingByIdAsync(1); var filter = await filterService.GetFilterByIdAsync(1); // FileSizes - FileTypes var fileSizes = await fileSizeService.GetFileSizesAsync(); var fileTypes = await fileTypeService.GetFileTypesAsync(); // Get viewmodels this.Dispatcher.Invoke(() => { settingViewModel = SettingMap.MapToSettingViewModel(setting); filterViewModel = FilterMap.MapToFilterViewModel(filter); filterViewModel.FileTypeViewModels = FileTypeMap.MapToFileTypeViewModelList(fileTypes); filterViewModel.FileSizeViewModels = FileSizeMap.MapToFileSizeViewModelList(fileSizes); dockPanelFilter.DataContext = filterViewModel; } ); // Show message if MoviesPath is not set if (!Directory.Exists(settingViewModel.MoviesPath)) { this.Dispatcher.Invoke(() => { MessageBoxResult result = ModernDialog.ShowMessage("A(z) '" + settingViewModel.MoviesPath + "' mappa nem létezik, így nem lehet filmeket keresni! Szeretnéd megváltoztatni most?", "'Filmek' mappa nem létezik", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { IInputElement target = NavigationHelper.FindFrame("_top", this); NavigationCommands.GoToPage.Execute("/Views/Content/SettingServer.xaml", target); } else { IInputElement target = NavigationHelper.FindFrame("_top", this); LinkCommands.NavigateLink.Execute("/Views/Pages/Introduction.xaml", target); } }); } // Get movies and set viewmodel else { // Get movies from database moviesFromDb = await movieService.GetMoviesAsync(); movieViewModels = MovieMap.MapToMovieViewModelList(moviesFromDb); await Task.Factory.StartNew(async() => { moviesFromFileServer = await MovieServer.GetMovieTitles(settingViewModel.MoviesPath, FileTypeMap.MapToFileTypeList(settingViewModel.FileTypeViewModels)); }); // We have no movies in database if (movieViewModels.Count <= 0) { await movieService.InsertAllMovieAsync(moviesFromFileServer).ContinueWith(async moviesResult => { movieViewModels = MovieMap.MapToMovieViewModelList(await moviesResult); // Start Socket Server after new movies socketServer.StartServer(settingViewModel); } ); //movieViewModels = MovieMap.MapToMovieViewModelList(insertedMovies); } else { // Delete and insert changes var deleted = moviesFromDb.Where(m => !moviesFromFileServer.Select(c => c.Title).Contains(m.Title)).ToList(); var inserted = moviesFromFileServer.Where(c => !moviesFromDb.Select(m2 => m2.Title).Contains(c.Title)).ToList(); if (deleted != null && deleted.Count > 0) { // Delete my movies await movieService.DeleteMoviesByListIdAsync(deleted.Select(d => d.Id).ToList()); } if (inserted != null && inserted.Count > 0) { // Insert my movies await movieService.InsertAllMovieAsync(inserted).ContinueWith(moviesResult => // Start Socket Server after new movies socketServer.StartServer(settingViewModel) ); } // Correct current movies what can search with TMDB moviesFromDb = await movieService.GetMoviesAsync(); movieViewModels = MovieMap.MapToMovieViewModelList(moviesFromDb); } }; return(await Task.FromResult(movieViewModels)); }