public object ComputeFieldValue(IIndexable indexable)
 {
     Item i = indexable as SitecoreIndexableItem;
     if (i?.Visualization.Layout != null)
         return true;
     return null;
 }
    public virtual object ComputeFieldValue(IIndexable indexable)
    {
      var item = (Item)(indexable as SitecoreIndexableItem);
      if (item == null)
      {
        return null;
      }

      if (!this.ShouldIndexItem(item))
      {
        return null;
      }

      var dataSources = item.GetLocalDatasourceDependencies();

      var result = new StringBuilder();
      foreach (var dataSource in dataSources)
      {
        dataSource.Fields.ReadAll();
        foreach (var field in dataSource.Fields.Where(this.ShouldIndexField))
        {
          result.AppendLine(field.Value);
        }
      }

      return result.ToString();
    }
        public object ComputeFieldValue(IIndexable indexable)
        {
            var indexItem = indexable as SitecoreIndexableItem;
            if (indexItem == null)
            {
                return null;
            }
            var item = (Sitecore.Data.Items.Item)indexItem.Item;
            if (item == null || item.Template == null)
            {
                return null;
            }

            if (!item.InheritsTemplate(BaseEventDetailPageItem.TemplateId))
            {
                return null;
            }

            BaseEventDetailPageItem eventPage = item;

            switch (FieldName)
            {
                case Constants.SolrFields.EventStartDateUtc:
                    return eventPage.GetEventStartDateUtc() ?? DateTime.MinValue;
                case Constants.SolrFields.EventEndDateUtc:
                    return eventPage.GetEventEndDateUtc() ?? DateTime.MinValue;
            }

            return null;
        }
Пример #4
0
 public BasicBlockUtil(StringBuilder log, MethodBodyEx body, IIndexable<int> basicBlockStartOffsets)
 {
     Log = log;
     this.body = body;
     _basicBlockStartOffsets = basicBlockStartOffsets;
     PrintInstructions(body);
 }
        public object ComputeFieldValue(IIndexable indexable)
        {
            var item = (Item)(indexable as SitecoreIndexableItem);
            Assert.ArgumentNotNull(item, "item");

            if (!ShouldIndexItem(item))
            {
                return null;
            }
            List<Item> dataSources = Globals.LinkDatabase.GetReferences(item)
                                           .Where(link => ShouldProcessLink(link, item))
                                           .Select(link => link.GetTargetItem())
                                           .Where(targetItem => targetItem != null)
                                           .Distinct().ToList();
            dataSources.Add(item);

            var result = new StringBuilder();
            foreach (var dataSource in dataSources.Where(ShouldIndexDataSource))
            {
                dataSource.Fields.ReadAll();
                foreach (var field in dataSource.Fields.Where(ShouldIndexField))
                {
                    result.AppendLine(IndexOperationsHelper.StripHtml(field.Value));;
                }
            }
            return result.ToString();
        }
        public object ComputeFieldValue(IIndexable indexable)
        {
            var indexItem = indexable as SitecoreIndexableItem;
            if (indexItem == null)
            {
                return null;
            }
            var item = (Sitecore.Data.Items.Item)indexItem.Item;
            if (item == null || item.Template == null)
            {
                return null;
            }

            if (!item.InheritsTemplate(AssistiveToolsReviewPageItem.TemplateId))
            {
                return null;
            }

            AssistiveToolsReviewPageItem toolPage = item;

            double offGrade = GetGradeValue(toolPage.OffGrade);
            double targetGrade = GetGradeValue(toolPage.TargetGrade);
            double onGrade = GetGradeValue(toolPage.OnGrade);

            double offGradeMultiplier = GetMultiplierConfigValue(Constants.Settings.GradeLevelOffMultiplier);
            double targetGradeMultipler = GetMultiplierConfigValue(Constants.Settings.GradeLevelTargetMultiplier);
            double onGradeMultiplier = GetMultiplierConfigValue(Constants.Settings.GradeLevelOnMultiplier);

            return (offGrade * offGradeMultiplier) + (targetGrade * targetGradeMultipler) + (onGrade * onGradeMultiplier);
        }
        public object ComputeFieldValue(IIndexable indexable)
        {
            Item i = ((Item)(indexable as SitecoreIndexableItem));
              if (i != null && i["__Tracking"] != String.Empty)
              {
            TrackingField field = new TrackingField(i.Fields["__Tracking"]);
            ContentProfile[] profiles = field.Profiles;

            List<ID> presets = new List<ID>();
            foreach (ContentProfile profile in profiles)
            {
              if (profile.Presets != null)
              {
            foreach (var a in profile.Presets)
            {
              foreach (Item card in profile.GetProfileItem().Axes.GetDescendants())
              {
                if (card.Key == a.Key && card.Template.Key.StartsWith("profile card"))
                  presets.Add(card.ID);
              }
            }
              }
            }
            return presets;
              }
              return string.Empty;
        }
 public object ComputeFieldValue(IIndexable indexable)
 {
     Item item = indexable as SitecoreIndexableItem;
     if (item == null)
         return null;
     if (!String.IsNullOrEmpty(item["Runtime"]))
     {
         int length = 0;
         if (Int32.TryParse(item["Runtime"], out length))
         {
             if (length < 60)
                 return "0-59";
             if (length <= 60 && length < 120)
                 return "60-119";
             if (length <= 120 && length < 180)
                 return "120-178";
             if (length <= 180 && length < 240)
                 return "180-239";
             return "240+";
         }
         else
         {
             return "";
         }
     }
     return null;
 }
 /// <summary>
 /// Check and convert 
 /// </summary>
 /// <param name="indexable"></param>
 /// <returns></returns>
 private Item CheckItemIsValid(IIndexable indexable)
 {
     var scIndexable = (SitecoreIndexableItem) indexable;
     if (scIndexable == null) return null;
     var item = (Item) scIndexable;
     return item ?? null;
 }
