Click or drag to resize

Getting Started

Getting Started AOP with Unity project

Steps

  1. After improting package right click one of the script (only C# supported) and reimport

  2. Example

    C#
    using Octupied.Aspect.Logging;
    using Octupied.Aspect.Profile;
    using System;
    
    namespace Octupied.Aspect.Example {
    
        /// <summary>
        /// AOP Example 
        /// </summary>
        public class Example {
            /// <summary>
            /// Aspect the log Example
            /// </summary>
            [LogJoinpointAspect()]
            public void LoggingExample() {
                Console.Out.WriteLine("This will be displayed after enter and before exit of this method");
            }
    
            /// <summary>
            /// Measure the performance of Newton's Approximation method
            /// </summary>
            /// <returns></returns>
            [SimpleTimeProfileAspect]
            private double FastSqrRoot(double number) {
                const double ACCURACY = 0.001;
                double lower, upper, guess;
    
                if (number < 1) {
                    lower = number;
                    upper = 1;
                }
                else {
                    lower = 1;
                    upper = number;
                }
    
                while ((upper - lower) > ACCURACY) {
                    guess = (lower + upper) / 2;
                    if (guess * guess > number)
                        upper = guess;
                    else
                        lower = guess;
                }
                return (lower + upper) / 2;
            }
        }
    }