protected internal CompilerResults Compile(string assemblyNameToCreate, string writeSourceTo) { HashSet <string> references = new HashSet <string>(DaoGenerator.DefaultReferenceAssemblies.ToArray()) { typeof(JsonIgnoreAttribute).Assembly.GetFileInfo().FullName }; _additionalReferenceAssemblies.Each(asm => { FileInfo assemblyInfo = asm.GetFileInfo(); if (references.Contains(assemblyInfo.Name)) { references.Remove(assemblyInfo.Name); // removes System.Core.dll if it is later referenced by full path } references.Add(assemblyInfo.FullName); }); SchemaDefinitionCreateResult.TypeSchema.Tables.Each(type => { references.Add(type.Assembly.GetFileInfo().FullName); CustomAttributeTypeDescriptor attrTypes = new CustomAttributeTypeDescriptor(type); attrTypes.AttributeTypes.Each(attrType => references.Add(attrType.Assembly.GetFileInfo().FullName)); }); references.Add(typeof(DaoRepository).Assembly.GetFileInfo().FullName); CompilerResults results = _daoGenerator.Compile(new DirectoryInfo(writeSourceTo), assemblyNameToCreate, references.ToArray(), false); return(results); }
public void AddType(Type type) { if (!ClrDaoTypeFilter(type)) { return; } if (type.GetProperty("Id") == null && !type.HasCustomAttributeOfType <KeyAttribute>() && CheckIdField) { throw new NoIdPropertyException(type); } // TODO: Investigate if this is necessary. Can a type have children that are // of the same type as itself if (type.HasEnumerableOfMe(type)) { throw new NotSupportedException("Storable types cannot have enumerable properties that are of the same type as themselves."); } AddAdditionalReferenceAssemblies(new TypeInheritanceDescriptor(type)); CustomAttributeTypeDescriptor attrs = new CustomAttributeTypeDescriptor(type); attrs.AttributeTypes.Each(attrType => AddAdditionalReferenceAssemblies(new TypeInheritanceDescriptor(attrType))); _types.Add(type); }