public override void OnEntry(MethodExecutionArgs args)
 {
     if (Enabled)
     {
         _concern.OnEntry(new AngularAntiForgeryTokenArgumentAdapter(args));
     }
 }
		public override void OnExit(MethodExecutionArgs args)
		{
			if (this.PerformanceCounter != null)
			{
				this.BasePerformanceCounter.Increment();
			}
		}
        // This method is executed at runtime inside your application, before target methods
        public override void OnEntry(MethodExecutionArgs args)
        {
            Trace.WriteLine(MethodName + " - OnEntry");
            Trace.WriteLine(string.Format("Name: {0}, Date: {1}, User: {2}", Name, Date.ToString(), User));
            Trace.WriteLine(string.Format("MethodName: {0}", MethodName));
            Trace.WriteLine(string.Format("ParameterInfo[] Length: {0}", ParameterInfo.Length));

            // Get the values of ParameterInfo[] params with Reflection?
            // NOTE: simple reflective techniques cannot achieve what you desire with full generality
            // at least not without hooking into the debugger/profiling API: 
            // http://stackoverflow.com/questions/1867482/c-sharp-getting-value-of-parms-using-reflection

            Trace.WriteLine(string.Format("Entering {0}.{1}", args.Method.DeclaringType.Name, args.Method.Name));
            
            Trace.WriteLine(args.Method.GetParameters()[0].Name + " = " + args.Arguments.GetArgument(0));
            Trace.WriteLine(args.Method.GetParameters()[1].Name + " = " +
                                (args.Arguments.GetArgument(1) as SomeObject).XYZ + ", " + 
                                (args.Arguments.GetArgument(1) as SomeObject).ABC
                            );

            /*
            for (int x = 0; x < args.Arguments.Count; x++)
                Trace.WriteLine(args.Method.GetParameters()[x].Name + " = " + args.Arguments.GetArgument(x));
            */
        }
示例#4
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            if (!ValidationFlags.HasFlag(ValidationFlags.Arguments)) return;

            var method = MethodInformation.GetMethodInformation(args);
            if (method == null
                || !method.HasArguments
                || (!ValidationFlags.HasFlag(ValidationFlags.NonPublic) && !method.IsPublic)
                || (!ValidationFlags.HasFlag(ValidationFlags.Properties) && method.IsProperty)
                || (!ValidationFlags.HasFlag(ValidationFlags.Methods) && !method.IsProperty)
                // TODO: What about events?
                )
                return;

            var invalidArgument = (from arg in args.Method.GetParameters()
                where arg.MayNotBeNull() && args.Arguments[arg.Position] == null
                select arg).FirstOrDefault();

            if (invalidArgument == null) return;

            if (method.IsProperty)
            {
                throw new ArgumentNullException(invalidArgument.Name,
                    String.Format(CultureInfo.InvariantCulture,
                        "Cannot set the value of property '{0}' to null.",
                        method.Name));
            }
            throw new ArgumentNullException(invalidArgument.Name);
        }
示例#5
0
        // Executed at runtime, before the method.
        public override void OnEntry( MethodExecutionArgs eventArgs )
        {
            // Compose the cache key.
            string key = this.formatStrings.Format(
                eventArgs.Instance, eventArgs.Method, eventArgs.Arguments.ToArray() );

            // Test whether the cache contains the current method call.
            lock ( cache )
            {
                object value;
                if ( !cache.TryGetValue( key, out value ) )
                {
                    // If not, we will continue the execution as normally.
                    // We store the key in a state variable to have it in the OnExit method.
                    eventArgs.MethodExecutionTag = key;
                }
                else
                {
                    // If it is in cache, we set the cached value as the return value
                    // and we force the method to return immediately.
                    eventArgs.ReturnValue = value;
                    eventArgs.FlowBehavior = FlowBehavior.Return;
                }
            }
        }
