• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ISitecoreService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISitecoreService的典型用法代码示例。如果您正苦于以下问题:C# ISitecoreService类的具体用法?C# ISitecoreService怎么用?C# ISitecoreService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISitecoreService类属于命名空间,在下文中一共展示了ISitecoreService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetValue

        public override void SetValue(global::Sitecore.Data.Items.Item item, object value, ISitecoreService service)
        {
            
            switch (InfoType)
            {
                case SitecoreInfoType.DisplayName:
                    if (value is string || value == null)
                        item[Settings.DisplayNameFieldName] = (value ?? string.Empty).ToString();
                    else
                        throw new NotSupportedException("Can't set DisplayName. Value is not of type System.String");
                    break;
                case SitecoreInfoType.Name:
                    if (value is string || value == null)
                    {
                        //if the name is null or empty nothing should happen
                        if ((value ?? string.Empty).ToString().IsNullOrEmpty()) return;
                        
                        if (item.Name != value.ToString())
                        {
                            item.Name = value.ToString();
                        }
                        
                    }
                    else
                        throw new NotSupportedException("Can't set Name. Value is not of type System.String");
                    break;             
                default:
                    throw new NotSupportedException("You can not save SitecoreInfo {0}".Formatted(InfoType));
            }

        }
开发者ID:brianfeucht,项目名称:Glass.Sitecore.Mapper,代码行数:31,代码来源:SitecoreInfoHandler.cs


