public IReference CreateReferenceForNode(Type type, object value, bool isMember) { if (isMember) { return(!IsPrimitiveType(type) ? Reference.CreateReference(value, type, NodeIndex.Empty, true) : null); } var descriptor = TypeDescriptorFactory.Find(value?.GetType()); if (descriptor is CollectionDescriptor || descriptor is DictionaryDescriptor) { var valueType = GetElementValueType(descriptor); return(!IsPrimitiveType(valueType) ? Reference.CreateReference(value, type, NodeIndex.Empty, false) : null); } return(null); }
private IReference CreateReferenceForNode(Type type, object value) { // Is it a reference? if ((!type.IsClass && !type.IsInterface) || IsPrimitiveType(type)) { return(null); } ITypeDescriptor descriptor = value != null?TypeDescriptorFactory.Find(value.GetType()) : null; var valueType = GetElementValueType(descriptor); // This is either an object reference or a enumerable reference of non-primitive type (excluding custom primitive type) if (valueType == null || !IsPrimitiveType(valueType, false)) { return(Reference.CreateReference(value, type, Reference.NotInCollection)); } return(null); }
public IReference CreateReferenceForNode(Type type, object value) { // We don't create references for primitive types if (IsPrimitiveType(type) || type.IsStruct()) { return(null); } ITypeDescriptor descriptor = value != null?TypeDescriptorFactory.Find(value.GetType()) : null; var valueType = GetElementValueType(descriptor); // This is either an object reference or a enumerable reference of non-primitive type (excluding custom primitive type) if (valueType == null || (!IsPrimitiveType(valueType) && !valueType.IsStruct())) { return(Reference.CreateReference(value, type, Reference.NotInCollection)); } return(null); }
public IReference CreateReferenceForNode(Type type, object value) { // We don't create references for primitive types if (IsPrimitiveType(type)) { return(null); } // At this point it is either a struct, a reference type or a collection var descriptor = TypeDescriptorFactory.Find(value?.GetType()); var valueType = GetElementValueType(descriptor); // We don't create references for collection of primitive types if (IsPrimitiveType(valueType)) { return(null); } // In any other case, we create a reference return(Reference.CreateReference(value, type, Index.Empty)); }
public IReference CreateReferenceForNode(Type type, object value) { // We don't create references for primitive types and structs if (IsPrimitiveType(type) || type.IsStruct()) { return(null); } // At this point it is either a reference type or a collection ITypeDescriptor descriptor = value != null?TypeDescriptorFactory.Find(value.GetType()) : null; var valueType = GetElementValueType(descriptor); // We create reference only for structs (in case of collection of structs) and classes (in a collection or not) if (valueType == null || !IsPrimitiveType(valueType)) { return(Reference.CreateReference(value, type, Index.Empty)); } return(null); }