示例#6
0
 public override void OnException(MethodExecutionArgs args)
 {
     if (Exceptions.Handle(args.Exception))
         args.FlowBehavior = FlowBehavior.Continue;
     args.FlowBehavior = FlowBehavior.ThrowException;
     LoggingHelper.Writelog("exception:"+args.Exception);
 }
示例#7
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            var cmdlet = args.Instance as CmdletProvider;
            if( null == cmdlet )
            {
                return;
            }

            string parameters = "";
            if( null != args.Arguments && args.Arguments.Any() )
            {
                parameters = String.Join("; ", args.Arguments.ToList().ConvertAll(a => (a ?? "null").ToString()).ToArray());
            }
            try
            {
                var s = String.Format(
                    "[{0}] >> Entering [{1}] ( [{2}] )",
                    args.Instance.GetType().FullName,
                    args.Method.Name,
                    parameters);
                cmdlet.WriteDebug(s);
            }
            catch
            {
            }
        }
        /// <summary>
        /// Handler executed before execution of the method to which the current custom attribute is applied.
        /// </summary>
        /// <param name="eventArgs"></param>
        public override void OnEntry( MethodExecutionArgs eventArgs )
        {
            ReaderWriterLockSlim @lock = ((IReaderWriterSynchronized)eventArgs.Instance).Lock;

            if ( this.UseDeadlockDetection )
            {
                MethodInterceptionArgs args = new MethodInterceptionArgsImpl( @lock, Arguments.Empty ) { TypedBinding = WriterReadLockBinding.Instance };

                if ( [email protected] )
                {
                    eventArgs.MethodExecutionTag = new ExitReaderLockLockCookie();
                    DeadlockDetectionPolicy.ReaderWriterEnhancements.Instance.OnUpgradeableReadEnter( args );
                }
                DeadlockDetectionPolicy.ReaderWriterEnhancements.Instance.OnWriterLockEnter( args );
            }
            else
            {
                if ( [email protected] )
                {
                    eventArgs.MethodExecutionTag = new ExitReaderLockLockCookie();
                    @lock.EnterUpgradeableReadLock();
                }
                @lock.EnterWriteLock();
            }
        }
        public override void OnException(MethodExecutionArgs args)
        {
            InternalError internalError;
            HttpStatusCode httpStatusCode;

            var exceptionType = args.Exception.GetType();

            if (exceptionType == typeof(KeyNotFoundException))
            {
                httpStatusCode = HttpStatusCode.NotFound;
                var keyNotFoundException = args.Exception as KeyNotFoundException;
                internalError = InternalError.CreateNotFound(keyNotFoundException);
            }
            else if (exceptionType == typeof(ValidationException))
            {
                httpStatusCode = HttpStatusCode.BadRequest;
                var validationException = args.Exception as ValidationException;
                internalError = InternalError.CreateValidation(validationException);
            }
            else if (exceptionType == typeof(AuthenticationException))
            {
                httpStatusCode = HttpStatusCode.Unauthorized;
                var authenticationException = args.Exception as AuthenticationException;
                internalError = InternalError.CreateAuthentication(authenticationException);
            }
            else
            {
                httpStatusCode = HttpStatusCode.InternalServerError;
                internalError = InternalError.CreateUnexpected();
            }

            _log.Error(internalError.Id, args.Exception);
            throw new WebFaultException<InternalError>(internalError, httpStatusCode);
        }
示例#10
0
 /// <summary>
 /// Called at runtime after the method is executed, in case of exception.
 /// </summary>
 /// <param name="eventArgs">Event arguments.</param>
 public override void OnException( MethodExecutionArgs eventArgs )
 {
     Trace.Unindent();
     Trace.TraceWarning( "Exiting " +
                         this.strings.Format(eventArgs.Instance, eventArgs.Method, eventArgs.Arguments.ToArray()) +
                         " with error: " + eventArgs.Exception.Message );
 }
示例#11
0
        public override void OnException(MethodExecutionArgs args)
        {
            Console.WriteLine(String.Format("Exception in :[{0}] ,            Message:[{1}]", args.Method, args.Exception.Message));
            args.FlowBehavior = FlowBehavior.Continue;

            base.OnException(args);
        }
