Example #1
0
        public string[] GetEnumItems(ITypeData typeData)
        {
            ComInterfaceDescription interfaceDescription = _descriptionData.GetComDescription(typeData.Name);
            string fullName = ModuleUtils.GetFullName(typeData);

            if (null != interfaceDescription)
            {
                return(interfaceDescription.Enumerations.ContainsKey(fullName)
                    ? interfaceDescription.Enumerations[fullName]
                    : new string[0]);
            }
            return(_loaderManager.GetEnumItemsByType(typeData));
        }
        // 添加Struct默认构造函数
        private static void AddStructDefaultConstructor(Type classType, ClassInterfaceDescription classDescription)
        {
            string descriptionStr = "Struct default constructor";
            FunctionInterfaceDescription funcDescription = new FunctionInterfaceDescription()
            {
                Category    = classDescription.ClassTypeDescription.Category,
                Description = descriptionStr,
                FuncType    = FunctionType.StructConstructor,
                IsGeneric   = false,
                Name        = $"{classType.Name}_Constructor"
            };

            funcDescription.Arguments = new List <IArgumentDescription>(1);
            funcDescription.Return    = null;
            funcDescription.Signature = ModuleUtils.GetSignature(classType.Name, funcDescription);
            classDescription.Functions.Add(funcDescription);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
0
        public bool Add(ComInterfaceDescription description)
        {
            bool addSuccess = false;

            _lock.EnterWriteLock();
            if (!_descriptions.ContainsKey(description.Assembly.AssemblyName))
            {
                _descriptions.Add(description.Assembly.AssemblyName, description);
                addSuccess = true;
            }
            if (_refAssemblyInfos.ContainsKey(description.Assembly.AssemblyName))
            {
                _refAssemblyInfos.Remove(description.Assembly.AssemblyName);
            }
            _lock.ExitWriteLock();

            ModuleUtils.SetComponentId(description, NextComId);

            return(addSuccess);
        }
Example #6
0
 public void RemoveAssembly(string assemblyName)
 {
     _lock.EnterWriteLock();
     if (_descriptions.ContainsKey(assemblyName))
     {
         ComInterfaceDescription description = _descriptions[assemblyName];
         _descriptions.Remove(assemblyName);
         foreach (ITypeData variableType in description.VariableTypes)
         {
             _typeMapping.Remove(ModuleUtils.GetFullName(variableType));
         }
         foreach (IClassInterfaceDescription classDescription in description.Classes)
         {
             _typeMapping.Remove(ModuleUtils.GetFullName(classDescription.ClassType));
         }
         if (!_refAssemblyInfos.ContainsKey(assemblyName))
         {
             _refAssemblyInfos.Add(assemblyName, description.Assembly);
         }
     }
     _lock.ExitWriteLock();
 }
        private void AddFieldSetterDescription(Type classType, ClassInterfaceDescription classDescription)
        {
            List <IArgumentDescription> staticProperties = GetFieldDescriptions(classType, BindingFlags.Static | BindingFlags.Public);

            if (null != staticProperties && staticProperties.Count > 0)
            {
                FunctionInterfaceDescription staticSetterDesp = new FunctionInterfaceDescription()
                {
                    Name           = CommonConst.SetStaticFieldFunc,
                    Arguments      = staticProperties,
                    ClassType      = classDescription.ClassType,
                    ComponentIndex = classDescription.ComponentIndex,
                    FuncType       = FunctionType.StaticFieldSetter,
                    Signature      = ModuleUtils.GetSignature(classType.Name, CommonConst.SetStaticFieldFunc),
                    Return         = null,
                    IsGeneric      = false
                };
                classDescription.Functions.Add(staticSetterDesp);
            }

            List <IArgumentDescription> instanceProperties = GetFieldDescriptions(classType, BindingFlags.Instance | BindingFlags.Public);

            if (null != instanceProperties && instanceProperties.Count > 0)
            {
                FunctionInterfaceDescription instanceSetterDesp = new FunctionInterfaceDescription()
                {
                    Name           = CommonConst.SetInstanceFieldFunc,
                    Arguments      = instanceProperties,
                    ClassType      = classDescription.ClassType,
                    ComponentIndex = classDescription.ComponentIndex,
                    FuncType       = FunctionType.InstanceFieldSetter,
                    Signature      = ModuleUtils.GetSignature(classType.Name, CommonConst.SetInstanceFieldFunc),
                    Return         = null,
                    IsGeneric      = false
                };
                classDescription.Functions.Add(instanceSetterDesp);
            }
        }
Example #8
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);
        }
Example #9
0
        public ITypeData GetTypeByName(string typename, string namespaceStr)
        {
            string fullName = ModuleUtils.GetFullName(namespaceStr, typename);

            return(_descriptionData.ContainsType(fullName) ? _descriptionData.GetTypeData(fullName) : null);
        }