예제 #1
0
        private static void InitializeArgumentType(ISequenceManager sequenceManager,
                                                   DescriptionDataTable descriptionCollection, IArgumentDescription argumentDescription)
        {
            ArgumentDescription argDescription = (ArgumentDescription)argumentDescription;

            // 如果类型描述类为空且TypeData非空,则说明该argDescription已经被修改过,无需再执行处理
            if (argDescription.TypeDescription == null)
            {
                if (null == argDescription.Type)
                {
                    I18N i18N = I18N.GetInstance(Constants.I18nName);
                    throw new TestflowRuntimeException(ModuleErrorCode.TypeCannotLoad,
                                                       i18N.GetFStr("InvalidArgType", argDescription.Name));
                }
                return;
            }
            string fullName = GetFullName(argDescription.TypeDescription);

            if (descriptionCollection.ContainsType(fullName))
            {
                argDescription.Type = descriptionCollection.GetTypeData(fullName);
            }
            else
            {
                ITypeData typeData = sequenceManager.CreateTypeData(argDescription.TypeDescription);
                descriptionCollection.AddTypeData(fullName, typeData);
                argDescription.Type = typeData;
            }
            argDescription.TypeDescription = null;
        }
예제 #2
0
        public ComInterfaceDescription LoadAssemblyDescription(string path, DescriptionDataTable descriptionCollection)
        {
            IAssemblyInfo assemblyInfo = _sequenceManager.CreateAssemblyInfo();

            assemblyInfo.Path = path;
            string assemblyName = string.Empty;
            string version      = string.Empty;
            ComInterfaceDescription assemblyDescription = _loader.LoadAssemblyDescription(path, ref assemblyName, ref version);

            CheckAssemblyDescription(assemblyDescription, assemblyInfo.AssemblyName, path);

            assemblyInfo.AssemblyName    = assemblyName;
            assemblyInfo.Version         = version;
            assemblyDescription.Assembly = assemblyInfo;

            ModuleUtils.ValidateComDescription(_sequenceManager, assemblyDescription, descriptionCollection);
            assemblyInfo.Available = true;
            descriptionCollection.Add(assemblyDescription);
            // 如果一个AppDomain载入过多的程序集,则卸载该AppDomain,构造新的AppDomain
//            if (_assemblyCount > Constants.MaxAssemblyCount)
//            {
//                AppDomain.Unload(_loaderDomain);
//                Thread.MemoryBarrier();
//                _loaderDomain = AppDomain.CreateDomain(Constants.AppDomainName);
//                _loader = (AssemblyDescriptionLoader)_loaderDomain.CreateInstanceAndUnwrap(_assemblyFullName, _loaderName);
//                Interlocked.Exchange(ref _assemblyCount, 0);
//            }
            return(assemblyDescription);
        }
예제 #3
0
        public ClassInterfaceDescription GetClassDescription(ITypeData typeData, DescriptionDataTable descriptionDatas,
                                                             out string path, out string version)
        {
            string typeFullName = ModuleUtils.GetFullName(typeData);
            string assemblyName = typeData.AssemblyName;

            return(GetClassDescription(descriptionDatas, assemblyName, typeFullName, out path, out version));
        }
예제 #4
0
        public void DesigntimeInitialize()
        {
            _descriptionData?.Dispose();
            _loaderManager?.Dispose();

            _descriptionData = new DescriptionDataTable();
            _loaderManager   = new DescriptionLoaderManager();
            _loaderManager.LoadDefaultAssemblyDescription(_descriptionData,
                                                          _configData.GetProperty <string>("TestflowHome"));
        }
예제 #5
0
        // 使用TypeDescription信息更新VariableTypes和Class中的ClassType信息
        public static void ValidateComDescription(ISequenceManager sequenceManager, ComInterfaceDescription description,
                                                  DescriptionDataTable descriptionCollection)
        {
            int componentId = description.ComponentId;

            foreach (ITypeDescription typeDescription in description.TypeDescriptions)
            {
                ITypeData classType = GetTypeDataByDescription(sequenceManager, descriptionCollection, typeDescription);
                description.VariableTypes.Add(classType);
                if (null != typeDescription.Enumerations)
                {
                    description.Enumerations.Add(GetFullName(typeDescription), typeDescription.Enumerations);
                }
            }
            description.TypeDescriptions.Clear();
            description.TypeDescriptions = null;
            ((List <ITypeData>)description.VariableTypes).TrimExcess();

            foreach (ClassInterfaceDescription classDescription in description.Classes)
            {
                ITypeData classType = GetTypeDataByDescription(sequenceManager, descriptionCollection,
                                                               classDescription.ClassTypeDescription);
                classDescription.ClassType            = classType;
                classDescription.ClassTypeDescription = null;
            }
            ((List <IClassInterfaceDescription>)description.Classes).TrimExcess();

            I18N i18N = I18N.GetInstance(Constants.I18nName);

            foreach (IClassInterfaceDescription classDescription in description.Classes)
            {
                foreach (IFuncInterfaceDescription functionDescription in classDescription.Functions)
                {
                    // 配置实例属性配置方法和静态属性配置方法的描述信息
                    if (functionDescription.FuncType == FunctionType.InstancePropertySetter)
                    {
                        functionDescription.Description = i18N.GetStr("InstancePropertySetter");
                    }
                    else if (functionDescription.FuncType == FunctionType.StaticPropertySetter)
                    {
                        functionDescription.Description = i18N.GetStr("StaticPropertySetter");
                    }
                    foreach (IArgumentDescription argumentDescription in functionDescription.Arguments)
                    {
                        InitializeArgumentType(sequenceManager, descriptionCollection, argumentDescription);
                    }
                    ((List <IArgumentDescription>)functionDescription.Arguments).TrimExcess();
                    functionDescription.ClassType = classDescription.ClassType;
                    if (null != functionDescription.Return)
                    {
                        InitializeArgumentType(sequenceManager, descriptionCollection, functionDescription.Return);
                    }
                }
            }
        }
