Beispiel #1
0
 /// <summary>
 /// 获取函数参数类型集合关键字
 /// </summary>
 /// <returns></returns>
 public MethodParameterTypes[] Get()
 {
     MethodParameterTypes[] parameters = new MethodParameterTypes[ParameterIndexs.Count + JsonParameterIndexs.Count];
     ParameterIndex = 0;
     foreach (MethodParameterTypes parameter in ParameterIndexs.Keys)
     {
         if (parameter.IsParameter)
         {
             parameters[ParameterIndex++] = parameter;
         }
     }
     foreach (MethodParameterTypeNames parameter in JsonParameterIndexs.Keys)
     {
         if (parameter.IsParameter)
         {
             parameters[ParameterIndex++].Set(parameter);
         }
     }
     return(parameters);
 }
Beispiel #2
0
 /// <summary>
 /// 添加方法索引信息
 /// </summary>
 /// <param name="method">方法索引信息</param>
 public void Add(TcpMethod method)
 {
     MethodParameter[] inputParameters = method.MethodParameters, outputParameters = method.Method.OutputParameters;
     if (method.IsJsonSerialize)
     {
         MethodParameterTypeNames inputParameterTypeNames = new MethodParameterTypeNames(inputParameters, method.Attribute.IsInputSerializeReferenceMember, method.Attribute.IsInputSerializeBox);
         MethodParameterTypeNames outputParameterTypeNames = method.MethodIsReturn ? new MethodParameterTypeNames(outputParameters, method.MethodReturnType, method.Attribute.IsOutputSerializeReferenceMember, method.Attribute.IsOutputSerializeBox) : new MethodParameterTypeNames(outputParameters, method.Attribute.IsOutputSerializeReferenceMember, method.Attribute.IsOutputSerializeBox);
         MethodParameterTypeNames historyInputJsonParameterIndex = default(MethodParameterTypeNames), historyOutputJsonParameterIndex = default(MethodParameterTypeNames);
         if (inputParameterTypeNames.IsParameter)
         {
             if (!JsonParameterIndexs.TryGetValue(inputParameterTypeNames, out historyInputJsonParameterIndex))
             {
                 inputParameterTypeNames.Copy(++ParameterIndex);
                 JsonParameterIndexs.Add(inputParameterTypeNames, historyInputJsonParameterIndex = inputParameterTypeNames);
             }
             method.InputParameterIndex = historyInputJsonParameterIndex.Index;
         }
         if (outputParameterTypeNames.IsParameter)
         {
             if (!JsonParameterIndexs.TryGetValue(outputParameterTypeNames, out historyOutputJsonParameterIndex))
             {
                 outputParameterTypeNames.Copy(++ParameterIndex);
                 JsonParameterIndexs.Add(outputParameterTypeNames, historyOutputJsonParameterIndex = outputParameterTypeNames);
             }
             method.OutputParameterIndex = historyOutputJsonParameterIndex.Index;
         }
         method.InputParameters  = MethodParameterPair.Get(inputParameters, historyInputJsonParameterIndex);
         method.OutputParameters = MethodParameterPair.Get(outputParameters, historyOutputJsonParameterIndex);
     }
     else
     {
         MethodParameterTypes inputParameterTypes = new MethodParameterTypes(inputParameters, method.Attribute.IsInputSerializeReferenceMember, method.Attribute.IsInputSerializeBox);
         MethodParameterTypes outputParameterTypes = method.MethodIsReturn ? new MethodParameterTypes(outputParameters, method.MethodReturnType, method.Attribute.IsOutputSerializeReferenceMember, method.Attribute.IsOutputSerializeBox) : new MethodParameterTypes(outputParameters, method.Attribute.IsOutputSerializeReferenceMember, method.Attribute.IsOutputSerializeBox);
         MethodParameterTypes historyInputParameterIndex = default(MethodParameterTypes), historyOutputParameterIndex = default(MethodParameterTypes);
         if (inputParameterTypes.IsParameter)
         {
             if (!ParameterIndexs.TryGetValue(inputParameterTypes, out historyInputParameterIndex))
             {
                 inputParameterTypes.Copy(++ParameterIndex);
                 ParameterIndexs.Add(inputParameterTypes, historyInputParameterIndex = inputParameterTypes);
             }
             method.InputParameterIndex = historyInputParameterIndex.Index;
             if (IsSimpleSerialize)
             {
                 method.IsSimpleSerializeInputParamter = historyInputParameterIndex.IsSimpleSerialize;
             }
         }
         if (outputParameterTypes.IsParameter)
         {
             if (!ParameterIndexs.TryGetValue(outputParameterTypes, out historyOutputParameterIndex))
             {
                 outputParameterTypes.Copy(++ParameterIndex);
                 ParameterIndexs.Add(outputParameterTypes, historyOutputParameterIndex = outputParameterTypes);
             }
             method.OutputParameterIndex = historyOutputParameterIndex.Index;
             if (IsSimpleSerialize)
             {
                 method.IsSimpleSerializeOutputParamter = historyOutputParameterIndex.IsSimpleSerialize;
             }
         }
         method.InputParameters  = MethodParameterPair.Get(inputParameters, historyInputParameterIndex);
         method.OutputParameters = MethodParameterPair.Get(outputParameters, historyOutputParameterIndex);
     }
     MethodParameterPair.SetInputParameter(method.OutputParameters, method.InputParameters);
 }