示例#1
0
 internal ExceptionHandler(HandlerKind kind, TryBody tryBlock, ILGeneratorLabel handlerStart)
 {
     this.ExceptionType = Dummy.TypeReference;
     this.kind          = kind;
     this.HandlerStart  = handlerStart;
     this.tryBlock      = tryBlock;
 }
示例#2
0
        private ExceptionHandler BeginHandler(HandlerKind kind)
        //^ requires InTryBody;
        {
            ILGeneratorLabel handlerStart = new ILGeneratorLabel(false);

            this.MarkLabel(handlerStart);
            TryBody          currentTryBody = this.tryBodyStack.Peek();
            ExceptionHandler handler        = new ExceptionHandler(kind, currentTryBody, handlerStart);

            if (currentTryBody.end == null)
            {
                currentTryBody.end = handlerStart;
            }
            else if (this.handlers.Count > 0)
            {
                for (int i = this.handlers.Count - 1; i >= 0; i--)
                {
                    if (this.handlers[i].HandlerEnd == null)
                    {
                        this.handlers[i].HandlerEnd = handlerStart;
                        break;
                    }
                }
            }
            this.handlers.Add(handler);
            return(handler);
        }
示例#3
0
 internal CilExceptionRegion(HandlerKind kind, EntityHandle catchType, int startOffset, int filterHandlerStart, int endOffset)
 {
     Kind               = kind;
     CatchType          = catchType;
     StartOffset        = startOffset;
     FilterHandlerStart = filterHandlerStart;
     EndOffset          = endOffset;
 }
 public HandlerSpan(HandlerKind kind, object exceptionType, int startOffset, int endOffset, int filterHandlerStart = 0)
 {
     this.Kind               = kind;
     this.ExceptionType      = exceptionType;
     this.StartOffset        = startOffset;
     this.EndOffset          = endOffset;
     this.FilterHandlerStart = filterHandlerStart;
 }
示例#5
0
 internal CilExceptionRegion(HandlerKind kind, EntityHandle catchType, int startOffset, int filterHandlerStart, int endOffset)
 {
     Kind = kind;
     CatchType = catchType;
     StartOffset = startOffset;
     FilterHandlerStart = filterHandlerStart;
     EndOffset = endOffset;
 }
示例#6
0
        public void Kind_MustReturnDecoratedKind()
        {
            const HandlerKind ExpectedHandlerKind = HandlerKind.Asynchronous;

            A.CallTo(() => this.handler.Kind).Returns(ExpectedHandlerKind);

            this.testee.Kind.Should().Be(ExpectedHandlerKind);
        }
