Пример #1
0
 public static void PasteTo(IEntityFilter filter)
 {
     if (filter != null)
     {
         filter.CopyFrom(storedSetting);
     }
 }
Пример #2
0
 public IEnumerable <TResult> Select <TResult>(Func <TEntity, TResult> selector,
                                               IEntityFilter <TEntity> filter = null,
                                               IEntitySorter <TEntity> sorter = null,
                                               IEntityLoader <TEntity> loader = null)
 {
     return(List(filter, sorter, null, null, loader).Select(selector));
 }
        public override FullTextSearchResultModel CreateResultModelByFilter(IEntityFilter filter)
        {
            var emailMessageFullTextSearchResultModel = new EmailMessageFullTextSearchResultModel();

            SetFilterTypeUid(emailMessageFullTextSearchResultModel, filter);
            return(emailMessageFullTextSearchResultModel);
        }
Пример #4
0
        private static void DrawHeadingCheckBox(IEntityFilter filter, string label, string description, ref Rect baseRect)
        {
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(baseRect.x, baseRect.y, baseRect.width, Text.LineHeight);

            Widgets.DrawHighlightIfMouseover(rect);
            if (!description.NullOrEmpty())
            {
                if (Mouse.IsOver(rect))
                {
                    GUI.DrawTexture(rect, TexUI.HighlightTex);
                }
                TooltipHandler.TipRegion(rect, description);
            }
            Text.Anchor = TextAnchor.MiddleCenter;

            Widgets.Label(rect, label);
            bool flag  = filter.IsVaild();
            bool flag2 = flag;

            Widgets.Checkbox(new Vector2(baseRect.x + rect.width - 26f, baseRect.y + 4f), ref flag);
            if (flag != flag2)
            {
                filter.SetVaild(flag);
            }
            baseRect.y += rect.height;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Пример #5
0
        protected void Awake()
        {
            _entityFilter = EntityFilter <CommercialFilterData> .Create(OnTracked, OnUntracked);

            _building1 = new Building(50);
            _building2 = new Building(75);
        }
Пример #6
0
 public static void DefaultPasteTo(IEntityFilter filter)
 {
     if (filter != null)
     {
         filter.CopyFrom(RestrictedEntityManager.defaultSettings);
     }
 }
Пример #7
0
        /// <summary>
        /// Get all entities that satisfy the given entity filter.
        /// </summary>
        /// <param name="filter">Entity filter to use</param>
        /// <returns>Collection of entities as result of filter operation</returns>
        public EntityQueryResult GetEntities(IEntityFilter filter)
        {
            var result = Result
                         .Where(x => filter.Apply(x))
                         .ToList();

            return(new EntityQueryResult(result));
        }
Пример #8
0
 /// <summary>
 /// Evaluate whether an item of the specified type has been activated optionally at the specidied location
 /// </summary>
 /// <param name="nodeId"></param>
 /// <param name="filter"></param>
 public ItemTypeIsActivated(EntityConfig entityConfig       = null,
                            ActivationState activationState = ActivationState.Active,
                            IEntityFilter <Simulation, SimulationConfiguration> filter = null)
 {
     _entityConfig    = entityConfig;
     _activationState = activationState;
     _filter          = filter;
 }
Пример #9
0
 public TripleStoreFromEnglish(IEnglishFactiodEngine englishFactiodStore, AltBot theBot, WordExpander expander)
 {
     EntityFilter        = this;
     TheBot              = theBot;
     EnglishFactiodStore = englishFactiodStore;
     WordNetExpand       = expander;
     AddDefaultExclusions();
 }
Пример #10
0
        protected void Awake()
        {
            _entityFilter = EntityFilter <HealthFilterData> .Create(new TestModule(), OnTracked, OnUntracked);

            _character  = new Character(50);
            _character2 = new Character(75);

            // Call Flush when you need the entities within the same frame, else the entities will be added to the system the next frame
            // EntityTracker.Instance.Flush();
        }
Пример #11
0
        public TEntity SingleOrDefault(IEntityFilter <TEntity> filter = null, IEntityLoader <TEntity> loader = null)
        {
            var entities = (filter ?? EntityFilter <TEntity> .AsQueryable()).Filter(Entities);

            if (loader != null)
            {
                return(loader.SingleOrDefault(entities));
            }
            return(entities.SingleOrDefault());
        }
Пример #12
0
        public TEntity First(IEntityFilter <TEntity> filter = null, IEntitySorter <TEntity> sorter = null, IEntityLoader <TEntity> loader = null)
        {
            var entities = (filter ?? EntityFilter <TEntity> .AsQueryable()).Filter(Entities);

            if (loader != null)
            {
                return(loader.First(entities));
            }
            return(entities.First());
        }
Пример #13
0
        private static void DrawDefaultSettingButton(IEntityFilter filter, ref Rect baseRect)
        {
            Text.Font = GameFont.Tiny;
            float btHeight    = 24f;
            Rect  buttonRect1 = new Rect(baseRect.x, baseRect.y - btHeight - 2f, 140f, 24f);

            if (Widgets.ButtonText(buttonRect1, "DefaultEntityListSettingsButton".Translate(), true, false, true))
            {
                RestrictedEntityManager.DefaultCopyFrom(filter);
            }
        }
Пример #14
0
        /// <summary>
        /// Returns a dictionary of key/value pairs for which request options
        /// have been added to the existing set of filters.
        /// </summary>
        /// <param name="filter">
        /// A <see cref="IEntityFilter"/> instance; an object which can be represented as a set of key/value pairs.
        /// </param>
        /// <param name="options">
        /// A <see cref="RequestOptions"/> object for controlling the behavior of API calls.
        /// </param>
        /// <returns>The dictionary of concatenated key-value pairs.</returns>
        internal static Dictionary <string, string> GetFiltersWithOptions(
            this IEntityFilter filter,
            RequestOptions options)
        {
            options.ThrowIfNull();

            Dictionary <string, string> filters        = filter.GetFilters();
            Dictionary <string, string> optionsFilters = options.GetFilters();

            return(filters.Concat(optionsFilters).ToDictionary(s => s.Key, s => s.Value));
        }
Пример #15
0
 public DbConfiguration(IDbEntityValidator validation,
                        IEntityFilter entityFilter,
                        IAggregateUpdateService aggregateUpdateService,
                        ICacheService cacheService,
                        [CanBeNull] Func <BaseDb> getDbForEvilLazyLoad)
 {
     Validator              = validation;
     EntityFilter           = entityFilter;
     AggregateUpdateService = aggregateUpdateService;
     CacheService           = cacheService;
     GetDbForEvilLazyLoad   = getDbForEvilLazyLoad;
 }
Пример #16
0
        protected IActionResult ResourcesGet <TParameters>(TParameters parameters,
                                                           IEntityFilter <TEntity> entityFilter,
                                                           IEntitySearch <TEntity> entitySearch) where TParameters : class
        {
            if (!typeof(TDto).TypeHasOutputProperties(CollectionConfig.Shape))
            {
                return(BadRequest("Shape has one or more invalid field names."));
            }

            var orderByCheck = _orderByPropertyMappingService
                               .ClauseIsValid(CollectionConfig.OrderBy);

            if (!orderByCheck.Valid)
            {
                orderByCheck.Details.Instance = Url.Link(HateoasConfig.ResourcesGetRouteName, parameters);
                return(BadRequest(orderByCheck.Details));
            }

            var orderByMappings = _orderByPropertyMappingService.PropertyMapping();

            var pagedEntities = _restResourceRepository
                                .Load(
                CollectionConfig.Page,
                CollectionConfig.PageSize,
                entityFilter,
                entitySearch,
                CollectionConfig.SearchText,
                CollectionConfig.OrderBy,
                orderByMappings);

            AddPaginationHeader(HateoasConfig.ResourcesGetRouteName, pagedEntities);

            var resources = Mapper.Map <IEnumerable <TDto> >(pagedEntities)
                            .ShapeData(CollectionConfig.Shape).ToList();

            if (HateoasConfig.AddLinks)
            {
                AddHateoasLinksToResourceCollection(resources);
            }

            if (HateoasConfig.AddLinks)
            {
                var collectionLinks = ResourcesGetLinks(parameters, pagedEntities);

                var expandoObject = new { value = resources }.ShapeData("");
                expandoObject.TryAdd(HateoasConfig.LinksPropertyName, collectionLinks);

                return(Ok(expandoObject));
            }

            return(Ok(resources));
        }
Пример #17
0
        private static Gizmo PasteGizmo(IEntityFilter filter)
        {
            Command_Action pasteGizmo = new Command_Action();

            pasteGizmo.icon             = pasteGizmoIcon;
            pasteGizmo.action           = () => CopyPasteRestrictionSetting.PasteTo(filter);
            pasteGizmo.defaultIconColor = Color.white;
            pasteGizmo.defaultLabel     = "PasteRestrictionLabel".Translate();
            pasteGizmo.defaultDesc      = "PasteRestrictionDesc".Translate();
            pasteGizmo.groupKey         = gizmoGroupKey + 1;

            return(pasteGizmo);
        }
Пример #18
0
        private static Gizmo CopyGizmo(IEntityFilter filter)
        {
            Command_Action copyGizmo = new Command_Action();

            copyGizmo.icon             = copyGizmoIcon;
            copyGizmo.action           = () => CopyPasteRestrictionSetting.CopyFrom(filter);
            copyGizmo.defaultIconColor = Color.white;
            copyGizmo.defaultLabel     = "CopyRestrictionLabel".Translate();
            copyGizmo.defaultDesc      = "CopyRestrictionDesc".Translate();
            copyGizmo.groupKey         = gizmoGroupKey;

            return(copyGizmo);
        }
Пример #19
0
        /// <summary>
        ///     Returns a <see cref="IEntityFilter{TEntity}" /> that filters a sequence based on a predicate.
        /// </summary>
        /// <typeparam name="TEntity">
        ///     The type of the entity.
        /// </typeparam>
        /// <param name="baseFilter">
        ///     The base filter.
        /// </param>
        /// <param name="predicate">
        ///     The predicate.
        /// </param>
        /// <returns>
        ///     A new <see cref="IEntityFilter{TEntity}" />.
        /// </returns>
        public static IEntityFilter <TEntity> Where <TEntity>(
            this IEntityFilter <TEntity> baseFilter, Expression <Func <TEntity, bool> > predicate)
        {
            if (baseFilter == null)
            {
                throw new ArgumentNullException("baseFilter");
            }

            if (predicate == null)
            {
                throw new ArgumentNullException("predicate");
            }

            return(new WhereEntityFilter <TEntity>(baseFilter, predicate));
        }
        public override List <string> GetSearchFields(Type cardType, IEntityFilter filter)
        {
            if (cardType == null || typeof(IEmailMessageFullTextSearchObject) != cardType)
            {
                return(new List <string>());
            }
            var searchFields = base.GetSearchFields(cardType);

            searchFields.AddRange(new List <string>
            {
                LinqUtils.NameOf((IEmailMessageFullTextSearchObject d) => d.Subject),
                LinqUtils.NameOf((IEmailMessageFullTextSearchObject d) => d.Text)
            });

            return(searchFields);
        }
Пример #21
0
        public static MvcHtmlString FilterOptionLink(
            this HtmlHelper htmlHelper,
            Entity entity,
            IEntityFilter currentFilter,
            SelectListItem option,
            IEnumerable <IEntityFilter> filters,
            string searchQuery,
            string order,
            string orderDirection,
            int perPage)
        {
            var routeValues = new Dictionary <string, object>
            {
                { "area", "IlaroAdmin" },
                { "entityName", entity.Name },
                { "pp", perPage }
            };

            if (!searchQuery.IsNullOrEmpty())
            {
                routeValues.Add("sq", searchQuery);
            }
            if (!order.IsNullOrEmpty() && !orderDirection.IsNullOrEmpty())
            {
                routeValues.Add("o", order);
                routeValues.Add("od", orderDirection);
            }
            var activeFilters = filters.Where(x => !x.Value.IsNullOrEmpty()).ToList();

            activeFilters.Remove(currentFilter);
            foreach (var filter in activeFilters)
            {
                routeValues.Add(filter.Property.Name, filter.Value);
            }

            if (!option.Value.IsNullOrEmpty())
            {
                routeValues.Add(currentFilter.Property.Name, option.Value);
            }

            return(htmlHelper.ActionLink(
                       option.Text,
                       "Index",
                       "Entities",
                       new RouteValueDictionary(routeValues),
                       null));
        }
Пример #22
0
        public static MvcHtmlString GetFilterIcon(this HtmlHelper htmlHelper, IEntityFilter filter)
        {
            if (filter is BoolEntityFilter)
            {
                return(MvcHtmlString.Create("<i class=\"icon-check\"></i>"));
            }
            else if (filter is EnumEntityFilter)
            {
                return(MvcHtmlString.Create("<i class=\"icon-list\"></i>"));
            }
            else if (filter is DateTimeEntityFilter)
            {
                return(MvcHtmlString.Create("<i class=\"icon-calendar\"></i>"));
            }

            return(null);
        }
Пример #23
0
        public static void DrawEntityListWindow(IEntityFilter filter, EntityCategory root, string label, string description, Rect baseRect, ref Vector2 scrollPosition, int count)
        {
            Widgets.DrawMenuSection(baseRect, true);

            TabRestrictUI.DrawDefaultSettingButton(filter, ref baseRect);
            TabRestrictUI.DrawHeadingCheckBox(filter, label, description, ref baseRect);

            Text.Font = GameFont.Tiny;

            float num         = baseRect.width - 2f;
            Rect  buttonRect1 = new Rect(baseRect.x + 1f, baseRect.y + 1f, num / 2f, 24f);

            if (Widgets.ButtonText(buttonRect1, "ClearAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(root, false);
            }
            Rect buttonRect2 = new Rect(buttonRect1.xMax + 1f, buttonRect1.y, baseRect.xMax - 1f - (buttonRect1.xMax + 1f), 24f);

            if (Widgets.ButtonText(buttonRect2, "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(root);
            }
            baseRect.yMin = buttonRect1.yMax;

            Text.Font = GameFont.Small;

            Rect viewRect = new Rect(0f, 0f, baseRect.width - 16f, TabRestrictUI.viewHeight[count]);

            Widgets.BeginScrollView(baseRect, ref scrollPosition, viewRect, true);
            float num2     = 2f;
            float num3     = num2;
            Rect  listRect = new Rect(0f, num2, viewRect.width, 9999f);

            Listing_EntityListUI entityListUI = new Listing_EntityListUI(filter);

            entityListUI.Begin(listRect);
            entityListUI.CreateCheckBoxUI(root, 8, 0);
            entityListUI.End();

            if (Event.current.type == EventType.Layout)
            {
                TabRestrictUI.viewHeight[count] = num3 + entityListUI.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
 public void CopyFrom(IEntityFilter from)
 {
     if (from == null)
     {
         return;
     }
     this.vaild = from.IsVaild();
     this.allowedEntityList.Clear();
     foreach (var a in from.GetAllowedEntityList())
     {
         this.allowedEntityList.Add(a);
     }
     this.forbiddenSpFilterList.Clear();
     foreach (var a in from.GetforbiddenSpFilterList())
     {
         this.forbiddenSpFilterList.Add(a);
     }
 }
Пример #25
0
        public IList <TEntity> List(IEntityFilter <TEntity> filter = null,
                                    IEntitySorter <TEntity> sorter = null,
                                    int?page     = null,
                                    int?pageSize = null,
                                    IEntityLoader <TEntity> loader = null)
        {
            if ((page.HasValue || pageSize.HasValue) && sorter == null)
            {
                throw new ArgumentException("You have to define a sorting order if you specify a page or pageSize! (IEntitySorter was null)");
            }

            if (page.HasValue && !pageSize.HasValue)
            {
                throw new ArgumentException("You have to define a pageSize if you specify a page!");
            }

            var entities = Entities;

            if (filter != null)
            {
                entities = filter.Filter(entities);
            }
            if (sorter != null)
            {
                entities = sorter.Sort(entities);
            }
            if (page != null)
            {
                entities = entities.Skip(pageSize.Value * page.Value);
            }
            if (pageSize != null)
            {
                entities = entities.Take(pageSize.Value);
            }
            entities = entities.InterceptWith(new QueryableEntitiesVisitor());
            if (loader != null)
            {
                return(loader.Load(entities));
            }
            return(entities.ToList());
        }
Пример #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="indexDir"></param>
        /// <param name="fieldName">usually "TEXT_MATTER"</param>
        public MyLuceneIndexer(string indexDir, string fieldName, AltBot myBot, WordNetEngine myWNEngine)
        {
            SearchSources = new List <IDocSearch>()
            {
                this
            };
            _indexDir     = indexDir;
            _fieldName    = fieldName;
            TheBot        = myBot;
            wordNetEngine = myWNEngine;
            IEnglishFactiodEngine assertTo = this;

            SearchSources.Add(new TrueKnowledgeFactiodEngine(assertTo, TheBot));
            SearchSources.Add(new AskDotComFactiodEngine(assertTo, TheBot));
            SearchSources.Add(new WikiAnswersFactoidEngine(assertTo, TheBot));
            TheBot.AddExcuteHandler("asklucene", AskTextStringJustHere);
            TheBot.AddExcuteHandler("askall", AskTextStringAll);
            //WNUser2Cache();

            //_path = new System.IO.FileInfo(indexDir);
            //_directory = new RAMDirectory();
            _analyzer = new StandardAnalyzer();
            try
            {
                InitDatabase();
            }
            catch (Exception e)
            {
                writeToLog("ERROR {0}", e);
                IsDbPresent = false;
                if (_directory == null)
                {
                    // in ram because of disk error?!
                    _directory = new RAMDirectory();
                }
            }
            TripleStoreProxy = new TripleStoreFromEnglish(this, TheBot, WordNetExpand);
            EntityFilter     = TripleStoreProxy.EntityFilter;
        }
Пример #27
0
        public static void AddConfiguration(
            string entityNameSpace,
            IDbEntityValidator validation = null,
            IEntityFilter entityFilter    = null,
            IAggregateUpdateService aggregateUpdateService = null,
            ICacheService cacheService         = null,
            Func <BaseDb> getDbForEvilLazyLoad = null)
        {
            if (configurationByEntityNamespace.ContainsKey(entityNameSpace))
            {
                throw new InvalidOperationException($"There is already a configuration for '{entityNameSpace}' Changing the configuration is not allowed");
            }

            var configuration = new DbConfiguration(
                validation: validation ?? EmptyValidator.Instance,
                entityFilter: entityFilter ?? EmptyEntityFilter.Instance,
                aggregateUpdateService: aggregateUpdateService ?? EmptyAggregateUpdateService.Instance,
                cacheService: cacheService ?? NullCacheService.Instance,
                getDbForEvilLazyLoad: getDbForEvilLazyLoad
                );

            configurationByEntityNamespace[entityNameSpace] = configuration;
        }
Пример #28
0
 public FilteredSystem(IEntityFilter filter = null)
 {
     Filter = filter;
 }
Пример #29
0
 public Listing_EntityListUI(IEntityFilter filter)
 {
     this.filter = filter;
 }
Пример #30
0
 public static void DefaultCopyFrom(IEntityFilter filter)
 {
     RestrictedEntityManager.defaultSettings.CopyFrom(filter);
 }
Пример #31
0
 public void PopulateFromJson(JObject jsonObject)
 {
     m_filter = IEntityFilterUtils.FromJsonProperty(jsonObject, "filter");
 }