当前位置: 首页>>代码示例>>C#>>正文


C# IActor.GetType方法代码示例

本文整理汇总了C#中IActor.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IActor.GetType方法的具体用法?C# IActor.GetType怎么用?C# IActor.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IActor的用法示例。


在下文中一共展示了IActor.GetType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildDispatchingMethod

        private static DynamicMethod BuildDispatchingMethod(IActor handler, IStructSizeCounter counter,
            Func<Type, int> messageIdGetter)
        {
            var handlerType = handler.GetType();
            var handleMethods = ActorRegistry.GetHandleMethods(handlerType)
                .ToDictionary(m => messageIdGetter(m.GetParameters()[1].ParameterType.GetElementType()), m => m)
                .OrderBy(kvp => kvp.Key)
                .ToArray();

            var dm = new DynamicMethod("ReadMessagesFor_" + handlerType.Namespace.Replace(".", "_") + handlerType.Name,
                typeof (void), new[] {typeof (MessageReader), typeof (int), typeof (ByteChunk)},
                handlerType.Assembly.Modules.First(), true);

            var actorField = typeof (MessageReader).GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                .Single(fi => fi.FieldType == typeof (IActor));

            var il = dm.GetILGenerator();

            // push handler
            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Ldfld, actorField);
            il.Emit(OpCodes.Castclass, handlerType);

            var endLbl = il.DefineLabel();

            // dispatch
            foreach (var method in handleMethods)
            {
                var lbl = il.DefineLabel();
                il.Emit(OpCodes.Ldarg_1); // messageTypeId
                il.Emit(OpCodes.Ldc_I4, method.Key);
                il.Emit(OpCodes.Ceq);
                il.Emit(OpCodes.Brfalse_S, lbl);

                // push envelope
                il.Emit(OpCodes.Ldarg_2);
                il.Emit(OpCodes.Ldfld, typeof (ByteChunk).GetField("Pointer"));

                //var messageType = method.Value.GetParameters()[1].ParameterType.GetElementType();
                //il.Emit(OpCodes.Ldc_I4, (int)Marshal.OffsetOf(messageType, Envelope.FieldName));
                //il.Emit(OpCodes.Add);

                // push message
                il.Emit(OpCodes.Ldarg_2);
                il.Emit(OpCodes.Ldfld, typeof (ByteChunk).GetField("Pointer"));

                il.EmitCall(OpCodes.Callvirt, method.Value, null);
                il.Emit(OpCodes.Br_S, endLbl);
                il.MarkLabel(lbl);
            }

            // nothing was called, pop
            il.Emit(OpCodes.Pop);

            // end label
            il.MarkLabel(endLbl);
            il.Emit(OpCodes.Ret);
            return dm;
        }
开发者ID:Scooletz,项目名称:RampUp,代码行数:59,代码来源:MessageReader.cs

示例2: Enumerate

        public static EventPlug[] Enumerate(IActor actor)
        {
            List<EventPlug> list = new List<EventPlug>();

            foreach (EventInfo e in actor.GetType().GetEvents())
            {
                EventPlug plug = Create(e,actor);
                if (plug != null)
                {
                    list.Add(plug);
                }
            }

            return list.ToArray();
        }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:15,代码来源:EventPlug.cs

示例3: Initialize

        private void Initialize(IActor actor)
        {
            // First get all public methods.
            MethodInfo[] allMethods = actor.GetType().GetMethods( BindingFlags.Public | BindingFlags.NonPublic );

            foreach (MethodInfo m in allMethods)
            {
                // Check if its a method handler.
                MessageHandlerAttribute messageAttribute = Attribute.GetCustomAttribute( m,typeof(MessageHandlerAttribute)) as MessageHandlerAttribute;

                if (messageAttribute != null)
                {
                    string messageName = messageAttribute.Name;

                    if (messageName == string.Empty)
                    {
                        messageName = m.Name;
                    }

                    // Store it.
                    if (!methods.ContainsKey(messageName))
                    {
                        MessagePrototype newPrototype = MessagePrototype.Create( messageName,m );

                        methods.Add( messageName,m );
                        prototypes.Add( messageName,newPrototype );
                    }
                }
            }

            returnArray = new MessagePrototype[ prototypes.Count ];
            prototypes.Values.CopyTo( returnArray,0 );

            // Handle the dispatch
            realCall = new MessageDebugger.DebugMessageDelegate( this.CallMethod );
        }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:36,代码来源:MessageTable.cs

示例4: Enumerate

        public static IProperty[] Enumerate(IActor actor)
        {
            PropertyInfo[] properties = actor.GetType().GetProperties();
            List<IProperty> propertyList = new List<IProperty>();

            foreach (PropertyInfo p in properties)
            {
                Property currentProperty = Create(p,actor);
                if (currentProperty != null)
                    propertyList.Add(currentProperty);
            }

            return propertyList.ToArray();
        }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:14,代码来源:Property.cs

示例5: GetBaseType

 public static string GetBaseType(IActor actor)
 {
     return GetBaseType( actor.GetType() );
 }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:4,代码来源:Utility.cs

