示例#1
0
 public CodeDomCodeVariable(DTE dte, CodeElement parent, string name, CodeTypeRef type, vsCMAccess access)
     : base(dte, name)
 {
     CodeObject                   = new CodeMemberField(CodeDomCodeTypeRef.ToCodeTypeReference(type), name);
     CodeObject.Attributes        = VSAccessToMemberAccess(access);
     CodeObject.UserData[CodeKey] = this;
     this.parent                  = parent;
 }
示例#2
0
        public CodeElement AddBase(object Base, object Position)
        {
            string             clsName = ObjectToClassName(Base);
            CodeDomCodeTypeRef ctr     = new CodeDomCodeTypeRef(DTE, clsName);

            CodeObject.BaseTypes.Insert(PositionToBaseIndex(Position), ctr.CodeObject);
            return(ctr);
        }
示例#3
0
        public CodeDomCodeParameter(DTE dte, CodeElement parent, string name, CodeTypeRef type)
            : base(dte, name)
        {
            this.parent = parent;
            this.type   = type;

            CodeObject = new CodeParameterDeclarationExpression(
                CodeDomCodeTypeRef.ToCodeTypeReference(type),
                name);
            CodeObject.UserData[CodeKey] = this;
        }
示例#4
0
        public CodeDomCodeProperty(DTE dte, CodeClass parent, string name, string putName, object type, vsCMAccess access)
            : base(dte, name)
        {
            this.parent = parent;

            CodeMemberProperty prop = new CodeMemberProperty();

            prop.Name = name;
            prop.UserData[CodeKey] = this;
            CodeObject             = prop;

            prop.Type       = CodeDomCodeTypeRef.ToCodeTypeReference(ObjectToTypeRef(type));
            prop.Attributes = VSAccessToMemberAccess(access);
        }
示例#5
0
        private CodeTypeRef GetSystemType(string typeName)
        {
            if (systemTypes == null)
            {
                systemTypes = new Dictionary <string, CodeTypeRef>();
            }

            CodeTypeRef res;

            if (systemTypes.TryGetValue(typeName, out res))
            {
                return(res);
            }

            res = new CodeDomCodeTypeRef(dte, typeName);
            systemTypes[typeName] = res;

            return(res);
        }
示例#6
0
        public static CodeTypeReference ToCodeTypeReference(CodeTypeRef typeRef)
        {
            if (null == typeRef)
            {
                throw new ArgumentNullException("typeRef");
            }
            CodeDomCodeTypeRef cdTypeRef = typeRef as CodeDomCodeTypeRef;

            if (cdTypeRef != null)
            {
                return(cdTypeRef.CodeObject);
            }

            CodeTypeReference ctr = new CodeTypeReference();

            ctr.BaseType = typeRef.AsFullName;
            if (typeRef.Rank != 0)
            {
                ctr.ArrayRank        = typeRef.Rank;
                ctr.ArrayElementType = ToCodeTypeReference(typeRef.ElementType);
            }
            ctr.UserData[CodeKey] = cdTypeRef;
            return(ctr);
        }