Beispiel #1
0
        public CodeItem(string data, CodeItemType type, bool isEncoded, EditablePortalItem parent)
        {
            Type   = type;
            state  = CodeItemState.None;
            Parent = parent;

            if (string.IsNullOrEmpty(data))
            {
                content = string.Empty;
                return;
            }

            if (isEncoded)
            {
                encodedContent = data;
                // use StreamReader to auto-detect encoding
                using (var stream = new StreamReader(new MemoryStream(Convert.FromBase64String(data)), true))
                {
                    content = stream.ReadToEnd();
                }
            }
            else
            {
                content = data;
            }
        }
Beispiel #2
0
        public CodeItem(string data, CodeItemType type, bool isEncoded, EditablePortalItem parent)
        {
            Type   = type;
            state  = CodeItemState.None;
            Parent = parent;

            if (string.IsNullOrEmpty(data))
            {
                content = string.Empty;
                return;
            }

            if (isEncoded)
            {
                encodedContent = data;
                content        = Encoding.UTF8.GetString(Convert.FromBase64String(data));
            }
            else
            {
                content = data;
            }
        }