예제 #6
0
        public static ITypeData GetTypeDataByDescription(ISequenceManager sequenceManager,
                                                         DescriptionDataTable descriptionCollection, ITypeDescription typeDescription)
        {
            string    classFullName = GetFullName(typeDescription);
            ITypeData classType;

            if (!descriptionCollection.ContainsType(classFullName))
            {
                classType = sequenceManager.CreateTypeData(typeDescription);
                descriptionCollection.AddTypeData(classFullName, classType);
            }
            else
            {
                classType = descriptionCollection.GetTypeData(classFullName);
            }
            return(classType);
        }
예제 #7
0
        private void LoadMscorLibDescription(DescriptionDataTable descriptionCollection)
        {
            Assembly assembly = typeof(int).Assembly;
            ComInterfaceDescription mscoreLibDescription = _loader.LoadMscorlibDescription();

            IAssemblyInfo assemblyInfo = _sequenceManager.CreateAssemblyInfo();

            assemblyInfo.Path         = assembly.Location;
            assemblyInfo.AssemblyName = assembly.GetName().Name;

            assemblyInfo.Version = assembly.GetName().Version.ToString();

            CheckAssemblyDescription(mscoreLibDescription, assemblyInfo.AssemblyName, assemblyInfo.Path);
            ModuleUtils.ValidateComDescription(_sequenceManager, mscoreLibDescription, descriptionCollection);
            assemblyInfo.Available        = true;
            mscoreLibDescription.Assembly = assemblyInfo;
            descriptionCollection.Add(mscoreLibDescription);
        }
예제 #8
0
        public ClassInterfaceDescription GetClassDescription(DescriptionDataTable descriptionDatas, string assemblyName,
                                                             string typeFullName, out string path, out string version)
        {
            ClassInterfaceDescription classDescription = _loader.GetClassDescription(assemblyName,
                                                                                     typeFullName, out path, out version);
            // 初始化TypeData
            ITypeData classType = ModuleUtils.GetTypeDataByDescription(_sequenceManager, descriptionDatas,
                                                                       classDescription.ClassTypeDescription);

            classDescription.ClassType            = classType;
            classDescription.ClassTypeDescription = null;
            foreach (IFuncInterfaceDescription funcDescription in classDescription.Functions)
            {
                funcDescription.ClassType = classType;
            }
            CheckClassDescription(classDescription, assemblyName, typeFullName);
            return(classDescription);
        }
예제 #9
0
        public ITypeData GetPropertyType(ITypeData typeData, string property, DescriptionDataTable descriptionCollection)
        {
            ITypeDescription propertyTypeDescription = _loader.GetPropertyType(typeData.AssemblyName,
                                                                               ModuleUtils.GetFullName(typeData),
                                                                               property);

            if (null == propertyTypeDescription)
            {
                CheckPropertyDescription(typeData, property);
            }
            string    fullName = ModuleUtils.GetFullName(propertyTypeDescription);
            ITypeData propertyType;

            if (descriptionCollection.ContainsType(fullName))
            {
                propertyType = descriptionCollection.GetTypeData(fullName);
            }
            else
            {
                propertyType = _sequenceManager.CreateTypeData(propertyTypeDescription);
                descriptionCollection.AddTypeData(fullName, propertyType);
            }
            return(propertyType);
        }
예제 #10
0
        private void LoadFuncDefinitionDescriptions(DescriptionDataTable descriptionCollection, string testflowHome)
        {
            string funcDefLibPath = $"{testflowHome}lib{Path.DirectorySeparatorChar}funcdefs.dll";

            LoadAssemblyDescription(funcDefLibPath, descriptionCollection);
        }
예제 #11
0
 public void LoadDefaultAssemblyDescription(DescriptionDataTable descriptionCollection, string testflowHome)
 {
     LoadMscorLibDescription(descriptionCollection);
     LoadFuncDefinitionDescriptions(descriptionCollection, testflowHome);
 }