Пример #10
0
        public object ComputeFieldValue(IIndexable indexable)
        {
            var item = (Item)(indexable as SitecoreIndexableItem);
            var isStandardValues = StandardValuesManager.IsStandardValuesHolder(item);

            return isStandardValues;
        }
Пример #11
0
        public object ComputeFieldValue(IIndexable indexable)
        {
            var item = (SitecoreIndexableItem) indexable;

            if (item != null && item.Item != null)
            {
                Field field = item.Item.Fields["{CFD2712F-8BF9-4023-AB94-59871A9C974E}"];

                if (field == null)
                {
                    return false;
                }

                if (field.TypeKey != "image")
                {
                    return null;
                }

                ImageField imgField = field;

                if (!imgField.MediaID.IsNull)
                {
                    if (item.Item.Database.GetItem(imgField.MediaID) != null)
                    {
                        return true;
                    }
                }

                return false;
            }

            return false;
        }
    public void ShouldGetFreeProducts(
      SearchRepository sut,
      ISearchIndex searchIndex,
      IIndexable indexable,
      [Frozen]SearchProvider provider,
      Switcher<SearchProvider> switcher)
    {
      // arrange
      searchIndex
        .CreateSearchContext()
        .GetQueryable<ProductSearchResultItem>()
        .Returns(new[]
          {
            new ProductSearchResultItem { Free = true },
            new ProductSearchResultItem { Free = false },
            new ProductSearchResultItem { Free = true }
          }.AsQueryable());

      ContentSearchManager.SearchConfiguration.Indexes["indexName"] = searchIndex;
      provider.GetContextIndexName(indexable, Arg.Any<ICorePipeline>()).Returns("indexName");

      // act
      var products = sut.GetProducts(indexable);

      // assert
      Assert.Equal(2, products.Count());
    }
 public LuceneSpatialDocumentBuilder(IIndexable indexable, IProviderUpdateContext context)
     : base(indexable, context)
 {
     if (spatialConfigurations == null)
     {
         BuildSettings();
     }
 }
        public object ComputeFieldValue(IIndexable indexable)
        {
            string renderedField;

            Item obj = (Item)(indexable as SitecoreIndexableItem);

            return obj.Language.CultureInfo.Name.Replace("-", String.Empty);
        }
        public object ComputeFieldValue(IIndexable indexable)
        {
            var item = (Item)(indexable as SitecoreIndexableItem);

            if (item == null)
                return null;

            return Guid.NewGuid();
        }
