public FunctionSignature WithSubstitutedTypes(ISet <Substitution> typeMap)
 {
     return(new FunctionSignature(originalDefinitionSyntax: OriginalDefinition,
                                  typeArguments: typeMap.Select(substitution => substitution.typeArgument).ToImmutableArray(),
                                  parameters: ParametersTypes.Select(p => p.WithSubstitutedTypes(typeMap)).ToImmutableArray(),
                                  returnType: ReturnType.WithSubstitutedTypes(typeMap)));
 }
Beispiel #2
0
        /// <summary>
        /// 打包脚本,获取委托信息等
        /// </summary>
        /// <returns>(函数名,涉及到的类,脚本体, 委托类型)</returns>
        public (string Flag, IEnumerable <Type> Types, string Script, Type Delegate) Package()
        {
            //未扣减脚本则构建脚本
            if (Script.Length == 0)
            {
                Builder();
            }


            //获取动态方法委托类型
            DelegateType = DelegateBuilder.GetDelegate(ParametersTypes.ToArray(), ReturnType);


            //返回包装函数信息
            return(MethodNameScript, UsingRecoder.Types, Script.ToString(), DelegateType);
        }
Beispiel #3
0
 DemonTypes
 (
     TypeDefinition joinPoint,
     MethodDefinition joinPointConstructor,
     TypeDefinition typeJoinPoint,
     MethodDefinition typeJoinPointConstructor,
     ParametersTypes parameters,
     ReturnTypes returns
 )
 {
     JoinPoint                = joinPoint;
     JoinPointConstructor     = joinPointConstructor;
     TypeJoinPoint            = typeJoinPoint;
     TypeJoinPointConstructor = typeJoinPointConstructor;
     Parameters               = parameters;
     Returns = returns;
 }
Beispiel #4
0
        private object convertValue(string stringValue, ParametersTypes parameterType)
        {
            switch (parameterType)
            {
            case ParametersTypes.Bool:
                return(Convert.ToBoolean(stringValue));

            case ParametersTypes.Long:
                return(Convert.ToInt64(stringValue));

            case ParametersTypes.Decimal:
                return(Convert.ToDecimal(stringValue));

            default:
                return(stringValue.ToString());
            }
        }
        public ParametersTypes ReadFileTypes()
        {
            FileInfo fileInfo = new FileInfo(FullNameFileTypes);

            if (!fileInfo.Exists)
            {
                return(null);
            }

            List <string> listType = InitializeListType();
            Dictionary <string, List <string> > keysType = IninializeDictionatyTypeName();

            Dictionary <string, string> dictionaryTranslate = GetTranslateTypes();
            Dictionary <string, bool>   usingType           = GetUsingTypes();

            #region Read file types
            using (XmlReader xmlReader = XmlReader.Create(FullNameFileTypes))
            {
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element &&
                        xmlReader.Name == "ChildObjects")
                    {
                        xmlReader.Read();

                        do
                        {
                            string typeName = xmlReader.LocalName;

                            if (dictionaryTranslate.ContainsKey(typeName))
                            {
                                if (usingType.ContainsKey(typeName))
                                {
                                    if (usingType[typeName])
                                    {
                                        string typeNameTranslation = dictionaryTranslate[typeName];

                                        if (!string.IsNullOrWhiteSpace(typeNameTranslation))
                                        {
                                            listType.Add(typeNameTranslation);

                                            xmlReader.Read();

                                            string typeValue = xmlReader.Value;

                                            if (!string.IsNullOrWhiteSpace(typeValue))
                                            {
                                                if (keysType.ContainsKey(typeNameTranslation))
                                                {
                                                    keysType.First(f => f.Key == typeNameTranslation).Value.Add(typeValue);
                                                }
                                                else
                                                {
                                                    keysType.Add(typeNameTranslation, new List <string>()
                                                    {
                                                        typeValue
                                                    });
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            xmlReader.Read();
                        }while (!(xmlReader.NodeType == XmlNodeType.EndElement &&
                                  xmlReader.Name == "ChildObjects"));
                    }
                }
                xmlReader.Close();
            }
            #endregion

            foreach (var item in keysType)
            {
                item.Value.Sort();
            }

            ParametersTypes types = new ParametersTypes()
            {
                UniqueTypes    = listType.Distinct().ToList(),
                DictionaryType = keysType
            };

            return(types);
        }
 public override string ToString()
 {
     return(string.Format("{0} .ctor({1})", DeclaringType, string.Join(", ", ParametersTypes.Select(t => t.Name))));
 }