Exemple #1
0
        public void PerformRename(CodeTypeDeclarationCollection col)
        {
            if (col == null)
            {
                throw new ArgumentNullException("col");
            }

            Dictionary <string, string> map = new Dictionary <string, string>(StringComparer.Ordinal);

            map.Add("tagPOINT", "Point");

            CodeDomIterator it   = new CodeDomIterator();
            List <object>   list = it.Iterate(col);

            // Use the iterator so we make sure to reach nested types
            foreach (CodeTypeDeclaration ctd in FindUnmodifiedTypes(list))
            {
                NativeDefinedType definedNt = GetDefined(ctd);
                if (IsBadName(ctd.Name))
                {
                    foreach (NativeTypeDef possible in FindTypeDefsTargeting(definedNt))
                    {
                        if (!IsBadName(possible.Name))
                        {
                            map[ctd.Name] = possible.Name;
                        }
                    }
                }
            }

            SmartTypeRename(map, list);
            ResetCustomExpressions(list);
        }
Exemple #2
0
        /// <summary>
        /// Add any of the helper types that we need
        /// </summary>
        /// <param name="col"></param>
        /// <remarks></remarks>
        private void AddHelperTypes(CodeTypeDeclarationCollection col)
        {
            bool            addPInvokePointer = false;
            CodeDomIterator it   = new CodeDomIterator();
            List <object>   list = it.Iterate(col);

            foreach (object obj in list)
            {
                CodeTypeReference ctdRef = obj as CodeTypeReference;
                if (ctdRef != null && 0 == string.CompareOrdinal(ctdRef.BaseType, MarshalTypeFactory.PInvokePointerTypeName))
                {
                    addPInvokePointer = true;
                }
            }

            if (addPInvokePointer)
            {
                col.Add(MarshalTypeFactory.CreatePInvokePointerType());
            }
        }