Пример #16
0
 public static void Insert(IList list, int index, IIndexable item)
 {
     item.Index = index;
     for (int i = index; i < list.Count - 1; i++)
     {
         list[i].As<IIndexable>().Index++;
     }
     list.Insert(index, item);
 }
        public object ComputeFieldValue(IIndexable indexable)
        {
            var indexItem = indexable as SitecoreIndexableItem;
            if (indexItem == null)
            {
                return null;
            }
            var item = (Sitecore.Data.Items.Item)indexItem.Item;
            if (item == null)
            {
                return null;
            }

            // Skip non-articles
            if (!item.InheritsTemplate(DefaultArticlePageItem.TemplateId))
            {
                return null;
            }

            var article = new DefaultArticlePageItem(item);
            bool fieldMatch = true;
            CustomTreeListField target = null;

            // Only index the following fields
            switch (FieldName)
            {
                case UnderstoodDotOrg.Common.Constants.SolrFields.ChildDiagnoses:
                    target = article.ChildDiagnoses;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.ChildGrades:
                    target = article.ChildGrades;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.ChildIssues:
                    target = article.ChildIssues;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.ApplicableEvaluations:
                    target = article.OtherApplicableEvaluations;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.DiagnosedConditions:
                    target = article.DiagnosedCondition;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.ImportanceLevels:
                    target = article.ImportanceLevel;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.OverrideTypes:
                    target = article.OverrideType;
                    break;
                case UnderstoodDotOrg.Common.Constants.SolrFields.ParentInterests:
                    target = article.ApplicableInterests;
                    break;
                default:
                    fieldMatch = false;
                    break;
            }

            return fieldMatch ? GetSelectedItems(target) : null;
        }
 public object ComputeFieldValue(IIndexable indexable)
 {
   Item i = indexable as SitecoreIndexableItem;
   if (i.HasLayout())
   {
     return true;
   }
   return null;
 }
Пример #19
0
 public static CardInstance[] MapToCards(this List<int> cardGuidArray, IIndexable<CardInstance> candidates)
 {
     var cardArray = new CardInstance[cardGuidArray.Count];
     for (int i = 0; i < cardGuidArray.Count; ++i)
     {
         cardArray[i] = candidates.Find(cardGuidArray[i]);
     }
     return cardArray;
 }
Пример #20
0
        public CardFactory(string xml)
        {
            using (XmlReader xr = XmlReader.Create(xml))
            {
                m_cards = IntermediateSerializer.Deserialize<CardModelList>(xr, Path.GetDirectoryName(xml));
            }

            CardModels = m_cards.Cast<ICardModel>().ToArray().ToIndexable();
        }
 public IndexData(ISearchIndex index, IIndexable indexable, Document document, ConcurrentQueue<AzureField> fields)
 {
     this.Document = document;
     this.Fields = fields;
     this.AzureIndex = (IAzureProviderIndex)index;
     
     this.UpdateTerm = new AzureField("s_key", index.Configuration.IndexFieldStorageValueFormatter.FormatValueForIndexStorage(indexable.UniqueId.Value, "s_key"), BuildKeyField("s_key"));
     this.FullUpdateTerm = new AzureField("s_uniqueid", index.Configuration.IndexFieldStorageValueFormatter.FormatValueForIndexStorage(indexable.UniqueId.Value, "s_uniqueid"), AzureFieldBuilder.BuildField("s_uniqueid", index.Configuration.IndexFieldStorageValueFormatter.FormatValueForIndexStorage(indexable.UniqueId.Value, "s_uniqueid"), this.AzureIndex));
     this.Culture = indexable.Culture;
 }
        public void Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
        {
            //if (doc == null)
            //{
            //    Event.RaiseEvent("indexing:excludedfromindex", new object[] { _index.Name, indexable.Id });
            //    return;
            //}

            //context.AddDocument(doc, null);
        }
 public void ShouldReturnCurrentName(
   [Frozen] SearchProvider current,
   Switcher<SearchProvider> switcher,
   IIndexable indexable,
   string expected,
   SwitchingSearchProvider sut)
 {
   current.GetContextIndexName(indexable).Returns(expected);
   sut.GetContextIndexName(indexable).Should().Be(expected);
 }
