本文整理汇总了C#中System.Item.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetString方法的具体用法?C# Item.GetString怎么用?C# Item.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.GetString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHeadersForRequest
private NameValueCollection GetHeadersForRequest(Item expoTvsettings)
{
NameValueCollection headers = new NameValueCollection();
headers.Add("X-Expo_API_version", (expoTvsettings.FieldHasValue(Templates.VideoReviewsSettings.Fields.ApiVersion) ?
expoTvsettings.GetString(Templates.VideoReviewsSettings.Fields.ApiVersion) : "2.0"));
headers.Add("X-Expo_API_client_id", (expoTvsettings.FieldHasValue(Templates.VideoReviewsSettings.Fields.ClientId) ?
expoTvsettings.GetString(Templates.VideoReviewsSettings.Fields.ClientId) : string.Empty));
return headers;
}
示例2: GetReviews
public virtual VideoReviews GetReviews(Item expoTvsettings, string sku)
{
VideoReviews videoReviewResponse = null;
if (expoTvsettings != null && !string.IsNullOrWhiteSpace(sku))
{
string expoTvUrl =
expoTvsettings.GetString(Templates.VideoReviewsSettings.Fields.DetailedReviewURL) + "/" + sku;
if (!string.IsNullOrWhiteSpace(expoTvUrl))
{
NameValueCollection headers = GetHeadersForRequest(expoTvsettings);
string expoTvResponse = ExpoTvExternalProviderClient.GetDataFromExpoTvProvider(expoTvUrl, headers).Result;
XDocument expoResponseDoc = XDocument.Parse(expoTvResponse);
if (expoResponseDoc != null && expoResponseDoc.Root != null &&
expoResponseDoc.Root.Element("reviews") != null)
{
IEnumerable<XElement> reviewItems = expoResponseDoc.Root.Element("reviews").Elements("review_item");
videoReviewResponse = GetReviewsFromXml(reviewItems);
}
}
}
return videoReviewResponse;
}
示例3: GetSitecoreItemFieldValue
private static object GetSitecoreItemFieldValue(Type propertyType, Item item, SitecoreItemFieldAttribute attribute, bool isLazyLoad)
{
if (propertyType == _types[DataTypes.String])
{
return item.GetString(attribute.FieldId);
}
if (propertyType == _types[DataTypes.DateTime])
{
return item.GetDateTime(attribute.FieldId);
}
if (propertyType == _types[DataTypes.Int])
{
return item.GetInt(attribute.FieldId);
}
if (propertyType == _types[DataTypes.Double])
{
return item.GetDouble(attribute.FieldId);
}
if (propertyType == _types[DataTypes.Bool])
{
return item.GetBool(attribute.FieldId);
}
if (propertyType == _types[DataTypes.Item])
{
return item.GetItem(attribute.FieldId);
}
if (propertyType == _types[DataTypes.ItemEnumerable])
{
return item.GetItems(attribute.FieldId);
}
if (propertyType == _types[DataTypes.CustomField] || propertyType.IsSubclassOf(_types[DataTypes.CustomField]))
{
Field field = item.Fields[attribute.FieldId];
if (field != null)
return ReflectionUtil.CreateObject(propertyType, new object[] { field });
}
// got to figure out a better way to do this
if (propertyType == _types[DataTypes.SitecoreItem] || propertyType.IsSubclassOf(_types[DataTypes.SitecoreItem]))
{
Item fieldValueItem = item.GetItem(attribute.FieldId);
if (fieldValueItem != null && ItemExtensions.IsItemValidForType(propertyType, fieldValueItem))
return TypeMapper.CreateObject(item.GetItem(attribute.FieldId), propertyType, isLazyLoad);
}
// got to figure out a better way to do this
if (_types[DataTypes.SitecoreItemEnumerable].IsAssignableFrom(propertyType))
{
Type[] types = propertyType.GetGenericArguments();
if (!types.Any())
throw new Exception("XCore needs at least one type argument");
if (types.Count() > 1)
throw new Exception("XCore only supports one type argument");
Type classType = types[0];
Type listType = typeof(List<>).MakeGenericType(classType);
IList list = Activator.CreateInstance(listType) as IList;
if (list == null)
throw new Exception("XCore could not create a list of object type" + listType);
foreach (Item itm in item.GetItems(attribute.FieldId))
{
if (itm == null || !ItemExtensions.IsItemValidForType(classType, itm)) continue;
object typeObject = TypeMapper.CreateObject(itm, classType, isLazyLoad);
if (typeObject != null)
list.Add(typeObject);
}
return list;
}
return null;
}