Ejemplo n.º 1
0
 public static CodeNamespace AddInterface(this CodeNamespace codeNamespace, string interfaceName)
 {
     return(codeNamespace.AddInterface(new CodeTypeDeclaration(interfaceName)
     {
         IsInterface = true
     }));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the interface.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns>The interface.</returns>
        public static CodeInterface CreateInterface(this ProjectItem instance)
        {
            string interfaceName = string.Format("I{0}", instance.Name);
            string path          = instance.FileNames[1].Replace(instance.Name, interfaceName);

            CodeNamespace codeNamespace = instance.GetNameSpace();

            string nameSpace = codeNamespace.FullName;

            object[] bases = { };

            CodeNamespace interfaceNameSpace = instance.ProjectItems.ContainingProject.CodeModel.AddNamespace(
                nameSpace, path);

            CodeInterface codeInterface = interfaceNameSpace.AddInterface(
                interfaceName, -1, bases, vsCMAccess.vsCMAccessPublic);

            CodeClass codeClass = instance.GetFirstClass();

            if (codeClass != null)
            {
                object interfaceClass = interfaceName;
                codeClass.AddImplementedInterface(interfaceClass, 0);
            }

            return(codeInterface);
        }
Ejemplo n.º 3
0
 protected override object NewInterface(NewCodeElementItemParams newItemParams, string path)
 {
     return(_namespace.AddInterface(path,
                                    newItemParams.Position,
                                    newItemParams.ImplementedInterfaces.ToCSVDTEParameter(),
                                    newItemParams.AccessKind));
 }
Ejemplo n.º 4
0
 public CodeInterfaceDeclarationWriterTests()
 {
     codeElementWriter = new CodeInterfaceDeclarationWriter(new GoConventionService());
     writer            = LanguageWriter.GetLanguageWriter(GenerationLanguage.Go, DefaultPath, DefaultName);
     tw = new StringWriter();
     writer.SetTextWriter(tw);
     root            = CodeNamespace.InitRootNamespace();
     parentInterface = new () {
         Name = "parentClass"
     };
     root.AddInterface(parentInterface);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Finds the or create interface element.
 /// </summary>
 /// <param name="cn">The cn.</param>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public static CodeInterface2 FindOrCreateInterfaceElement(CodeNamespace cn, string name)
 {
     foreach (CodeElement ce in cn.Members)
     {
         if (ce is CodeInterface2 && ce.Name == name)
         {
             return((CodeInterface2)ce);
         }
     }
     return
         ((CodeInterface2)
          cn.AddInterface(name, 0 /* au debut */, null /*classes de bases*/, vsCMAccess.vsCMAccessPublic));
 }
Ejemplo n.º 6
0
 public ShellCodeInterface AddInterface(string Name, object Position, object Bases, vsCMAccess Access)
 {
     return(new ShellCodeInterface(_namespace.AddInterface(Name, Position, Bases, Access) as CodeInterface2));
 }