protected HtmlElement CreateRenderedTypeNameElement(RepresentedType type) { using (var writer = new StringWriter()) { writer.WriteHtmlEscaped(TypeHelper.GetCSharpTypeName(type.Name)); return(Document.CreateElement("code", innerHtml: writer.ToString())); } }
/// <summary> /// Creates and returns the CLR <see cref="Type"/>. /// </summary> /// <returns>Creates and returns the CLR <see cref="Type"/>.</returns> protected virtual Type CreateClrType() { if (!IsGeneric) { return(RepresentedType); } return(RepresentedType.MakeGenericType(GenericArguments.Select(arg => (Type)arg.GetClrVersion()).ToArray())); }
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()); }
protected InteractiveObjectBase( long handle, long representedObjectHandle, RepresentedType representedType, int depth) { Handle = handle; RepresentedObjectHandle = representedObjectHandle; RepresentedType = representedType; Depth = depth; }
/// <summary> /// Creates and returns the CLR <see cref="Type"/>. /// </summary> /// <returns>Creates and returns the CLR <see cref="Type"/>.</returns> protected virtual Type CreateClrType() { if (!IsGeneric) { return(RepresentedType); } #if !NETFX_CORE return(RepresentedType.MakeGenericType(GenericArguments.Select(arg => (Type)arg.GetClrVersion()).ToArray())); #else return(RepresentedType.MakeGenericType(GenericArguments.Select(arg => ((TypeInfo)arg.GetClrVersion()).AsType()).ToArray())); #endif }
EnumValue( RepresentedType representedType, RepresentedType underlyingType, object value, IReadOnlyList <object> values, IReadOnlyList <string> names, bool isFlags) { RepresentedType = representedType; UnderlyingType = underlyingType; Value = value; Values = values; Names = names; IsFlags = isFlags; }
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()); }
public MemberReferenceRequestArgs( InteractiveObject interactiveObject, RepresentedType interactiveObjectType, string memberName = null) { if (interactiveObject == null) { throw new ArgumentNullException(nameof(interactiveObject)); } if (interactiveObjectType == null) { throw new ArgumentNullException(nameof(interactiveObjectType)); } InteractiveObject = interactiveObject; InteractiveObjectType = interactiveObjectType; MemberName = memberName; }
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); } }
ReflectionInteractiveObject( long handle, long representedObjectHandle, RepresentedType representedType, int depth, bool hasMembers, RepresentedMemberInfo [] members, object [] values, string toStringRepresentation, bool suppressToStringRepresentation) : base( handle, representedObjectHandle, representedType, depth, hasMembers, members, values, toStringRepresentation, suppressToStringRepresentation) { }
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> (); }
protected HtmlElement CreateHeaderElement(RepresentedType type, string detailsText = null) { if (type == null) { throw new ArgumentNullException(nameof(type)); } var headerElem = Document.CreateElement("header"); headerElem.AppendChild(CreateRenderedTypeNameElement(type)); if (detailsText != null) { headerElem.AppendChild( Document.CreateElement("span", @class: "details", innerHtml: detailsText ) ); } return(headerElem); }
public override string CheckProperty( PropertyInfo property, object target, RepresentedType declaringType) { if (!typeof(NSObject).IsAssignableFrom(declaringType.ResolvedType)) { return(null); } var selName = property ?.GetGetMethod(true) ?.GetCustomAttribute <ExportAttribute> () ?.Selector; if (selName == null) { return(null); } var objCSelector = new Selector(selName); if (objCSelector == null || objCSelector.Handle == IntPtr.Zero) { return(null); } var nso = target as NSObject; if (nso == null || nso.RespondsToSelector(objCSelector)) { return(null); } return(string.Format("{0} instance 0x{1:x} does not respond to selector {2}", target.GetType(), nso.Handle, objCSelector.Name)); }
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; } }
public RepresentedObject(RepresentedType representedType) { this.representedType = representedType; }
/// <summary> /// Check that a CLR property can be safely invoked on a target object that /// may wrap a native object. /// </summary> /// <returns>Null if invocation is safe, an error string suitable for an /// exception message otherwise.</returns> public virtual string CheckProperty( PropertyInfo property, object target, RepresentedType declaringType) => null;
public override string ToCode() { return(BaseExpression != null?BaseExpression.ToString() : RepresentedType != null?RepresentedType.ToString() : "null"); }
protected override IRepresentedType GetValue(string value) => RepresentedType.Lookup(value);
public Type BindToType(string assemblyName, string typeName) => RepresentedType.GetType(typeName);
public override string ToCode() { return(RepresentedType != null?RepresentedType.ToString() : "null"); }
public virtual Type BindToType(string typeName) => RepresentedType.GetType(typeName);
protected HtmlElement CreateRenderedTypeNameElement(RepresentedType type) { return(Document.CreateElement("code", innerHtml: TypeHelper.GetCSharpTypeName(type.Name))); }