Sitecore Swamp

Dive in the Sitecore Swamp


Citrix Shortcuts

Citrix receiver is widely adopt as remote application access by enterprise level IT department. It enables IT deploys security polices, but compared with Microsoft Remote Desktop, it's not that easy to use with (personal feeling). Here're some shortcuts to share:

- Ctrl+F1: Ctrl+Alt+Del

- Shift+F2: exit/back to full screen mode. But, once exits from full screen mode, and back to it, you will lose all the shortcuts. So do not use this one, if you want back to the host.

- Ctrl+Alt+Del: it brings host's quick menu, and now be able to select the application icon from task bar. Click the Citrix icon in task bar to back to Citrix Receiver full screen mode, and the shortcuts still works!

The last one make need do twice if you have dual monitors, not sure if need 3 times for 3 monitors.

Glass Cast an Image Field

Today, I just encounter a scenario that I have to get the Glass Image from a Sitecore Image Field. Here's code to achieve it:

        public static Glass.Mapper.Sc.Fields.Image GlassCast(this ImageField field)
            if (field == null || field.Value.IsNullOrEmpty())
                return null;
            var glassImage = new Glass.Mapper.Sc.Fields.Image();
            Glass.Mapper.Sc.DataMappers.SitecoreFieldImageMapper.MapToImage(glassImage, field);
            return glassImage;

Happy coding.

Remove/Replace the line ending

It's quite an old problem that we have to remove the line ending and replace with <br /> somethings for web development. Everything time, I have to google the solution and trail it, and today I am going to note down the final, and no more search for the future.

First, we need understand what's line ending. It has many names: newline, end of line, line break, .. The most common we need to deal with are:

LF: \n, unix world

CR: \r some MacOS

CR+LF: \r\n, Windows

LS: 0x2028, line separator Unicode

PS: 0x2029, paragraph separator Unicode

To remove all of above instances:

        public static string ReplaceLineEndings(string value, string replaceWith)


            if (String.IsNullOrEmpty(value))


                return value;


            string pattern = @"\r\n?|[\n\u2028\u2029]";

            return Regex.Replace(value, pattern, replaceWith);