示例#12
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            if (string.IsNullOrEmpty(_name))
                _name = args.Method.Name;

            base.OnEntry(args);
        }
示例#13
0
 /// <summary>
 /// Called at runtime before the method is executed.
 /// </summary>
 /// <param name="eventArgs">Event arguments.</param>
 public override void OnEntry( MethodExecutionArgs eventArgs )
 {
     Trace.TraceInformation(
         "Entering " + this.strings.Format( eventArgs.Instance, eventArgs.Method, eventArgs.Arguments.ToArray() )
         );
     Trace.Indent();
 }
示例#14
0
 public override void OnSuccess(MethodExecutionArgs args)
 {
     //note: this is a terrible example, aspects should be "method agnostic"
     //but I'm doing it to prove a point :P
     var results = args.ReturnValue as SearchResults;
     Console.WriteColorLine(string.Format("Successfully searched twitter, got {0} results", results.Results.Length), ConsoleColor.Yellow);
 }
 public override void OnEntry(MethodExecutionArgs args)
 {
     // It is equiavlent to the start of the "try"
     Stopwatch sw = new Stopwatch();
     args.MethodExecutionTag = sw;
     sw.Start();
 }
        public override void OnEntry(MethodExecutionArgs args)
        {
            IPassport thisPassport = null;
            if (_passportParameterIndex >= 0)
            {
                thisPassport = (IPassport)args.Arguments[_passportParameterIndex];
            }

            if (thisPassport== null)
                return;

            var scopeName = args.ScopeName();

            thisPassport.PushScope(scopeName);

            IDictionary<string, object> parameters = new Dictionary<string, object>();

            for (var i = 0; i < args.Arguments.Count; i++)
            {
                if (!_passportParameters.Contains(_parameterNames[i]))
                {
                    parameters[_parameterNames[i]] = args.Arguments[i] ?? "null";
                }

            }
            thisPassport.Scope.RecordParameters(() => parameters, Constants.PassportScope.Enter);
            thisPassport.Debug("Has been entered", includeContext: true, includeScopes: true, scopeDepth: 0);

        }
示例#17
0
 public override void OnEntry(MethodExecutionArgs args)
 {
     _start = DateTime.Now;
     //note: this is a terrible example, aspects should be "method agnostic"
     //but I'm doing it to prove a point
     Console.WriteColorLine(string.Format("Starting search for {0}", args.Arguments[0]), ConsoleColor.Blue);
 }
        public override void OnSuccess(MethodExecutionArgs args)
        {
            var returnStatus = args.ReturnValue as Status;

            if (returnStatus == null || !returnStatus.Success) return;

	    // Note: password retreived from method's arguments, database stores only hash
            var password = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "password"));
            var recipients = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "recipients"));
            var optionalText = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "optionalText"));

            Guid campaignId;
            Guid.TryParse(AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "campaignId")), out campaignId);

            var abstractService = args.Instance as AbstractService;

            if (abstractService != null)
            {
                if(!abstractService.AuthenticatedUserId.HasValue)
                    throw new ArgumentException("AbstractService.AuthenticatedUserId should not be null, i.e. only authorized users allowed");

                if (notificationCondition(args))
                {
                    sendRegistrationMessage(abstractService.context, abstractService.AuthenticatedUserId.Value, campaignId, password: password, recipients: recipients, optionalText: optionalText);
                }
            }
        }
