示例#1
0
        protected HtmlElement CreateHeaderElement(object obj, string detailsText = null)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            return(CreateHeaderElement(RepresentedType.Lookup(obj.GetType()), detailsText));
        }
        public InteractiveEnumerable(int depth, IEnumerable enumerable,
                                     InteractiveItemPreparer itemPreparer) : base(depth, itemPreparer)
        {
            if (enumerable == null)
            {
                throw new ArgumentNullException(nameof(enumerable));
            }

            this.enumerable = enumerable;
            RepresentedType = RepresentedType.Lookup(enumerable.GetType());
        }
示例#3
0
        public ReflectionInteractiveObject(int depth,
                                           object representedObject,
                                           InteractiveItemPreparer itemPreparer,
                                           RepresentedMemberPredicate memberFilter = null)
            : base(depth, itemPreparer)
        {
            if (representedObject == null)
            {
                throw new ArgumentNullException(nameof(representedObject));
            }

            this.representedObject  = representedObject;
            this.memberFilter       = memberFilter;
            RepresentedObjectHandle = ObjectCache.Shared.GetHandle(representedObject);

            RepresentedType = RepresentedType.Lookup(representedObject.GetType());
        }
示例#4
0
        public EnumValue(Enum value)
        {
            var type           = value.GetType();
            var underlyingType = Enum.GetUnderlyingType(type);

            representedType     = RepresentedType.Lookup(type);
            this.underlyingType = RepresentedType.Lookup(underlyingType);

            this.value = Convert.ChangeType(value, underlyingType, CultureInfo.InvariantCulture);
            names      = Enum.GetNames(type);
            isFlags    = type.IsDefined(typeof(FlagsAttribute), false);

            var values = Enum.GetValues(type);

            this.values = new object [values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                this.values [i] = Convert.ChangeType(
                    values.GetValue(i), underlyingType, CultureInfo.InvariantCulture);
            }
        }
示例#5
0
        internal Evaluation(
            CodeCellId codeCellId,
            EvaluationStatus status,
            EvaluationResultHandling resultHandling,
            object value,
            TimeSpan evaluationDuration = default,
            int cultureLCID             = 0,
            int uiCultureLCID           = 0,
            bool initializedIntegration = false,
            IReadOnlyList <AssemblyDefinition> loadedAssemblies = null)
        {
            CodeCellId     = codeCellId;
            Status         = status;
            ResultHandling = resultHandling;

            switch (value)
            {
            case null:
                ResultRepresentations = Array.Empty <object> ();
                break;

            case RepresentedObject representedObject:
                ResultType            = representedObject.RepresentedType;
                ResultRepresentations = representedObject;
                break;

            default:
                ResultType            = RepresentedType.Lookup(value.GetType());
                ResultRepresentations = new [] { value };
                break;
            }

            EvaluationDuration     = evaluationDuration;
            CultureLCID            = cultureLCID;
            UICultureLCID          = uiCultureLCID;
            InitializedIntegration = initializedIntegration;
            LoadedAssemblies       = loadedAssemblies ?? Array.Empty <AssemblyDefinition> ();
        }
示例#6
0
        public CodeCellResultEvent(
            CodeCellId codeCellId,
            EvaluationResultHandling resultHandling,
            object value)
        {
            CodeCellId     = codeCellId;
            ResultHandling = resultHandling;

            switch (value)
            {
            case null:
                break;

            case RepresentedObject representedObject:
                Type = representedObject.RepresentedType;
                ValueRepresentations = representedObject;
                break;

            default:
                Type = RepresentedType.Lookup(value.GetType());
                ValueRepresentations = new [] { value };
                break;
            }
        }
示例#7
0
 protected override IRepresentedType GetValue(string value) => RepresentedType.Lookup(value);