private ITypeVersionEntity TryResolveCustomTypeVersion <T>() { var typeSignatureAttribute = typeof(T).GetCustomAttribute <TypeSignatureAttribute>(); ITypeVersionEntity typeVersion = null; if (typeSignatureAttribute != null) { typeVersion = this.Context.TryFindTypeVersion(typeSignatureAttribute.TypeVersionId); if (typeVersion == null) { typeVersion = this.Context.NewTypeVersion(); typeVersion.AssemblyName = typeof(T).Assembly.GetName().Name; typeVersion.DateCreated = this.Options.DateTimeProvider.Now; typeVersion.TypeName = typeof(T).FullName; typeVersion.TypeSignature = typeSignatureAttribute.TypeSignature; typeVersion.TypeVersionId = typeSignatureAttribute.TypeVersionId; this.Context.AddTypeVersion(typeVersion); } else { if (String.Compare(typeVersion.TypeSignature, typeSignatureAttribute.TypeSignature, false) != 0) { //need better exception here.. throw new Exceptions.NoSqlWrapperException("Type signature does not match!"); } } } return(typeVersion); }
private ITypeVersionEntity ResolveTypeVersion <T>() { //get a custom type version if its defined (do THIS first) ITypeVersionEntity typeVersion = this.TryResolveCustomTypeVersion <T>(); //if not defined, look for an existing type version if (typeVersion == null) { //look in cache at some point... var typeName = typeof(T).FullName; var assemblyName = typeof(T).Assembly.GetName().Name; var typeSignature = this.GetTypeSignature <T>(); typeVersion = this.Context.TryFindTypeVersion(assemblyName, typeName, typeSignature); } //if we are still null, add the type version if (typeVersion == null) { typeVersion = this.Context.NewTypeVersion(); typeVersion.AssemblyName = typeof(T).Assembly.GetName().Name; typeVersion.TypeName = typeof(T).FullName; typeVersion.TypeSignature = this.GetTypeSignature <T>(); typeVersion.DateCreated = this.Options.DateTimeProvider.Now; this.Context.AddTypeVersion(typeVersion); //this.Context.SaveChanges(); } return(typeVersion); }
public static void AddTypeVersion(this NoSQLContext context, ITypeVersionEntity typeVersionEntity) { var item = context.TypeVersion.Create(); context.TypeVersion.Add(item); item.AssemblyName = item.AssemblyName; item.TypeName = typeVersionEntity.TypeName; item.TypeSignature = typeVersionEntity.TypeSignature; item.TypeVersionId = typeVersionEntity.TypeVersionId; item.AssemblyName = typeVersionEntity.AssemblyName; item.DateCreated = typeVersionEntity.DateCreated; }