示例#19
0
 /// <summary>
 /// Method invoked after failure of the method to which the current
 /// aspect is applied.
 /// </summary>
 /// <param name="args">Information about the method being executed.</param>
 public override void OnException(MethodExecutionArgs args)
 {
     Trace.Unindent();
     Trace.TraceInformation("{0}.{1}: Exception {2}",
                             args.Method.DeclaringType.FullName, args.Method.Name,
                             args.Exception.Message);
 }
 public override void OnEntry(MethodExecutionArgs args)
 {
     if (_amountParameterIndex != -1)
     {
         Logger.Write(_className + "." + _methodName + ", amount: " + args.Arguments[_amountParameterIndex]);
     }
 }
        public override void OnEntry(MethodExecutionArgs args)
        {
            var instance = args.Instance as IHasPassport;
            if (instance == null) return;

            var thisPassport = instance.Passport;
            if (thisPassport == null) return;

            var scopeName = args.ScopeName();

            thisPassport.PushScope(scopeName);

            IDictionary<string, object> parameters = new Dictionary<string, object>();

            for (var i = 0; i < args.Arguments.Count; i++)
            {
                if (_sessionParameterIndex == i)
                {
                    thisPassport.SessionId = args.Arguments[i];
                }
                else
                {
                    parameters[_parameterNames[i]] = args.Arguments[i] ?? "null";
                }
            }

            thisPassport.PassportId = Guid.NewGuid();
            thisPassport.Scope.RecordParameters(() => parameters, Constants.PassportScope.Enter);
            thisPassport.Debug("Has been entered", includeContext: true, includeScopes: true, scopeDepth: 0);
        }
        public void OnExit(MethodExecutionArgs args)
        {
            var tabControlMember = Instance.GetType()
                                                    .GetFields(BindingFlags.NonPublic | BindingFlags.Public |
                                                               BindingFlags.Instance)
                                                    .FirstOrDefault(x => x.FieldType == typeof(TabControl));
            if (tabControlMember == null)
                return;

            var tabControl = tabControlMember.GetValue(Instance) as TabControl;
            if (tabControl == null)
                return;

            var formControllerMember = Instance.GetType()
                                         .GetFields(BindingFlags.NonPublic | BindingFlags.Public |
                                                    BindingFlags.Instance)
                                         .FirstOrDefault(x => x.FieldType.IsSubclassOf(typeof(BaseController)));

            if (formControllerMember == null)
                return;

            var formController = formControllerMember.GetValue(Instance) as BaseController;
            if (formController == null)
                return;

            var tabPage = new TabPage { Text = "Documents" };
            DocumentControl documentControl = new DocumentControl();
            tabPage.Controls.Add(documentControl);
            documentControl.Dock = DockStyle.Fill;
            tabControl.TabPages.Add(tabPage);
            formController.DataSourceInitialized += (sender, eventArgs) => documentControl.Controller.InitDataSource();
        }
        public override void OnSuccess(MethodExecutionArgs args)
        {
            var status = args.ReturnValue as Status;

            if (status != null && status.Success)
            {
                var campaignId = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "campaignId"));
                var affiliateId = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "affiliateId"));
                var accessKeyId = AspectUtility.GetArgument<string>(args, AspectUtility.GetArgumentPosition(args, "accessKeyId"));

                Guid validCampaignId;
                Guid validAccessKeyId;

                if (Guid.TryParse(campaignId, out validCampaignId) && Guid.TryParse(accessKeyId, out validAccessKeyId))
                {
                    using (var context = new DataContext())
                    {
                        var accessKey = context.AccessKeys.SingleOrDefault(key => key.Id == validAccessKeyId);

                        if (accessKey != null && accessKey.UserId != null)
                        {
                            processAffiliate(context, accessKey.UserId ?? Guid.Empty, validCampaignId, affiliateId);
                        }
                    }
                }
            }
        }
 public override void OnEntry(MethodExecutionArgs args)
 {
     _methodKey = args.Instance.ToString() + "." + args.Method.Name;
     System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();
     w.Start();
     args.MethodExecutionTag = w;
 }
        public override void OnExit(MethodExecutionArgs args)
        {
            System.Diagnostics.Stopwatch w = (System.Diagnostics.Stopwatch) args.MethodExecutionTag;
            w.Stop();

            Metrics.Timer(_methodKey, (int)w.ElapsedMilliseconds);
        }
		int Current( MethodExecutionArgs args, int move )
		{
			var dictionary = cache.Get( args.Instance ?? args.Method.DeclaringType );
			var key = Keys.For( args );
			var result = dictionary[key] = dictionary.Ensure( key, i => 0 ) + move;
			return result;
		}