Пример #24
0
        internal Zones(IIndexable<ZoneConfig> zoneConfigs, Player owner)
        {
            Debug.Assert(m_zones == null);

            m_zones = new Zone[zoneConfigs.Count];
            for (int i = 0; i < zoneConfigs.Count; ++i)
            {
                m_zones[i] = new Zone(owner, zoneConfigs[i].Id, zoneConfigs[i].Type, zoneConfigs[i].Visibility);
            }
        }
 public string GetItem(IIndexable indexable)
 {
     if (InboundIndexFilterPipeline.Run(new InboundIndexFilterArgs(indexable)))
     {
         return null;
     }
     else
     {
         return "";
     }
 }
Пример #26
0
        /// <summary>
        /// Convert an Indexable item to a solr document
        /// </summary>
        /// <param name="item">the object to index</param>
        /// <returns></returns>
        public static XElement ConvertToSolrDocument(IIndexable item)
        {
            var doc = new XElement("doc");

            foreach (var field in item.GetIndexableFields())
            {
                doc.Add(new XElement("field", new XAttribute("name", field.Key), field.Value.Replace("<", " ")));
            }

            return doc;
        }
Пример #27
0
        public object ComputeFieldValue(IIndexable indexable)
        {
            var item = (Item)(indexable as SitecoreIndexableItem);
            Assert.ArgumentNotNull(item, "item");

            if (item.Visualization != null && item.Visualization.Layout != null && !item.Paths.LongID.Contains(ItemIDs.TemplateRoot.ToString()))
            {
                return true;
            }
            return null;
        }
      public virtual IEnumerable<ProductSearchResultItem> GetProducts(IIndexable item)
      {
        using (var context = ContentSearchManager.CreateSearchContext(item))
        {
          var query = context.GetQueryable<ProductSearchResultItem>();

          var products = query.Where(searchResultItem => searchResultItem.Free);

          return products.ToList();
        }
      }
    public object ComputeFieldValue(IIndexable indexable)
    {
      var indexItem = indexable as SitecoreIndexableItem;
      if (indexItem == null)
      {
        return null;
      }
      var item = indexItem.Item;

      return IndexingProviderRepository.SearchResultFormatters.Any(p => p.ContentType != null && p.SupportedTemplates.Any(id => item.IsDerived(id)));
    }
        public object ComputeFieldValue(IIndexable indexable)
        {
            Assert.ArgumentNotNull(indexable, "indexable");
            string url = null;
            try
            {
                Item item = indexable as SitecoreIndexableItem;

                // This field only works for items uder /sitecore/content that have a layout
                if (item == null
                    || item.Visualization.Layout == null
                    || ! item.Paths.FullPath.StartsWith(
                            Sitecore.Constants.ContentPath,
                            StringComparison.InvariantCultureIgnoreCase))
                {
                    return null;
                }

                // Determine the url to request
                using (new DatabaseSwitcher(item.Database))
                {
                    url = WebUtil.AddQueryString(
                        LinkManager.GetItemUrl(item, new UrlOptions()
                            {
                                AlwaysIncludeServerUrl = true
                            }),
                        "sc_database", Sitecore.Context.Database.Name);
                }

                // Http request the page
                using (var client = new WebClient())
                {
                    string pageContent = client.DownloadString(url);

                    // Parse the page's html using HtmlAgilityPack
                    HtmlDocument htmlDocument = new HtmlDocument();
                    htmlDocument.LoadHtml(pageContent);

                    // Strip out all the html tags, so we can index just the text
                    HtmlNode mainContainer = htmlDocument.DocumentNode.Descendants("body").FirstOrDefault();
                    string content = mainContainer != null ? GetAllInnerTexts(mainContainer) : null;
                    return content;
                }
            }
            catch (WebException webExc)
            {
                Log.Warn(string.Format("Failed to html index {0} ({1}): {2}", indexable.Id, url, webExc.Message), webExc, this);
            }
            catch (Exception exc)
            {
                Log.Error(string.Format("An error occurred when indexing {0}: {1}", indexable.Id, exc.Message), exc, this);
            }
            return null;
        }
Пример #31
0
 public Node(IIndexable owner)
 {
     Owner      = owner;
     ChildNodes = new NodeDictionary();
     Items      = new List <TItem>();
 }
