Example #1
0
 public Activity(Activity authority, Type type, MethodBase method, Signature signature, Func <MethodInfo, MethodInfo> update)
 {
     this.Authority = authority;
     this.Type      = type;
     this.Method    = method;
     this.Signature = signature;
     this.Update    = update;
 }
                internal Entry(Type type, MethodBase method, Aspect.Activity activity)
                {
                    this.Type            = type;
                    this.Method          = method;
                    this.Activity        = activity;
                    this.m_Aspectization = new LinkedList <Aspect>();
                    this.m_Dictionary    = new Dictionary <Aspect, Aspect.Activity>();
                    var _update = Aspect.Directory.Entry.Update(method);

                    if (_update == null)
                    {
                        throw new NotSupportedException(string.Format($"Method '{ method.Name }' declared in type '{ method.DeclaringType.AssemblyQualifiedName }' is not managed by Puresharp and cannot be supervised. Please install Puresharp nuget package on '{ method.DeclaringType.Assembly.FullName }' to make it supervisable."));
                    }
                    this.m_Update   = Delegate.CreateDelegate(Metadata <Action <IntPtr> > .Type, _update) as Action <IntPtr>;
                    this.m_Pointer  = (IntPtr)Aspect.Directory.Entry.Authentic(method).GetValue(null);
                    this.m_Sequence = new LinkedList <MethodInfo>();
                    var _attribute = method.Attribute <AsyncStateMachineAttribute>();

                    if (_attribute == null)
                    {
                        return;
                    }
                    this.m_Factory = (_attribute.StateMachineType.IsGenericTypeDefinition ? _attribute.StateMachineType.MakeGenericType((method.IsGenericMethod ? type.GetGenericArguments().Concat(method.GetGenericArguments()) : type.GetGenericArguments()).ToArray()) : _attribute.StateMachineType).GetField("<Factory>", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly);
                }