示例#27
0
 public override void OnEntry(MethodExecutionArgs args)
 {
     args.MethodExecutionTag = Stopwatch.StartNew();
     //private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
     Logging.Info("Called Entry " + args.Method.Name);
     base.OnEntry(args);
 }
 public override void OnException(MethodExecutionArgs args)
 {
     object key = OperationContext.Current.IncomingMessageHeaders.MessageId;
     
     ObjectServiceExceptionStore.SetException(key, args.Exception.Message);
     throw args.Exception;
 }
 public override void OnEntry( MethodExecutionArgs eventArgs )
 {
     TransactionOptions options = new TransactionOptions();
     options.IsolationLevel = IsolationLevel.ReadCommitted;
     options.Timeout = TimeSpan.FromSeconds( this.timeout );
     eventArgs.MethodExecutionTag = new TransactionScope( this.transactionScopeOption, options );
 }
示例#30
0
 public override void OnException(MethodExecutionArgs args)
 {
     const string anErrorOccured = "An error occured";
     Console.WriteLine(anErrorOccured);
     args.ReturnValue = anErrorOccured;
     args.FlowBehavior = FlowBehavior.Return;
 }
 public void OnExit(MethodExecutionArgs args)
 {
     // your exit statements, such as committing transaction etc.
 }
 public override void OnEntry(MethodExecutionArgs args)
 {
     args.MethodExecutionTag = new TransactionScope(_option);
 }
 public override void OnExit(MethodExecutionArgs arg)
 {
     SetReturnValueAspectMethods.Result = arg.ReturnValue;
 }
示例#34
0
 //hangisini kullanacağıma tam emin olamadım (transaction hata verdiğinde mi dispose ediliyor yoksa iş bittikten sonra mı dispose edilmeli ?)
 public override void OnExit(MethodExecutionArgs args)
 {
     //finally block
     ((TransactionScope)args.MethodExecutionTag).Dispose();
 }
示例#35
0
 public override void OnSuccess(MethodExecutionArgs args)
 {
     ((TransactionScope)args.MethodExecutionTag).Complete();
 }
 public override void OnSuccess(MethodExecutionArgs args)
 {
     _cacheManager.RemoveByPattern(string.IsNullOrEmpty(_pattern)
         ? string.Format("{0}.{1}.*", args.Method.ReflectedType.Namespace, args.Method.ReflectedType.Name)
         : _pattern);
 }
示例#37
0
 public override void OnSuccess(MethodExecutionArgs args)
 {
     Console.WriteLine("{0} complete: {1}", args.Method.Name, DateTime.Now);
 }
 public void OnException(MethodExecutionArgs args)
 {
 }
示例#39
0
        public override void OnExit(MethodExecutionArgs args)
        {
            JFile returnValue = args.ReturnValue as JFile;

            DiagManager.LogInfo($"Loaded File {returnValue.FileName}.");
        }
 public void OnEntry(MethodExecutionArgs args)
 {
 }