Пример #32
0
 public bool Equals(IIndexable other) => other == this;
Пример #33
0
 public DynamicIndexable(IIndexable <TValue> source) : this(IndexableToDictionary(source), start : 0, length : source.Length)
 {
 }
Пример #34
0
        public override string GetContextIndexName(IIndexable indexable)
        {
            var currentProvider = Switcher <SearchProvider> .CurrentValue;

            return(currentProvider != null?currentProvider.GetContextIndexName(indexable) : null);
        }
Пример #35
0
 public MergedIndexable2D(IIndexable <IIndexable <IIndexable2D <TValue> > > source)
     : this(new IndexableOfIndexableAsIndexable2D <IIndexable2D <TValue> >(source))
 {
 }
 public void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     Delete(indexable.Id, context);
 }
Пример #37
0
 public IndexableEnumerator(IIndexable <TValue> values)
 {
     _values = values;
     Reset();
 }
 public IndexData(ISearchIndex index, IIndexable indexable, AzureDocumentBuilder documentBuilder)
     : this(index, indexable, documentBuilder.Document, documentBuilder.CollectedFields)
 {
 }
Пример #39
0
        protected override object Compute(IIndexable indexable)
        {
            var value = indexable?.GetFieldByName(Constants.Fields.Redirect.RegexEnabled)?.Value;

            return(MainUtil.GetBool(value, false));
        }
 protected abstract object ExecuteComputeFieldValue(IIndexable indexable);
        protected Item GetCurrentItem(IIndexable indexable)
        {
            var language = LanguageManager.GetLanguage(indexable.Culture.TwoLetterISOLanguageName);

            return(this.Database.GetItem(ID.Parse(indexable.Id), language));
        }
Пример #42
0
 public void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     Assert.ArgumentNotNull(context, "context");
     Delete(indexable.Id, context);
 }
