Example #1
0
        public void SetForType(Type type, TStoreType value)
        {
            var newEntry = new TypeRegistryEntry(type, value);

            _entries.Remove(newEntry);
            _entries.Add(newEntry);
        }
        public bool TypeMappingExists(IodineTypeDefinition from, Type to)
        {
            if (to.IsArray)
            {
                return(TypeMappingExists(from, to.GetElementType()));
            }
            TypeRegistryEntry entry = typeMappings.Where(p => p.IodineType == from &&
                                                         p.NativeType != null &&
                                                         p.NativeType.IsAssignableFrom(to)).FirstOrDefault();

            return(entry != null);
        }
Example #3
0
        public object ConvertToNativeObject(IodineObject obj, Type expectedType)
        {
            if (obj == IodineNull.Instance || obj == null)
            {
                return(null);
            }

            IodineTypeDefinition key = obj.TypeDef;

            TypeRegistryEntry entry = typeMappings.FirstOrDefault(p => p.IodineType == key && p.NativeType == expectedType);

            if (entry != null)
            {
                return(entry.Mapping.ConvertFrom(this, obj));
            }
            return(null);
        }
Example #4
0
        public IodineObject ConvertToIodineObject(object obj)
        {
            if (obj == null)
            {
                return(IodineNull.Instance);
            }

            Type key = obj.GetType();

            if (key.IsArray)
            {
                return(ConvertFromArray((object[])obj));
            }

            TypeRegistryEntry entry = typeMappings.Where(p => p.NativeType.IsAssignableFrom(key))
                                      .FirstOrDefault();

            if (entry != null)
            {
                return(entry.Mapping.ConvertFrom(this, obj));
            }
            return(null);
        }
Example #5
0
        public bool TypeMappingExists(IodineTypeDefinition from, Type to)
        {
            TypeRegistryEntry entry = typeMappings.FirstOrDefault(p => p.IodineType == from && p.NativeType.IsAssignableFrom(to));

            return(entry != null);
        }