示例#41
0
        public override void OnException(MethodExecutionArgs exec)
        {
            var logger = (exec.Instance as ITraceLoggable)?.Logger ?? DefaultLogger;

            logger.LogError(exec.Exception, "<<<!thrown:{method}", exec.Method.Name);
        }
        public override void OnEntry(MethodExecutionArgs args)
        {
            if (!args.Method.IsConstructor)
            {
                TransactionAttribute ta = (TransactionAttribute)args.Method.GetCustomAttributes(typeof(TransactionAttribute), true).FirstOrDefault();
                if (ta != null)
                {
                    if (ta.TransactionAttributeType == TransactionAttributeType.MANDATORY)
                    {
                        if (System.Transactions.Transaction.Current == null)
                        {
                            throw new TransactionRequiredException();
                        }
                    }
                    else if (ta.TransactionAttributeType == TransactionAttributeType.REQUIRED)
                    {
                        EJBTransactionScope ts2 = new EJBTransactionScope();

                        if (EJBContainer.Instance.TransactionScopes.Any())
                        {
                            EJBTransactionScope ts = EJBContainer.Instance.TransactionScopes.Peek();

                            ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Required);
                            ts2.TransactionAttributeType = TransactionAttributeType.REQUIRED;
                            ts2.DbContext = ts.DbContext;
                        }
                        else
                        {
                            ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Required);
                            ts2.TransactionAttributeType = TransactionAttributeType.REQUIRED;
                            ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                        }
                        EJBContainer.Instance.TransactionScopes.Push(ts2);
                    }
                    else if (ta.TransactionAttributeType == TransactionAttributeType.REQUIRES_NEW)
                    {
                        EJBTransactionScope ts2 = new EJBTransactionScope();

                        if (EJBContainer.Instance.TransactionScopes.Any())
                        {
                            EJBTransactionScope ts = EJBContainer.Instance.TransactionScopes.Peek();
                            if (ts.TransactionAttributeType == TransactionAttributeType.REQUIRED)
                            {
                                ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.RequiresNew);
                                ts2.TransactionAttributeType = TransactionAttributeType.REQUIRES_NEW;
                                ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                            }
                            else
                            {
                                ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Required);
                                ts2.TransactionAttributeType = TransactionAttributeType.REQUIRES_NEW;
                                ts2.DbContext = ts.DbContext;
                            }
                        }
                        else
                        {
                            ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Required);
                            ts2.TransactionAttributeType = TransactionAttributeType.REQUIRES_NEW;
                            ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                        }
                        EJBContainer.Instance.TransactionScopes.Push(ts2);
                    }
                    else if (ta.TransactionAttributeType == TransactionAttributeType.SUPPORTS)
                    {
                        EJBTransactionScope ts2 = new EJBTransactionScope();

                        if (EJBContainer.Instance.TransactionScopes.Any())
                        {
                            EJBTransactionScope ts = EJBContainer.Instance.TransactionScopes.Peek();

                            ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Required);
                            ts2.TransactionAttributeType = TransactionAttributeType.SUPPORTS;
                            ts2.DbContext = ts.DbContext;
                        }
                        else
                        {
                            ts2.TransactionScope         = null;
                            ts2.TransactionAttributeType = TransactionAttributeType.SUPPORTS;
                            ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                        }
                        EJBContainer.Instance.TransactionScopes.Push(ts2);
                    }
                    else if (ta.TransactionAttributeType == TransactionAttributeType.NOT_SUPPORTED)
                    {
                        EJBTransactionScope ts2 = new EJBTransactionScope();

                        if (EJBContainer.Instance.TransactionScopes.Any())
                        {
                            EJBTransactionScope ts = EJBContainer.Instance.TransactionScopes.Peek();

                            ts2.TransactionScope         = new TransactionScope(TransactionScopeOption.Suppress);
                            ts2.TransactionAttributeType = TransactionAttributeType.NOT_SUPPORTED;
                            ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                        }
                        else
                        {
                            ts2.TransactionScope         = null;
                            ts2.TransactionAttributeType = TransactionAttributeType.NOT_SUPPORTED;
                            ts2.DbContext = EJBContainer.Instance.GetNewDbContext();
                        }
                        EJBContainer.Instance.TransactionScopes.Push(ts2);
                    }
                }
                Trace.WriteLine(string.Format("Entering {0}.{1}.", args.Method.DeclaringType.Name, args.Method.Name));
            }
        }
 public override void OnEntry(MethodExecutionArgs args)
 {
     _stopwatch.Start();
     base.OnEntry(args);
 }