Пример #43
0
 public void Update(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
 {
     Assert.ArgumentNotNull(indexable, "indexable");
     Add(indexable, context, indexConfiguration);
 }
Пример #44
0
        protected override void DoAdd(IProviderUpdateContext context, SitecoreIndexableItem indexable)
        {
            Assert.ArgumentNotNull((object)context, "context");
            Assert.ArgumentNotNull((object)indexable, "indexable");
            using (new LanguageFallbackItemSwitcher(new bool?(context.Index.EnableItemLanguageFallback)))
            {
                Event.RaiseEvent("indexing:adding", new object[3]
                {
                    (object)context.Index.Name,
                    (object)indexable.UniqueId,
                    (object)indexable.AbsolutePath
                });

                if (!this.IsExcludedFromIndex(indexable, false))
                {
                    foreach (Language language in indexable.Item.Languages)
                    {
                        if (language.Name != "en")
                        {
                            continue;
                        }

                        Item obj1;
                        using (new WriteCachesDisabler())
                            obj1 = indexable.Item.Database.GetItem(indexable.Item.ID, language, Sitecore.Data.Version.Latest);
                        if (obj1 == null)
                        {
                            CrawlingLog.Log.Warn(string.Format("SitecoreItemCrawler : AddItem : Could not build document data {0} - Latest version could not be found. Skipping.", (object)indexable.Item.Uri), (Exception)null);
                        }
                        else
                        {
                            Item[] objArray1;
                            using (new WriteCachesDisabler())
                            {
                                Item[] objArray2;
                                if (obj1.IsFallback)
                                {
                                    objArray2 = new Item[1] {
                                        obj1
                                    }
                                }
                                ;
                                else
                                {
                                    objArray2 = obj1.Versions.GetVersions(false);
                                }
                                objArray1 = objArray2;
                            }
                            foreach (Item obj2 in objArray1)
                            {
                                IIndexable indexableItem = GetIndexable(indexable);

                                SitecoreIndexableItem sitecoreIndexableItem1 = (SitecoreIndexableItem)obj2;
                                SitecoreIndexableItem sitecoreIndexableItem2 = sitecoreIndexableItem1;
                                int num = ((IIndexableBuiltinFields)sitecoreIndexableItem2).Version == obj1.Version.Number ? 1 : 0;
                                ((IIndexableBuiltinFields)sitecoreIndexableItem2).IsLatestVersion = num != 0;
                                sitecoreIndexableItem1.IndexFieldStorageValueFormatter            = context.Index.Configuration.IndexFieldStorageValueFormatter;
                                this.Operations.Add((IIndexable)indexableItem, context, this.index.Configuration);
                            }
                        }
                    }
                }

                Event.RaiseEvent("indexing:added", new object[3]
                {
                    (object)context.Index.Name,
                    (object)indexable.UniqueId,
                    (object)indexable.AbsolutePath
                });
            }
        }
Пример #45
0
        protected void ChangeIndex(MoveAction moveAction, int Index, object item)
        {
            var currentItem = item as IIndexable;

            if (currentItem == null)
            {
                return;
            }
            switch (moveAction)
            {
            case MoveAction.Top:
                IIndexable topItem   = GetItem(0);
                int        topIndex  = topItem.Index;
                List <int> tempArray = new List <int>();
                foreach (var tempItem in InnerList)
                {
                    tempArray.Add((tempItem as IIndexable).Index);
                }
                for (int i = 0; i < Index; i++)
                {
                    IIndexable moveitem = InnerList[i] as IIndexable;
                    moveitem.Index = tempArray[i + 1];
                }
                currentItem.Index = topIndex;
                break;

            case MoveAction.Up:
                if (Index == 0)
                {
                    return;
                }
                IIndexable prevItem  = GetItem(Index - 1);
                int        prevIndex = prevItem.Index;
                prevItem.Index    = currentItem.Index;
                currentItem.Index = prevIndex;
                break;

            case MoveAction.Down:
                IIndexable nextItem  = GetItem(Index + 1);
                int        nextIndex = nextItem.Index;
                nextItem.Index    = currentItem.Index;
                currentItem.Index = nextIndex;
                break;

            case MoveAction.Bottom:
                IIndexable bottomItem  = GetItem(InnerList.Count - 1);
                int        bottomIndex = bottomItem.Index;

                for (int i = InnerList.Count - 1; i > Index; i--)
                {
                    IIndexable moveitem = InnerList[i] as IIndexable;
                    moveitem.Index = (InnerList[i - 1] as IIndexable).Index;
                }
                currentItem.Index = bottomIndex;
                break;

            default:
                break;
            }
            RefreshDefaultView();
            if (TargetElement != null)
            {
                TargetElement.SelectedItem = null;
            }
        }
Пример #46
0
 private void ApplyPermissionsThenIndex(IProviderUpdateContext context, IIndexable version, IIndexable latestVersion)
 {
     if (InboundIndexFilterPipeline.Run(new InboundIndexFilterArgs(version)))
     {
         Event.RaiseEvent("indexing:excludedfromindex", new object[] { _index.Name, version.UniqueId });
     }
     else
     {
         var itemToAdd = IndexVersion(version, latestVersion, context);
         if (itemToAdd == null)
         {
             CrawlingLog.Log.Warn(string.Format("ElasticIndexOperations : AddItem : IndexVersion produced a NULL doc for version {0}. Skipping.", version.UniqueId));
         }
         else
         {
             context.AddDocument(itemToAdd, null);
         }
     }
 }
Пример #47
0
 public IndexableEnumerator(IIndexable <Element> indexable)
 {
     this.indexable = indexable;
     index          = -1;
 }
Пример #48
0
        //public void StopDragging(GameObject sender, GameObject currentRaycast)
        //{

        //    if (currentRaycast == null)
        //    {
        //        ExitDragMode();
        //        return;
        //    }

        //    // Try move to another slot
        //    IIndexable<Item> dest = currentRaycast.GetComponent<IIndexable<Item>>();

        //    if (dest != null)
        //    {

        //        // I need a controller to define behaviour when moving items from one container to another
        //        ///////////////////////////////////////////

        //        // Get destination container
        //        IContainer<Item> dstContainer = dest.GetContainer();
        //        int dstIdx = dest.GetIndex();

        //        // Get source data
        //        IContainer<Item> srcContainer = source.GetContainer();
        //        int srcIdx = source.GetIndex();
        //        Item item = srcContainer.GetElement(source.GetIndex());

        //        // Try add the item to the destination container
        //        int quantity = 0;

        //        if (Input.GetKey(KeyCode.LeftControl))
        //        {
        //            int srcQ = srcContainer.GetQuantity(srcIdx);
        //            bool open = true;

        //            int q = dstContainer.GetFreeRoom(dstIdx, item);

        //            // If there is no room or I'm not moving the item at all then do nothing
        //            if ((q <= 0) || ((dstContainer == srcContainer) && (dstIdx == srcIdx || (srcContainer as IBigSlotContainer).GetRootIndex(srcIdx) == (srcContainer as IBigSlotContainer).GetRootIndex(dstIdx))))
        //                open = false;

        //            // If there is free room but only for a single object you don't need to open the quantity selector panel, then simply add the object ( this
        //            // works well for the equipment for example )
        //            if (q == 1 || srcQ == 1)
        //            {
        //                open = false;
        //            }

        //            Debug.Log(string.Format("q:{0}", q));
        //            if (open)
        //            {
        //                int max = Mathf.Min(q, srcQ);

        //                CounterSliderUI.Instance.Show(1, max /*srcContainer.GetQuantity(srcIdx)*/, (int a) =>
        //                {
        //                    // Move items
        //                    srcContainer.Move(srcIdx, dstIdx, a);

        //                }, () => { });

        //            }

        //        }
        //        else
        //        {

        //            quantity = 1;
        //            // Move items
        //            srcContainer.Move(srcIdx, dstIdx, quantity);



        //        }


        //    }

        //    ExitDragMode();

        //}

        void ExitDragMode()
        {
            source = null;
            LeanTween.scale(gameObject, Vector2.zero, transform.localScale.magnitude * scaleTime).setDestroyOnComplete(true);
        }
Пример #49
0
 public static IndexableEnumerator <T> GetEnumerator <T>(this IIndexable <T> indexable)
 {
     return(new IndexableEnumerator <T>(indexable));
 }
Пример #50
0
        public void StopDragging(GameObject sender, GameObject currentRaycast)
        {
            if (currentRaycast == null)
            {
                ExitDragMode();
                return;
            }

            // Try move to another slot
            IIndexable <Item> dest = currentRaycast.GetComponent <IIndexable <Item> >();

            if (dest != null)
            {
                // Get destination data
                IContainer <Item> dstContainer = dest.GetContainer();
                int  dstIdx  = dest.GetIndex();
                Item dstItem = dstContainer.GetElement(dstIdx);

                // Get source data
                IContainer <Item> srcContainer = source.GetContainer();
                int  srcIdx  = source.GetIndex();
                Item srcItem = srcContainer.GetElement(source.GetIndex());


                if (srcContainer == dstContainer)              /*********************** Same container ( ex. from inventory to inventory ) *********************/
                {
                    if (dstItem == null || dstItem == srcItem) // Destination is empty or contains the same item
                    {
                        int  srcQ        = srcContainer.GetQuantity(srcIdx);
                        int  dstFreeRoom = srcContainer.GetFreeRoom(dstIdx, srcItem);
                        bool doNothing   = false;

                        // If there is no room or I'm not moving the item at all then do nothing
                        bool multiSlotSupport = new List <System.Type>(srcContainer.GetType().GetInterfaces()).Contains(typeof(IBigSlotContainer));
                        if ((dstFreeRoom <= 0) || ((dstIdx == srcIdx || (multiSlotSupport && (srcContainer as IBigSlotContainer).GetRootIndex(srcIdx) == (srcContainer as IBigSlotContainer).GetRootIndex(dstIdx)))))
                        {
                            doNothing = false;
                        }

                        if (!doNothing)
                        {
                            int max = Mathf.Min(dstFreeRoom, srcQ);
                            Debug.Log("Max:" + max);
                            if (max > 1 && Input.GetKey(KeyCode.LeftControl))
                            {
                                CounterSliderUI.Instance.Show(1, max /*srcContainer.GetQuantity(srcIdx)*/, (int a) =>
                                {
                                    // Move items
                                    srcContainer.Move(srcIdx, dstIdx, a);
                                }, () => { });
                            }
                            else
                            {
                                max = 1;
                                srcContainer.Move(srcIdx, dstIdx, max);
                            }
                        }
                    }
                }
                else /********** Different containers *****************/
                {
                    if (dstItem == null || dstItem == srcItem) // Destination is empty or contains the same item
                    {
                        int  srcQ        = srcContainer.GetQuantity(srcIdx);
                        int  dstFreeRoom = dstContainer.GetFreeRoom(dstIdx, srcItem);
                        bool doNothing   = false;

                        if (dstFreeRoom <= 0)
                        {
                            doNothing = true;
                        }

                        if (!doNothing)
                        {
                            int max = Mathf.Min(dstFreeRoom, srcQ);
                            Debug.Log("Max:" + max);
                            if (max > 1 && Input.GetKey(KeyCode.LeftControl))
                            {
                                CounterSliderUI.Instance.Show(1, max /*srcContainer.GetQuantity(srcIdx)*/, (int a) =>
                                {
                                    // Move items
                                    int q = dstContainer.Insert(dstIdx, srcItem, max);
                                    if (q > 0)
                                    {
                                        srcContainer.Remove(srcIdx, q);
                                    }
                                }, () => { });
                            }
                            else
                            {
                                max = 1;
                                // Move items
                                int q = dstContainer.Insert(dstIdx, srcItem, max);
                                if (q > 0)
                                {
                                    srcContainer.Remove(srcIdx, q);
                                }
                            }
                        }
                    }
                    else // Different items between different containers
                    {
                        int  srcQ        = srcContainer.GetQuantity(srcIdx);
                        int  dstFreeRoom = dstContainer.GetFreeRoom(dstIdx, srcItem);
                        bool doNothing   = false;

                        if (!doNothing)
                        {
                            int max = Mathf.Min(dstFreeRoom, srcQ);
                            Debug.Log("Max:" + max);
                            if (max > 1 && Input.GetKey(KeyCode.LeftControl))
                            {
                                CounterSliderUI.Instance.Show(1, max /*srcContainer.GetQuantity(srcIdx)*/, (int a) =>
                                {
                                    // Move items
                                    TrySwitch(srcIdx, dstIdx, srcItem, dstItem, max, srcContainer, dstContainer);
                                }, () => { });
                            }
                            else
                            {
                                max = 1;
                                TrySwitch(srcIdx, dstIdx, srcItem, dstItem, max, srcContainer, dstContainer);
                            }
                        }
                    }
                }
            }

            ExitDragMode();
        }
Пример #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManualPath"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 public ManualPath(IIndexable <Vector3> path)
     : this(null, path)
 {
 }
 public AzureDocumentBuilder(IIndexable indexable, IProviderUpdateContext context)
     : base(indexable, context)
 {
     this.Context = context;
 }
Пример #53
0
        public override string GetContextIndexName(IIndexable indexable, BaseCorePipelineManager pipeline)
        {
            var currentProvider = Switcher <SearchProvider> .CurrentValue;

            return(currentProvider?.GetContextIndexName(indexable, pipeline));
        }
 public void Delete(IIndexable indexable, IProviderUpdateContext context)
 {
     throw new NotImplementedException();
 }
Пример #55
0
        public virtual object ComputeFieldValue(IIndexable indexable)
        {
            var item = (Item)(indexable as SitecoreIndexableItem);

            return(item?.ImageUrl(string.IsNullOrWhiteSpace(RefFieldName) ? FieldName : RefFieldName, Width, Height));
        }
Пример #56
0
 public object ComputeFieldValue(IIndexable indexable)
 {
     return(GetAllTemplates(indexable as SitecoreIndexableItem));
 }
Пример #57
0
 public Node(IIndexable owner, Node source)
 {
     Owner      = owner;
     ChildNodes = new NodeDictionary(source.ChildNodes);
     Items      = new List <TItem>(source.Items);
 }
Пример #58
0
        private bool CheckIndexableItem()
        {
            IIndexable indexItem = InnerSelectedItem as IIndexable;

            return(indexItem == null || IsIndexEnable);
        }
Пример #59
0
 protected abstract void ProcessIndexable(ISearchIndex index, IIndexable indexable, string itemPath);
        public string GetValue(IIndexable indexable, string[] fieldNames, TemplateID templateId)
        {
            var item = indexable.ToItem();

            return(GetValue(item, fieldNames, templateId));
        }