当前位置: 首页>>代码示例>>C#>>正文


C# DataManager.ActsAs方法代码示例

本文整理汇总了C#中DataManager.ActsAs方法的典型用法代码示例。如果您正苦于以下问题:C# DataManager.ActsAs方法的具体用法?C# DataManager.ActsAs怎么用?C# DataManager.ActsAs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataManager的用法示例。


在下文中一共展示了DataManager.ActsAs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetDocumentMetaDataFields

        private void SetDocumentMetaDataFields(IndexingOptions options, DataManager manager, IndexDocument doc)
        {
            HasMetadata md = manager.ActsAs(typeof(HasMetadata)) as HasMetadata;
            if (md == null) return;

            MetaDataCollection metadata = manager[md.FieldName] as MetaDataCollection;

            if (metadata == null) return;

            Dictionary<string, double> tagHighestValues = new Dictionary<string, double>(StringComparer.CurrentCultureIgnoreCase);

            foreach (Tag t in metadata)
            {
                if (t.StringValueNormalized == null)
                {
                    doc.AddField(FieldType.Keyword, t.Name, t.NumericValue);
                }
                else
                {
                    if (!tagHighestValues.ContainsKey(t.Name))
                    {
                        tagHighestValues.Add(t.Name, 0f);
                        foreach (Tag weighted in metadata.Get(t.Name))
                        {
                            if (tagHighestValues[t.Name] < weighted.NumericValue)
                            {
                                tagHighestValues[t.Name] = weighted.NumericValue;
                            }
                        }
                    }

                    float highest = (float)tagHighestValues[t.Name];

                    float boost = (float)Math.Abs(t.NumericValue - highest);

                    if ("author".Equals(t.Name, StringComparison.CurrentCultureIgnoreCase))
                    {
                        doc.AddField(FieldType.Keyword, t.Name, t.StringValue.ToLower());
                    }
                    else
                    {
                        doc.AddField(FieldType.Keyword, t.Name, t.StringValueNormalized.ToLower());
                    }

                    //doc.AddField(FieldType.Keyword, t.Name, t.StringValueNormalized.ToLower(), boost);
                }
            }
        }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:48,代码来源:IsIndexable.cs

示例2: SetDocumentPermissions

        private void SetDocumentPermissions(IndexingOptions options, DataManager manager, IndexDocument doc)
        {
            LockedDown ld = manager.ActsAs(typeof(LockedDown)) as LockedDown;
            if (ld == null) return;

            PermissionsCollection permissions = manager[ld.FieldName] as PermissionsCollection;

            if (permissions == null) return;

            string[] groups = (options.GroupsWithViewPermissions != null) ? options.GroupsWithViewPermissions :
                permissions.GroupsWithViewPermissions;

            Array.Sort<string>(groups);

            foreach (string group in groups)
            {
                doc.AddField(FieldType.Keyword, "GroupWithViewPermissions", group.ToLower());
            }

            groups = permissions.GroupsWithCreatePermissions;
            Array.Sort<string>(groups);
            foreach (string group in groups)
            {
                doc.AddField(FieldType.Keyword, "GroupWithCreatePermissions", group.ToLower());
            }

            groups = permissions.GroupsWithEditPermissions;
            Array.Sort<string>(groups);
            foreach (string group in groups)
            {
                doc.AddField(FieldType.Keyword, "GroupWithEditPermissions", group.ToLower());
            }
        }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:33,代码来源:IsIndexable.cs


注:本文中的DataManager.ActsAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。