本文整理汇总了C#中IContent.GetOriginalType方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.GetOriginalType方法的具体用法?C# IContent.GetOriginalType怎么用?C# IContent.GetOriginalType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.GetOriginalType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public IDeleteResponse Delete(IContent content)
{
try {
var deleteResponse = Client.Delete(content, x => x.Index(IndexResolver.GetIndex()));
if (deleteResponse.IsValid == false) throw new DeleteException {DeleteResponse = deleteResponse };
Logger.WriteToLog($"Deleted content Name={content.Name} Id={content.ContentLink.ID} Type={content.GetOriginalType().Name} Elasticsearch response: Found={deleteResponse.Found} Id={deleteResponse.Id} Type={deleteResponse.Type}");
return deleteResponse;
}
catch (DeleteException exception) {
Logger.WriteToLog($"Delete content failed: Name={content.Name} Id={content.ContentLink.ID} Type={content.GetOriginalType().Name} Elasticsearch: Error={exception.DeleteResponse.ServerError.Error}",Level.Error);
}
catch (Exception exception)
{
Logger.WriteToLog("Unknown exception occured during delete indexing of content", Level.Error, exception);
}
return null;
}
示例2: Convert
public static string Convert(IContent content)
{
var properties = content.GetOriginalType()
.GetProperties(BindingFlags.Public |
BindingFlags.Instance |
BindingFlags.DeclaredOnly);
var list = new List<string>();
foreach (var property in properties) {
if(property.GetCustomAttribute(typeof (ElasticEPiIgnoreAttribute)) != null) continue;
var value = property.GetValue(content) as string;
if (!string.IsNullOrWhiteSpace(value))
list.Add(value);
}
return string.Join(" ", list);
}
示例3: Index
public IIndexResponse Index(IContent content)
{
try {
var response = Client.Index(content, x => x.
Index(IndexResolver.GetIndex()).
Id(content.ContentLink.ID)
);
var onIndexed = content as IOnIndexed;
if(onIndexed != null) onIndexed.OnIndexed();
if (response.IsValid == false) throw new IndexException {
ServerError = response.ServerError,
RequestInformation = response.RequestInformation
};
Logger.WriteToLog($"Indexed content: Name={content.Name} Id={content.ContentLink.ID} Type={content.GetOriginalType().Name}. Elasticsearch response: Created={response.Created} Version={response.Version} Id={response.Id} Type={response.Type}");
return response;
}
catch (IndexException exception) {
Logger.WriteToLog($"Indexing content failed: Name={content.Name} Id={content.ContentLink.ID} Type={content.GetOriginalType().Name} Exception details: Request={Encoding.UTF8.GetString(exception.RequestInformation.Request)} Response={Encoding.UTF8.GetString(exception.RequestInformation.ResponseRaw)}" ,Level.Error,exception);
}
catch (Exception exception) {
Logger.WriteToLog("Unknown exception occured during indexing of content", Level.Error, exception);
}
return null;
}
示例4: GetTypeSpecificCssClasses
private static string GetTypeSpecificCssClasses(IContent content)
{
var cssClass = content == null ? String.Empty : content.GetOriginalType().Name.ToLowerInvariant();
var customClassContent = content as ICustomCssInContentArea;
if (customClassContent != null && !string.IsNullOrWhiteSpace(customClassContent.ContentAreaCssClass))
{
cssClass += string.Format("{0}", customClassContent.ContentAreaCssClass);
}
return cssClass;
}