示例#44
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            string path = Path.Combine(args.Arguments[0].ToString(), args.Arguments[1].ToString());

            DiagManager.LogInfo($"Attempting to load file {path}...");
        }
 public override void OnException(MethodExecutionArgs args)
 {
     args.FlowBehavior = FlowBehavior.Return;
     args.Instance.GetType().GetMethod("OnAsyncExceptionCaught").Invoke(args.Instance, new object[] { args.Instance, args.Exception });
 }
 public override void OnEntry(MethodExecutionArgs arg)
 {
 }
 public override void OnException(MethodExecutionArgs args)
 {
     args.SetReturnValue(DefaultReturnVale);
 }
 public override void OnEntry(MethodExecutionArgs arg)
 {
     Debug.WriteLine("SecondAspect - OnEntry called for: " + arg.Method.Name);
     arg.MethodExecutionTag = MethodExecutionTagValue;
 }
示例#49
0
 public override void OnEntry(MethodExecutionArgs args)
 {
     _loggingService.Write("Log start");
 }
 public static string FullMethodName(this MethodExecutionArgs args) => $"{args.Method.DeclaringType.FullName}_{args.Method.Name}";
示例#51
0
        public ICollection Siralaturegore(MethodExecutionArgs args, string siralagirdi)
        {
            if (args.ReturnValue.GetType() == typeof(List <int>))
            {
                List <int> list_ = (List <int>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(List <string>))
            {
                List <string> list_ = (List <string>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(List <double>))
            {
                List <double> list_ = (List <double>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(List <float>))
            {
                List <float> list_ = (List <float>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }
                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(List <decimal>))
            {
                List <decimal> list_ = (List <decimal>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(List <long>))
            {
                List <long> list_ = (List <long>)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(ArrayList))
            {
                ArrayList list_ = (ArrayList)args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    list_.Sort();
                }
                else if (siralagirdi == "desc")
                {
                    list_.Sort();
                    list_.Reverse();
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    list_.Sort();
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(int[]))
            {
                int[] list_ = (int[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }
                Array.Sort(list_);

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(string[]))
            {
                string[] list_ = (string[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(double[]))
            {
                double[] list_ = (double[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(float[]))
            {
                float[] list_ = (float[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(decimal[]))
            {
                decimal[] list_ = (decimal[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }

                return(list_);
            }
            else if (args.ReturnValue.GetType() == typeof(long[]))
            {
                long[] list_ = (long[])args.ReturnValue;
                if (siralagirdi == "asc")
                {
                    Array.Sort(list_);
                }
                else if (siralagirdi == "desc")
                {
                    Array.Sort(list_);
                    Array.Reverse(list_);
                }
                else
                {
                    Console.WriteLine("buyukten kucuge sıralamak istiyorsanız ; desc kucukten buyuge siralamak istiyorsaniz asc degeri giriniz");
                    Array.Sort(list_);
                }

                return(list_);
            }
            else
            {
                return(new string[0]);
            }
        }
 public override void OnEntry(MethodExecutionArgs args)
 {
     args.MethodExecutionTag = Stopwatch.StartNew();
 }
示例#53
0
 public override void OnEntry(MethodExecutionArgs args)
 {
     args.MethodExecutionTag = StackExchange.Profiling.MiniProfiler.Current?.Step(methodName);
 }
示例#54
0
 public override void OnSuccess(MethodExecutionArgs args)
 {
     _loggingService.Write("Log end");
 }
 public override void OnEntry(MethodExecutionArgs arg)
 {
     arg.MethodExecutionTag = "MethodExecutionTag1";
 }
示例#56
0
 public override void OnExit(MethodExecutionArgs args)
 {
     ((IDisposable)args.MethodExecutionTag)?.Dispose();
 }
 public override void OnException(MethodExecutionArgs args)
 {
     args.FlowBehavior = FlowBehavior.RethrowException;
 }
        public override void OnSuccess(MethodExecutionArgs args)
        {
            var cacheKey = (string)args.MethodExecutionTag;

            MemoryCache.Default[cacheKey] = args.ReturnValue;
        }
示例#59
0
 public override void OnExit(MethodExecutionArgs args)
 {
     Log.Debug($"{args.Method.Name} execution has ended");
 }
 public override void OnExit(MethodExecutionArgs arg)
 {
     SetMethodExecutionTagValueOnExitAspectMethods.Result = arg.MethodExecutionTag;
 }