/// <summary> /// 程序集是否含有指定的特性的方法 /// </summary> public static bool IsHasAttributeClassMethond <T>(this Assembly InputAssembly) { bool reVal = false; Func <System.Object[], bool> IsAtte = o => { foreach (System.Attribute a in o) { if (a is T) { return(true); } } return(false); }; try { Type[] AssemblyTypes = InputAssembly.GetExportedTypes(); foreach (Type InType in AssemblyTypes) { MethodInfo[] MethodInfos = InType.GetMethods(); foreach (MethodInfo InMethod in MethodInfos) { if (IsAtte(Attribute.GetCustomAttributes(InMethod))) { reVal = true; goto IsHasAtte; } } if (!reVal) { PropertyInfo[] PropertyInfos = InType.GetProperties(); foreach (PropertyInfo InProperty in PropertyInfos) { if (IsAtte(InProperty.GetCustomAttributes(true))) { reVal = true; goto IsHasAtte; } } } } IsHasAtte: return(reVal); } catch (Exception ex) { ex.ToLog(); return(false); } }
void IRefactorRelationship.SetOutEntity(Entity target, bool allowLosingData) { Parent.EnsureSchemaMigration(); if (target.IsSubsclassOf(OutEntity)) { if (!allowLosingData) { throw new ArgumentException(string.Format("Target {0} is a sub type of {1}, you could lose data. If you want to do this anyway, you can set allowLosingData to true.", target.Name, OutEntity.Name), "baseType"); } foreach (var item in OutEntity.GetSubclasses()) { if (item.IsAbstract || item.IsVirtual) { continue; } if (item.IsSelfOrSubclassOf(target)) { continue; } //delete relations Parent.Templates.RemoveRelationship(template => { template.InEntity = InEntity.Label.Name; template.Relation = Neo4JRelationshipType; template.OutEntity = item.Label.Name; }).RunBatched(); } } else if (!OutEntity.IsSubsclassOf(target)) { throw new ArgumentException(string.Format("Target {0} is not a base or sub type of {1}. Consider using 'Reroute'.", target.Name, OutEntity.Name), "baseType"); } if (OutProperty != null) { OutEntity.Properties.Remove(OutProperty.Name); target.Properties.Add(OutProperty.Name, OutProperty); OutProperty.SetParentEntity(target); } if (InProperty != null) { InProperty.SetReturnTypeEntity(target); } OutInterface = new Interface(target); }