示例#7
0
 /// <summary>
 /// 初始化<c> HandlerConfigurator </ c>类的新实例.
 /// </summary>
 /// <param name="context">配置上下文.</param>
 /// <param name="name">消息处理程序的名称.</param>
 /// <param name="handlerKind">指定处理程序类型的<see cref ="HandlerKind"/>可以是Command或Event.</param>
 /// <param name="sourceType">指定源的类型的<see cref ="HandlerSourceType"/>可以是程序集或类型.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 public HandlerConfigurator(IConfigSourceConfigurator context, string name, HandlerKind handlerKind,
                            HandlerSourceType sourceType, string source)
     : base(context)
 {
     this.name        = name;
     this.handlerKind = handlerKind;
     this.sourceType  = sourceType;
     this.source      = source;
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of <c>HandlerConfigurator</c> class.
 /// </summary>
 /// <param name="context">The configuration context.</param>
 /// <param name="name">The name of the message handler.</param>
 /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param>
 /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 public HandlerConfigurator(IConfigSourceConfigurator context, string name, HandlerKind handlerKind,
     HandlerSourceType sourceType, string source)
     : base(context)
 {
     this.name = name;
     this.handlerKind = handlerKind;
     this.sourceType = sourceType;
     this.source = source;
 }
示例#9
0
 public static void PrintParamHelper(HandlerKind operation)
 {
     if (operation == HandlerKind.Fibonacci)
     {
         Console.WriteLine("Enter ranges (min and max) divided with blank:");
     }
     if (operation == HandlerKind.NumbersSquaresLessThanN)
     {
         Console.WriteLine("Enter N - max value for squares of printed numbers");
     }
 }
示例#10
0
        private bool PopulateExceptionInformation()
        {
            List <CilExceptionInformation> excepList = new List <CilExceptionInformation>();

            SEHTableEntry[] /*?*/ sehTable = _methodIL.SEHTable;
            if (sehTable != null)
            {
                for (int i = 0; i < sehTable.Length; ++i)
                {
                    SEHTableEntry  sehTableEntry       = sehTable[i];
                    int            sehFlag             = (int)sehTableEntry.SEHFlags;
                    int            handlerKindIndex    = sehFlag >= ILReader.s_handlerKindMap.Length ? ILReader.s_handlerKindMap.Length - 1 : sehFlag;
                    ITypeReference exceptionType       = Dummy.TypeReference;
                    uint           filterDecisionStart = 0;
                    HandlerKind    handlerKind         = ILReader.s_handlerKindMap[handlerKindIndex];
                    uint           tryStart            = sehTableEntry.TryOffset;
                    uint           tryEnd       = sehTableEntry.TryOffset + sehTableEntry.TryLength;
                    uint           handlerStart = sehTableEntry.HandlerOffset;
                    uint           handlerEnd   = sehTableEntry.HandlerOffset + sehTableEntry.HandlerLength;

                    if (sehTableEntry.SEHFlags == SEHFlags.Catch)
                    {
                        IModuleTypeReference /*?*/ typeRef = this.PEFileToObjectModel.GetTypeReferenceForToken(this.MethodDefinition, sehTableEntry.ClassTokenOrFilterOffset);
                        if (typeRef == null)
                        {
                            //  Error
                            return(false);
                        }
                        else
                        {
                            exceptionType = typeRef;
                        }
                    }
                    else if (sehTableEntry.SEHFlags == SEHFlags.Filter)
                    {
                        exceptionType       = this.PEFileToObjectModel.SystemObject;
                        filterDecisionStart = sehTableEntry.ClassTokenOrFilterOffset;
                    }
                    excepList.Add(
                        new CilExceptionInformation(
                            handlerKind,
                            exceptionType,
                            tryStart,
                            tryEnd,
                            filterDecisionStart,
                            handlerStart,
                            handlerEnd
                            )
                        );
                }
            }
            this.MethodBody.SetExceptionInformation(new EnumerableArrayWrapper <CilExceptionInformation, IOperationExceptionInformation>(excepList.ToArray(), Dummy.OperationExceptionInformation));
            return(true);
        }
示例#11
0
 internal CilExceptionInformation(
     HandlerKind handlerKind,
     ITypeReference exceptionType,
     uint tryStartOffset,
     uint tryEndOffset,
     uint filterDecisionStartOffset,
     uint handlerStartOffset,
     uint handlerEndOffset
     )
 {
     this.HandlerKind               = handlerKind;
     this.ExceptionType             = exceptionType;
     this.TryStartOffset            = tryStartOffset;
     this.TryEndOffset              = tryEndOffset;
     this.FilterDecisionStartOffset = filterDecisionStartOffset;
     this.HandlerStartOffset        = handlerStartOffset;
     this.HandlerEndOffset          = handlerEndOffset;
 }
示例#12
0
 /// <summary>
 /// Adds a command or event handler to the ConfigSource.
 /// </summary>
 /// <param name="name">Name of the handler to be added.</param>
 /// <param name="kind">The <see cref="Apworks.Config.HandlerKind"/> value which
 /// represents the kind of the message.</param>
 /// <param name="sourceType">The <see cref="Apworks.Config.HandlerSourceType"/> value
 /// which indicates where the handler exists. This could be either a type or an assembly.</param>
 /// <param name="source">The identifier of the source, for <c>sourceType==HandlerSourceType.Type</c>,
 /// this value should be the name of the type; for <c>sourceType==HandlerSourceType.Assembly</c>,
 /// this value should be the name of the assembly.</param>
 public void AddHandler(string name, HandlerKind kind, HandlerSourceType sourceType, string source)
 {
     if (this.config.Handlers == null)
     {
         this.config.Handlers = new HandlerElementCollection();
     }
     foreach (HandlerElement he in this.config.Handlers)
     {
         if ((he.Name == name) || (he.Kind == kind && he.SourceType == sourceType && he.Source == source))
         {
             return;
         }
     }
     this.config.Handlers.Add(new HandlerElement
     {
         Name       = name,
         Kind       = kind,
         SourceType = sourceType,
         Source     = source
     });
 }
示例#13
0
 /// <summary>
 /// 初始化<c> HandlerConfigurator </ c>类的新实例.
 /// </summary>
 /// <param name="context">配置上下文.</param>
 /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param>
 /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 public HandlerConfigurator(IConfigSourceConfigurator context, HandlerKind handlerKind,
                            HandlerSourceType sourceType, string source)
     : this(context, Guid.NewGuid().ToString(), handlerKind, sourceType, source)
 {
 }
示例#14
0
 private PredicateAndHandler(HandlerKind handlerKind, bool handlerFirstArgumentShouldBeBaseType)
 {
     _handlerKind = handlerKind;
     _handlerFirstArgumentShouldBeBaseType = handlerFirstArgumentShouldBeBaseType;
 }
示例#15
0
 /// <summary>
 /// Adds a command or event handler to the ConfigSource.
 /// </summary>
 /// <param name="name">Name of the handler to be added.</param>
 /// <param name="kind">The <see cref="Apworks.Config.HandlerKind"/> value which
 /// represents the kind of the message.</param>
 /// <param name="sourceType">The <see cref="Apworks.Config.HandlerSourceType"/> value
 /// which indicates where the handler exists. This could be either a type or an assembly.</param>
 /// <param name="source">The identifier of the source, for <c>sourceType==HandlerSourceType.Type</c>,
 /// this value should be the name of the type; for <c>sourceType==HandlerSourceType.Assembly</c>,
 /// this value should be the name of the assembly.</param>
 public void AddHandler(string name, HandlerKind kind, HandlerSourceType sourceType, string source)
 {
     this.config.Handlers.Add(new HandlerElement
     {
         Name = name,
         Kind = kind,
         SourceType = sourceType,
         Source = source
     });
 }
示例#16
0
 internal ExceptionHandler(HandlerKind kind, TryBody tryBlock, ILGeneratorLabel handlerStart)
 {
     this.ExceptionType = Dummy.TypeReference;
       this.kind = kind;
       this.HandlerStart = handlerStart;
       this.tryBlock = tryBlock;
 }
示例#17
0
 //^ requires InTryBody;
 private ExceptionHandler BeginHandler(HandlerKind kind)
 {
     ILGeneratorLabel handlerStart = new ILGeneratorLabel(false);
       this.MarkLabel(handlerStart);
       TryBody currentTryBody = this.tryBodyStack.Peek();
       ExceptionHandler handler = new ExceptionHandler(kind, currentTryBody, handlerStart);
       if (currentTryBody.end == null)
     currentTryBody.end = handlerStart;
       else if (this.handlers.Count > 0) {
     for (int i = this.handlers.Count-1; i >= 0; i--) {
       if (this.handlers[i].HandlerEnd == null) {
     this.handlers[i].HandlerEnd = handlerStart;
     break;
       }
     }
       }
       this.handlers.Add(handler);
       return handler;
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of <c>HandlerConfigurator</c> class.
 /// </summary>
 /// <param name="context">The configuration context.</param>
 /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param>
 /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 public HandlerConfigurator(IConfigSourceConfigurator context, HandlerKind handlerKind,
     HandlerSourceType sourceType, string source)
     : this(context, Guid.NewGuid().ToString(), handlerKind, sourceType, source)
 {
 }
示例#19
0
 /// <summary>
 /// Create a new handler for the given kind
 /// </summary>
 /// <param name="kind"></param>
 public SettingFinalizerDescription(HandlerKind kind)
 {
     Kind = kind;
 }
示例#20
0
 /// <summary>
 /// Adds a command or event handler to the ConfigSource.
 /// </summary>
 /// <param name="name">Name of the handler to be added.</param>
 /// <param name="kind">The <see cref="Apworks.Config.HandlerKind"/> value which
 /// represents the kind of the message.</param>
 /// <param name="sourceType">The <see cref="Apworks.Config.HandlerSourceType"/> value
 /// which indicates where the handler exists. This could be either a type or an assembly.</param>
 /// <param name="source">The identifier of the source, for <c>sourceType==HandlerSourceType.Type</c>,
 /// this value should be the name of the type; for <c>sourceType==HandlerSourceType.Assembly</c>,
 /// this value should be the name of the assembly.</param>
 public void AddHandler(string name, HandlerKind kind, HandlerSourceType sourceType, string source)
 {
     if (this.config.Handlers == null)
         this.config.Handlers = new HandlerElementCollection();
     foreach (HandlerElement he in this.config.Handlers)
     {
         if ((he.Name == name) || (he.Kind == kind && he.SourceType == sourceType && he.Source == source))
             return;
     }
     this.config.Handlers.Add(new HandlerElement
     {
         Name = name,
         Kind = kind,
         SourceType = sourceType,
         Source = source
     });
 }
示例#21
0
 private PredicateAndHandler(HandlerKind handlerKind, bool handlerFirstArgumentShouldBeBaseType)
 {
     _handlerKind = handlerKind;
     _handlerFirstArgumentShouldBeBaseType = handlerFirstArgumentShouldBeBaseType;
 }
示例#22
0
 /// <summary>
 /// Adds a message handler to the Apworks framework. (This operation only applies on CQRS architecture).
 /// </summary>
 /// <param name="configurator">The <see cref="IHandlerConfigurator"/> instance to be extended.</param>
 /// <param name="handlerKind">The <see cref="HandlerKind"/> which specifies the kind of the handler, can either be a Command or an Event.</param>
 /// <param name="sourceType">The <see cref="HandlerSourceType"/> which specifies the type of the source, can either be an Assembly or a Type.</param>
 /// <param name="source">The source name, if <paramref name="sourceType"/> is Assembly, the source name should be the assembly full name, if
 /// <paramref name="sourceType"/> is Type, the source name should be the assembly qualified name of the type.</param>
 /// <param name="name">The name of the message handler.</param>
 /// <returns>The <see cref="IHandlerConfigurator"/> instance.</returns>
 public static IHandlerConfigurator AddMessageHandler(this IHandlerConfigurator configurator, HandlerKind handlerKind, HandlerSourceType sourceType, string source, string name = null)
 {
     if (string.IsNullOrEmpty(name))
     {
         return(new HandlerConfigurator(configurator, handlerKind, sourceType, source));
     }
     else
     {
         return(new HandlerConfigurator(configurator, name, handlerKind, sourceType, source));
     }
 }
 internal CilExceptionInformation(
   HandlerKind handlerKind,
   ITypeReference exceptionType,
   uint tryStartOffset,
   uint tryEndOffset,
   uint filterDecisionStartOffset,
   uint handlerStartOffset,
   uint handlerEndOffset
 ) {
   this.HandlerKind = handlerKind;
   this.ExceptionType = exceptionType;
   this.TryStartOffset = tryStartOffset;
   this.TryEndOffset = tryEndOffset;
   this.FilterDecisionStartOffset = filterDecisionStartOffset;
   this.HandlerStartOffset = handlerStartOffset;
   this.HandlerEndOffset = handlerEndOffset;
 }
 public HandlerParameters(HandlerKind handlerKind, ulong[] args)
 {
     Operation = handlerKind;
     Arguments = new ulong[args.Length];
     Array.Copy(args, Arguments, args.Length);
 }