示例6: GetDocumentation

 public static string GetDocumentation(IActor actor)
 {
     return GetDocumentation( actor.GetType() );
 }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:4,代码来源:Utility.cs

示例7: GetDescription

 public static string GetDescription(IActor actor)
 {
     return GetDescription( actor.GetType() );
 }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:4,代码来源:Utility.cs

示例8: ActorDescriptor

 /// <summary>
 /// Builds the description on the actor instance basis.
 /// </summary>
 /// <param name="actor"></param>
 public ActorDescriptor(IActor actor)
 {
     HandledMessageTypes = GetHandledMessageTypes(actor.GetType());
 }
开发者ID:Scooletz,项目名称:RampUp,代码行数:8,代码来源:ActorDescriptor.cs

示例9: ResolveArgumentGroup

        public Object ResolveArgumentGroup(IActor resolvedActor, String[] parameters)
        {
            if (resolvedActor == null)
            {
                if (parameters.Length != 1)
                    throw new SystemException("argument group expects exactly one parameter instead of " + parameters.Length);

                String groupId = parameters[0];
                IGroup group = null;
                try
                {
                    group = organizationService.FindGroupById(groupId);
                }
                catch (OrganisationRuntimeException e)
                {
                    throw new SystemException("can't resolve group-argument with parameter " + groupId + " : " + e.Message);
                }

                return group;
            }
            else
            {
                if (parameters.Length != 1)
                    throw new SystemException("argument group expects exactly one parameter (membership-type) instead of " + parameters.Length);

                IUser user = null;
                IGroup group = null;
                String membershipType = parameters[0];

                try
                {
                    group = organizationService.FindGroupByMembership(resolvedActor.Id, membershipType);
                }
                catch (InvalidCastException e)
                {
                    throw new SystemException("can't resolve group-argument : a group must be calculated from a User, not a " + resolvedActor.GetType().FullName, e);
                }
                catch (OrganisationRuntimeException e)
                {
                    throw new SystemException("can't resolve group-argument : can't find the hierarchy-memberschip of User " + user.Id + " and membership-type " + membershipType + " : " + e.Message, e);
                }

                return group;
            }
        }
开发者ID:ephebe,项目名称:netbpm,代码行数:45,代码来源:ActorExpressionResolverService.cs

示例10: ResolveArgumentRole

        public Object ResolveArgumentRole(IActor resolvedActor, String[] parameters)
        {
            if (parameters.Length != 1)
                throw new SystemException("argument role expects exactly one parameter (role-name) instead of " + parameters.Length);

            IActor actor = null;

            if (resolvedActor == null)
            {
                try
                {
                    var attributeInstance = attributeRepository.FindAttributeInstanceInScope(parameters[0], CurrentScope, DbSession);
                    actor = (IActor)attributeInstance.GetValue();
                    throw new NotImplementedException();
                }
                catch (InvalidCastException e)
                {
                    //throw new SystemException("argument attribute(" + parameters[0] + ") does not contain an actor : " + executionContext.GetAttribute(parameters[0]).GetType().FullName, e);
                }
            }
            else
            {
                String roleName = parameters[0].Trim();

                try
                {
                    IList users = organizationService.FindUsersByGroupAndRole(resolvedActor.Id, roleName);
                    if (users.Count < 1)
                        throw new SystemException("no users have role " + roleName + " for group " + resolvedActor.Id);
                    actor = (IUser)users[0];

                    // TODO : create a new group if more then one user is returned on the query...
                }
                catch (InvalidCastException e)
                {
                    throw new SystemException("can't resolve role-argument : a role must be calculated from a Group, not a " + resolvedActor.GetType().FullName, e);
                }
                catch (OrganisationRuntimeException e)
                {
                    throw new SystemException("can't resolve role-argument : can't find the users that perform role " + roleName + " for group " + resolvedActor.Id + " : " + e.Message);
                }
            }

            return actor;
        }
开发者ID:ephebe,项目名称:netbpm,代码行数:45,代码来源:ActorExpressionResolverService.cs

示例11: ResolveArgumentParentGroup

        public Object ResolveArgumentParentGroup(IActor resolvedActor, String[] parameters)
        {
            if (parameters.Length != 0)
                throw new SystemException("argument parentGroup expects exactly zero parameters instead of " + parameters.Length);

            IGroup group = null;

            try
            {
                group = (IGroup)resolvedActor;
                group = group.Parent;
            }
            catch (InvalidCastException e)
            {
                throw new SystemException("can't resolve parentGroup-argument : a role must be calculated from a Group, not a " + resolvedActor.GetType().FullName, e);
            }

            return group;
        }
开发者ID:ephebe,项目名称:netbpm,代码行数:19,代码来源:ActorExpressionResolverService.cs

示例12: OnError

 public IActor OnError(IRuntime runtime, int actorId, IActor actor, Exception ex)
 {
     string message = String.Format("ActorId={0} of type={1}", actorId, actor.GetType().Name);
     runtime.Log.Error(message, ex);
     return null;
 }
开发者ID:snjee,项目名称:actor-http,代码行数:6,代码来源:DefaultErrorHandler.cs


注:本文中的IActor.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。