public void Delete(AttributeSearch request) { var matches = Get(request) as List <Attribute>; if (true != matches?.Any()) { throw new HttpError(HttpStatusCode.NotFound, "No matches for request"); } matches.ForEach(match => { Delete(match); }); }
public void FixtureSetUp() { const string assemblyName = "CryoAOP.TestAssembly.dll"; var assemblyImage = System.Reflection.Assembly.LoadFrom(assemblyName); var assemblyLoader = MockRepository.GenerateStub<IAssemblyLoader>(); assemblyLoader .Expect(al => al.GetShadowAssemblies()) .Return(new[] {new ShadowAssemblyType(assemblyImage, assemblyName)}); attributeSearch = new AttributeSearch(assemblyLoader); interceptAttributes = attributeSearch.FindAttributes<InterceptAttribute>(); }
public void FixtureSetUp() { const string assemblyName = "CryoAOP.TestAssembly.dll"; var assemblyImage = System.Reflection.Assembly.LoadFrom(assemblyName); var assemblyLoader = MockRepository.GenerateStub <IAssemblyLoader>(); assemblyLoader .Expect(al => al.GetShadowAssemblies()) .Return(new[] { new ShadowAssemblyType(assemblyImage, assemblyName) }); attributeSearch = new AttributeSearch(assemblyLoader); interceptAttributes = attributeSearch.FindAttributes <InterceptAttribute>(); }
public static void InterceptAspects() { var attributeFinder = new AttributeSearch(new AssemblyLoader()); var results = attributeFinder.FindAttributes <InterceptAttribute>(); var groupedByAssembly = results.GroupBy(r => r.Type.Assembly); foreach (var group in groupedByAssembly) { var shadowAssembly = group.First().ShadowAssembly; LoadAssembly(shadowAssembly.OriginalAssemblyPath); foreach (var result in group) { if (result.IsForType()) { InterceptType(result.TypeName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\*" .FormatWith( Path.GetFileName( shadowAssembly.OriginalAssemblyPath), result.TypeName)); } if (result.IsForMethod()) { InterceptMethod(result.TypeName, result.MethodName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\{2}" .FormatWith( Path.GetFileName(shadowAssembly.OriginalAssemblyPath), result.TypeName, result.MethodName)); } if (result.IsForProperty()) { InterceptProperty(result.TypeName, result.PropertyName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\{2}" .FormatWith( Path.GetFileName(shadowAssembly.OriginalAssemblyPath), result.TypeName, result.PropertyName)); } } SaveAssembly(shadowAssembly.OriginalAssemblyPath); } }
public static void InterceptAspects() { var attributeFinder = new AttributeSearch(new AssemblyLoader()); var results = attributeFinder.FindAttributes<InterceptAttribute>(); var groupedByAssembly = results.GroupBy(r => r.Type.Assembly); foreach (var group in groupedByAssembly) { var shadowAssembly = group.First().ShadowAssembly; LoadAssembly(shadowAssembly.OriginalAssemblyPath); foreach (var result in group) { if (result.IsForType()) { InterceptType(result.TypeName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\*" .FormatWith( Path.GetFileName( shadowAssembly.OriginalAssemblyPath), result.TypeName)); } if (result.IsForMethod()) { InterceptMethod(result.TypeName, result.MethodName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\{2}" .FormatWith( Path.GetFileName(shadowAssembly.OriginalAssemblyPath), result.TypeName, result.MethodName)); } if (result.IsForProperty()) { InterceptProperty(result.TypeName, result.PropertyName, result.Attribute.Scope); Console.WriteLine( "CryoAOP -> Intercepted {0}\\{1}\\{2}" .FormatWith( Path.GetFileName(shadowAssembly.OriginalAssemblyPath), result.TypeName, result.PropertyName)); } } SaveAssembly(shadowAssembly.OriginalAssemblyPath); } }
private IQueryable <DocEntityAttribute> _ExecSearch(AttributeSearch request, DocQuery query) { request = InitSearch <Attribute, AttributeSearch>(request); IQueryable <DocEntityAttribute> entities = null; query.Run(session => { entities = query.SelectAll <DocEntityAttribute>(); if (!DocTools.IsNullOrEmpty(request.FullTextSearch)) { var fts = new AttributeFullTextSearch(request); entities = GetFullTextSearch <DocEntityAttribute, AttributeFullTextSearch>(fts, entities); } if (null != request.Ids && request.Ids.Any()) { entities = entities.Where(en => en.Id.In(request.Ids)); } if (!DocTools.IsNullOrEmpty(request.Updated)) { entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date); } if (!DocTools.IsNullOrEmpty(request.UpdatedBefore)) { entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore); } if (!DocTools.IsNullOrEmpty(request.UpdatedAfter)) { entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter); } if (!DocTools.IsNullOrEmpty(request.Created)) { entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date); } if (!DocTools.IsNullOrEmpty(request.CreatedBefore)) { entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore); } if (!DocTools.IsNullOrEmpty(request.CreatedAfter)) { entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter); } if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.ATTRIBUTE, nameof(Reference.Archived), DocConstantPermission.VIEW)) { entities = entities.Where(en => en.Archived.In(request.Archived)); } else { entities = entities.Where(en => !en.Archived); } if (true == request.Locked?.Any()) { entities = entities.Where(en => en.Locked.In(request.Locked)); } if (!DocTools.IsNullOrEmpty(request.AttributeName) && !DocTools.IsNullOrEmpty(request.AttributeName.Id)) { entities = entities.Where(en => en.AttributeName.Id == request.AttributeName.Id); } if (true == request.AttributeNameIds?.Any()) { entities = entities.Where(en => en.AttributeName.Id.In(request.AttributeNameIds)); } else if (!DocTools.IsNullOrEmpty(request.AttributeName) && !DocTools.IsNullOrEmpty(request.AttributeName.Name)) { entities = entities.Where(en => en.AttributeName.Name == request.AttributeName.Name); } if (true == request.AttributeNameNames?.Any()) { entities = entities.Where(en => en.AttributeName.Name.In(request.AttributeNameNames)); } if (!DocTools.IsNullOrEmpty(request.AttributeType) && !DocTools.IsNullOrEmpty(request.AttributeType.Id)) { entities = entities.Where(en => en.AttributeType.Id == request.AttributeType.Id); } if (true == request.AttributeTypeIds?.Any()) { entities = entities.Where(en => en.AttributeType.Id.In(request.AttributeTypeIds)); } else if (!DocTools.IsNullOrEmpty(request.AttributeType) && !DocTools.IsNullOrEmpty(request.AttributeType.Name)) { entities = entities.Where(en => en.AttributeType.Name == request.AttributeType.Name); } if (true == request.AttributeTypeNames?.Any()) { entities = entities.Where(en => en.AttributeType.Name.In(request.AttributeTypeNames)); } if (!DocTools.IsNullOrEmpty(request.Interval) && !DocTools.IsNullOrEmpty(request.Interval.Id)) { entities = entities.Where(en => en.Interval.Id == request.Interval.Id); } if (true == request.IntervalIds?.Any()) { entities = entities.Where(en => en.Interval.Id.In(request.IntervalIds)); } if (true == request.IsCharacteristic?.Any()) { entities = entities.Where(en => en.IsCharacteristic.In(request.IsCharacteristic)); } if (true == request.IsOutcome?.Any()) { entities = entities.Where(en => en.IsOutcome.In(request.IsOutcome)); } if (true == request.IsPositive?.Any()) { if (request.IsPositive.Any(v => v == null)) { entities = entities.Where(en => en.IsPositive.In(request.IsPositive) || en.IsPositive == null); } else { entities = entities.Where(en => en.IsPositive.In(request.IsPositive)); } } if (!DocTools.IsNullOrEmpty(request.UniqueKey)) { entities = entities.Where(en => en.UniqueKey.Contains(request.UniqueKey)); } if (!DocTools.IsNullOrEmpty(request.UniqueKeys)) { entities = entities.Where(en => en.UniqueKey.In(request.UniqueKeys)); } if (!DocTools.IsNullOrEmpty(request.ValueType) && !DocTools.IsNullOrEmpty(request.ValueType.Id)) { entities = entities.Where(en => en.ValueType.Id == request.ValueType.Id); } if (true == request.ValueTypeIds?.Any()) { entities = entities.Where(en => en.ValueType.Id.In(request.ValueTypeIds)); } entities = ApplyFilters <DocEntityAttribute, AttributeSearch>(request, entities); if (request.Skip > 0) { entities = entities.Skip(request.Skip.Value); } if (request.Take > 0) { entities = entities.Take(request.Take.Value); } if (true == request?.OrderBy?.Any()) { entities = entities.OrderBy(request.OrderBy); } if (true == request?.OrderByDesc?.Any()) { entities = entities.OrderByDescending(request.OrderByDesc); } }); return(entities); }
public object Get(AttributeSearch request) => GetSearchResultWithCache <Attribute, DocEntityAttribute, AttributeSearch>(DocConstantModelName.ATTRIBUTE, request, _ExecSearch);
public object Post(AttributeSearch request) => Get(request);