コード例 #1
0
            /// <summary>
            /// 下一个函数处理
            /// </summary>
            /// <param name="methodIndex"></param>
            private void next(methodIndex methodIndex)
            {
                fastCSharp.code.cSharp.tcpMethod attribute = methodIndex.Attribute;
                server server = defaultServer;

                server.type serverType  = defaultType;
                string      serviceName = attribute.ServiceName;

                if (serviceName == null)
                {
                    serviceName = Attribute.ServiceName;
                }
                if (serviceName != defaultServiceName)
                {
                    if (serviceName == null)
                    {
                        serverType = null;
                    }
                    else
                    {
                        hashString nameKey = serviceName;
                        if (!servers.TryGetValue(nameKey, out server))
                        {
                            servers.Add(nameKey, server = new server());
                            server.TcpServer.Service    = serviceName;
                        }
                        if (!serverTypes.TryGetValue(nameKey, out serverType))
                        {
                            server.Types.Add(serverType = new server.type {
                                Type = type
                            });
                            serverTypes.Add(nameKey, serverType);
                        }
                    }
                }
                if (serverType != null)
                {
                    server.IsMethod = true;
                    methodIndex.ServiceAttribute = server.TcpServer;
                    //methodIndex.MethodIndex = server.MethodIndex++;
                    methodIndex.ParameterIndex = parameterIndex++;
                    serverType.Methods.Add(methodIndex);
                }
            }
コード例 #2
0
 /// <summary>
 /// 安装下一个类型
 /// </summary>
 protected override void nextCreate()
 {
     if (Attribute.IsAbstract || type.Type.IsSealed || !type.Type.IsAbstract)
     {
         defaultServiceName = Attribute.ServiceName;
         defaultServer      = null;
         defaultType        = null;
         if (defaultServiceName != null)
         {
             hashString nameKey = defaultServiceName;
             if (!servers.TryGetValue(nameKey, out defaultServer))
             {
                 servers.Add(nameKey, defaultServer = new server());
             }
             defaultServer.TcpServer.Service     = defaultServiceName;
             defaultServer.Types.Add(defaultType = new server.type {
                 Type = type, Attribute = Attribute
             });
             if (Attribute.IsServer)
             {
                 defaultServer.AttributeType = type;
                 defaultServer.TcpServer.CopyFrom(Attribute);
             }
         }
         foreach (methodInfo method in code.methodInfo.GetMethods <fastCSharp.code.cSharp.tcpMethod>(type, Attribute.MemberFilter, false, Attribute.IsAttribute, Attribute.IsBaseTypeAttribute, Attribute.IsInheritAttribute))
         {
             next(new methodIndex
             {
                 Method     = method,
                 MethodType = type,
                 IsTypeGenericParameterName = type.Type.IsGenericType
             });
         }
         if (!type.Type.IsGenericType)
         {
             foreach (memberIndex member in code.memberIndexGroup.GetStatic <fastCSharp.code.cSharp.tcpMethod>(type, Attribute.MemberFilter, false, Attribute.IsAttribute, Attribute.IsBaseTypeAttribute, Attribute.IsInheritAttribute))
             {
                 if (member.IsField)
                 {
                     FieldInfo   field     = (FieldInfo)member.Member;
                     methodIndex getMethod = new methodIndex
                     {
                         Method      = new methodInfo(field, true),
                         MemberIndex = member,
                         MethodType  = type
                     };
                     if (!getMethod.Attribute.IsOnlyGetMember)
                     {
                         getMethod.SetMethod = new methodIndex {
                             Method = new methodInfo(field, false), MemberIndex = member, MethodType = type
                         };
                     }
                     next(getMethod);
                     if (getMethod.SetMethod != null)
                     {
                         next(getMethod.SetMethod);
                     }
                 }
                 else if (member.CanGet)
                 {
                     PropertyInfo property  = (PropertyInfo)member.Member;
                     methodIndex  getMethod = new methodIndex
                     {
                         Method      = new methodInfo(property, true),
                         MemberIndex = member,
                         MethodType  = type
                     };
                     if (member.CanSet && !getMethod.Attribute.IsOnlyGetMember)
                     {
                         getMethod.SetMethod = new methodIndex {
                             Method = new methodInfo(property, false), MemberIndex = member, MethodType = type
                         };
                     }
                     next(getMethod);
                     if (getMethod.SetMethod != null)
                     {
                         next(getMethod.SetMethod);
                     }
                 }
             }
         }
         serverTypes.Clear();
     }
 }