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


C# Item.GetString方法代码示例

本文整理汇总了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;
 }
开发者ID:jintov,项目名称:Habitat.ProductReviews,代码行数:9,代码来源:VideoReviewsService.cs

示例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;
 }
开发者ID:jintov,项目名称:Habitat.ProductReviews,代码行数:23,代码来源:VideoReviewsService.cs

示例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;
        }
开发者ID:zmalmquist,项目名称:XBlog,代码行数:68,代码来源:DataHandler.cs


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