本文整理汇总了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);
}
}
}
示例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());
}
}