示例2: SetValue

        public override void SetValue( Item item, object value, ISitecoreService service)
        {
            var field = base.GetField(item);

            if (field == null)
            {
                return;
            }
            else if (field.Type.StartsWith("Rich Text") && Setting != SitecoreFieldSettings.RichTextRaw)
            {
                throw new NotSupportedException("It is not possible to save data from a rich text field when the data isn't raw."
                    + "Set the SitecoreFieldAttribute setting property to SitecoreFieldSettings.RichTextRaw for property {0} on type {1}".Formatted(Property.Name, Property.ReflectedType.FullName));
            }
            else
            {
                if (value != null)
                {
                    string fieldValue = value.ToString();
                    field.Value = fieldValue;
                }
                else
                {
                    field.Value = string.Empty;
                }
            }
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:26,代码来源:SitecoreFieldStringHandler.cs


示例3: SetValue

        public override void SetValue(global::Sitecore.Data.Items.Item item, object value, ISitecoreService service)
        {

            File  file = value as File;
            FileField field = new FileField(item.Fields[FieldName]);

            if (file == null)
            {
                field.Clear();
                return;
            }

            if (field.MediaID.Guid != file.Id)
            {
                if (file.Id == Guid.Empty)
                {
                    ItemLink link = new ItemLink(item.Database.Name, item.ID, field.InnerField.ID, field.MediaItem.Database.Name, field.MediaID, field.MediaItem.Paths.FullPath);
                    field.RemoveLink(link);
                }
                else
                {
                    ID newId = new ID(file.Id);
                    Item target = item.Database.GetItem(newId);
                    if (target != null)
                    {
                        field.MediaID = newId;
                        ItemLink link = new ItemLink(item.Database.Name, item.ID, field.InnerField.ID, target.Database.Name, target.ID, target.Paths.FullPath);
                        field.UpdateLink(link);
                    }
                    else throw new MapperException("No item with ID {0}. Can not update File Item field".Formatted(newId));
                }
            }

        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:34,代码来源:SitecoreFieldFileHandler.cs


示例4: GetValue

        public override object GetValue(global::Sitecore.Data.Items.Item item,  ISitecoreService service)
        {
                int numChildren = item.Children.Count;
                Type genericType = Utility.GetGenericArgument(Property.PropertyType);


              
                    var getItems = new Func<IEnumerable<Item>>(() =>
                    {

                        switch (Options)
                        {
                            case SitecoreLinkedOptions.All:
                                var itemLinks1 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferences(item);
                                var itemLinks2 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferrers(item);
                                return itemLinks1.Select(x => x.GetTargetItem()).Union(itemLinks2.Select(x=>x.GetSourceItem()));
                                break;
                            case SitecoreLinkedOptions.References:
                                var itemLinks3 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferences(item);
                                return itemLinks3.Select(x => x.GetTargetItem());
                                break;
                            case SitecoreLinkedOptions.Referrers:
                                var itemLinks4 = global::Sitecore.Configuration.Factory.GetLinkDatabase().GetReferrers(item);
                                return itemLinks4.Select(x => x.GetSourceItem());
                                break;
                            default:
                                return new List<Item>();
                        }
                        
                    });

                return service.CreateClasses(IsLazy, InferType,  genericType, getItems);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:33,代码来源:SitecoreLinkedHandler.cs


示例5: ReadFromItem

 public  void ReadFromItem(ISitecoreService service, object target, Item item, SitecoreClassConfig config)
 {
     foreach (var handler in config.DataHandlers)
     {
         handler.SetProperty(target, item, service);
     }
 }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:ClassManager.cs


示例6: GetValue

        public override object GetValue(global::Sitecore.Data.Items.Item item,  ISitecoreService service)
        {

            var itemField = base.GetField(item);

            if (itemField == null || itemField.Value.Trim().IsNullOrEmpty()) return null;
            
            

            Link link = new Link();
            LinkField field = new LinkField(itemField);

            switch (field.LinkType)
            {
                case "anchor":
                    link.Url = field.Anchor;
                    link.Type = LinkType.Anchor;
                    break;
                case "external":
                    link.Url = field.Url;
                    link.Type = LinkType.External;
                    break;
                case "mailto":
                    link.Url = field.Url;
                    link.Type = LinkType.MailTo;
                    break;
                case "javascript":
                    link.Url = field.Url;
                    link.Type = LinkType.JavaScript;
                    break;
                case "media":
                    global::Sitecore.Data.Items.MediaItem media = new global::Sitecore.Data.Items.MediaItem(field.TargetItem);
                    link.Url = global::Sitecore.Resources.Media.MediaManager.GetMediaUrl(media);
                    link.Type = LinkType.Media;
                    link.TargetId = field.TargetID.Guid;

                    break;
                case "internal":
                    if (field.TargetItem == null) link.Url = string.Empty;
                    else link.Url = LinkManager.GetItemUrl(field.TargetItem);
                    link.Type = LinkType.Internal;
                    link.TargetId = field.TargetID.Guid;

                    break;
                default:
                    return null;
                    break;

            }
            

            link.Anchor = field.Anchor;
            link.Class = field.Class;
            link.Text = field.Text;
            link.Title = field.Title;
            link.Target = field.Target;
            link.Query = field.QueryString;

            return link;
        }
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:60,代码来源:SitecoreFieldLinkHandler.cs


示例7: GetFieldValue

 public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
 {
     if (fieldValue.IsNullOrEmpty()) return 0d;
     double dValue = 0;
     if (double.TryParse(fieldValue, out dValue)) return dValue;
     else throw new MapperException("Could not convert value to double");
 }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:SitecoreFieldDoubleHandler.cs


示例8: GetFieldValue

        public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
        {
            Type type = Property.PropertyType;
            //Get generic type
            Type pType = Utility.GetGenericArgument(type);

            if (EnumSubHandler == null) EnumSubHandler = GetSubHandler(pType, service);
            
            //The enumerator only works with piped lists
            IEnumerable<string> parts = fieldValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            //replace any pipe encoding with an actual pipe
            parts = parts.Select(x => x.Replace(Settings.PipeEncoding, "|")).ToArray();

                      

            IEnumerable<object> items = parts.Select(x => EnumSubHandler.GetFieldValue(x, item, service)).ToArray();
            var list = Utility.CreateGenericType(typeof(List<>), new Type[] { pType }) ;
            Utility.CallAddMethod(items, list);

            return list;
            


        }
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:25,代码来源:SitecoreFieldIEnumerableHandler.cs


示例9: GetFieldValue

 public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
 {
     if (fieldValue.IsNullOrEmpty()) return 0;
     long lValue = 0;
     if (long.TryParse(fieldValue, NumberStyles.Any, CultureInfo.InvariantCulture, out lValue)) return lValue;
     throw new MapperException("Could not convert value to long.");
 }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:SitecoreFieldLongHandler.cs


示例10: SetFieldValue

        public override string SetFieldValue(object value, ISitecoreService service)
        {
            Type pType = Utility.GetGenericArgument(Property.PropertyType);


            if (EnumSubHandler == null)
                EnumSubHandler = GetSubHandler(pType, service);

            IEnumerable list = value as IEnumerable;

            if (list == null) return "";

            List<string> sList = new List<string>();
                       

            foreach (object obj in list)
            {
                string result = EnumSubHandler.SetFieldValue(obj, service);
                if (!result.IsNullOrEmpty())
                    sList.Add(result);
            }

            StringBuilder sb = new StringBuilder();
            sList.ForEach(x => sb.AppendFormat("{0}|", x.Replace("|", Settings.PipeEncoding)));
            if (sb.Length > 1) 
                sb.Remove(sb.Length - 1, 1);

            return sb.ToString();
        }
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:29,代码来源:SitecoreFieldIEnumerableHandler.cs


示例11: GetFieldValue

 public override object GetFieldValue(string fieldValue, Item item,  ISitecoreService service)
 {
     if (fieldValue.IsNullOrEmpty()) return 0;
     int iValue = 0;
     if (int.TryParse(fieldValue, out iValue)) return iValue;
     else throw new MapperException("Could not convert value to integer.");
 }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:SitecoreFieldIntegerHandler.cs


示例12: GetFieldValue

 public override object GetFieldValue(string fieldValue, Item item, ISitecoreService service)
 {
     if (fieldValue.IsNullOrEmpty()) return (float)0.0;
     float fValue = 0.0f;
     if (float.TryParse(fieldValue, out fValue)) return fValue;
     else throw new MapperException("Could not convert value to float");
 }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:7,代码来源:SitecoreFieldFloatHandler.cs


示例13: CommentsController

 public CommentsController(
     ISitecoreContext context,
     ISitecoreService master)
 {
     _context = context;
     _master = master;
 }
开发者ID:bplasmeijer,项目名称:Glass.Mapper.Sc.Demo,代码行数:7,代码来源:CommentsController.cs


示例14: SitecoreDataMappingContext

        /// <summary>
        /// Initializes a new instance of the <see cref="SitecoreDataMappingContext"/> class.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="item">The item.</param>
        /// <param name="service">The service.</param>
        public SitecoreDataMappingContext(object obj, Item item, ISitecoreService service):base(obj)
        {

            //TODO: ME - should we assert that these are not null
            this.Item = item;
            Service = service;
        }
开发者ID:kgkostadinov,项目名称:TdsTesting,代码行数:13,代码来源:SitecoreDataMappingContext.cs


示例15: GetValue

        public override object GetValue(global::Sitecore.Data.Items.Item item,  ISitecoreService service)
        {
            var itemField = item.Fields[FieldName];

            if (itemField == null) return null;

            Image img = new Image();
            ImageField scImg = new ImageField(itemField);

            int height = 0;
            int.TryParse(scImg.Height, out height);
            int width = 0;
            int.TryParse(scImg.Width, out width);
            int hSpace = 0;
            int.TryParse(scImg.HSpace, out hSpace);
            int vSpace = 0;
            int.TryParse(scImg.VSpace, out vSpace);

            img.Alt = scImg.Alt;
            img.Border = scImg.Border;
            img.Class = scImg.Class;
            img.Height = height;
            img.HSpace = hSpace;
            img.MediaId = scImg.MediaID.Guid;
            if(scImg.MediaItem != null)
                img.Src = MediaManager.GetMediaUrl(scImg.MediaItem);
            img.VSpace = vSpace;
            img.Width = width;

            return img;
        }
开发者ID:simonproctor,项目名称:Glass.Sitecore.Mapper,代码行数:31,代码来源:SitecoreFieldImageHandler.cs


示例16: GetValue

        public override  object GetValue(Item item, ISitecoreService service)
        {
            var field = GetField(item);

            string fieldValue = field == null ? string.Empty : field.Value ;

            return GetFieldValue(fieldValue, item, service);
        }
开发者ID:JamesHay,项目名称:Glass.Sitecore.Mapper,代码行数:8,代码来源:AbstractSitecoreField.cs


示例17: SetProperty

        /// <summary>
        /// Sets the property on the target object using data from the Sitecore Item
        /// </summary>
        /// <param name="target">The object to set the value on</param>
        /// <param name="item">The item to pull the data from</param>
        /// <param name="context">The current instance context</param>
        public void SetProperty(object target, Item item, ISitecoreService service)
        {
            object value = null;

            value = this.GetValue(item, service);
            if(value != null)
                Property.SetValue(target, value, null);
        }
开发者ID:photomoose,项目名称:Glass.Sitecore.Mapper,代码行数:14,代码来源:AbstractSitecoreDataHandler.cs


示例18: GetFieldValue

        public override object GetFieldValue(string fieldValue, Item item,  ISitecoreService service)
        {
            if (fieldValue.IsNullOrEmpty()) return 0M;

            decimal dValue = 0;
            if (decimal.TryParse(fieldValue, NumberStyles.Float, CultureInfo.InvariantCulture, out dValue)) return dValue;
            else throw new MapperException("Could not convert value to decimal");
        }
开发者ID:brianfeucht,项目名称:Glass.Sitecore.Mapper,代码行数:8,代码来源:SitecoreFieldDecimalHandler.cs


示例19: RateBaconController

        public RateBaconController(
            ISitecoreContext context,
            ISitecoreService service

            ):base(context, new GlassHtml(context))
        {
            _service = service;
        }
开发者ID:bplasmeijer,项目名称:Glass.Mapper.Sc.Demo,代码行数:8,代码来源:RateBaconController.cs


示例20: SetValue

        public override void SetValue(Item item, object value, ISitecoreService service)
        {
            if (value == null) return;
         
            Field field = item.Fields[FieldName];

            field.SetBlobStream(value as Stream);
        }
开发者ID:peelybird,项目名称:Glass.Sitecore.Mapper,代码行数:8,代码来源:SitecoreFieldStreamHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISkill类代码示例发布时间:2022-05-24
下一篇:
C# ISiteVar类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap