Пример #1
0
        public Variable GetVariable(IVariable value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            string presentation;
            string typeName;

            //На случай проблем, подобных:
            //https://github.com/EvilBeaver/OneScript/issues/918

            try
            {
                presentation = value.AsString();
            }
            catch (Exception e)
            {
                presentation = e.Message;
            }

            try
            {
                typeName = value.SystemType.Name;
            }
            catch (Exception e)
            {
                typeName = e.Message;
            }

            if (presentation.Length > DebuggerSettings.MAX_PRESENTATION_LENGTH)
            {
                presentation = presentation.Substring(0, DebuggerSettings.MAX_PRESENTATION_LENGTH) + "...";
            }

            return(new Variable()
            {
                Name = value.Name,
                Presentation = presentation,
                TypeName = typeName,
                IsStructured = IsStructured(value)
            });
        }