Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Declare class as partial class in CodeDOM

Declare class as partial class in CodeDOM

Scheduled Pinned Locked Moved C#
comtoolsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ista
    wrote on last edited by
    #1

    I have this code: Stream s = File.Open(@destinationDirectory + tableName + ".cs", FileMode.Create); StreamWriter sw = new StreamWriter(s); CodeGeneratorOptions cop = new CodeGeneratorOptions(); CodeNamespace cdm = new CodeNamespace(nameSpace); CSharpCodeProvider cscProvider = new CSharpCodeProvider(); ICodeGenerator cscg = cscProvider.CreateGenerator(sw); CodeTypeDeclaration ctd = new CodeTypeDeclaration(tableName); ctd.IsClass = true; ctd.TypeAttributes = System.Reflection.TypeAttributes.Public; This works just fine for creating the class. But, I want to declare this a partial class for this reason. I have a main code file with methods and what not. But, I am creating the properties for the class dynamically. So I want this class to be a partial class file that is never opened and can be replaced any time. So I need to say "public partial class". Does anyone know how? Thanks, Nick

    -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

    I 1 Reply Last reply
    0
    • I Ista

      I have this code: Stream s = File.Open(@destinationDirectory + tableName + ".cs", FileMode.Create); StreamWriter sw = new StreamWriter(s); CodeGeneratorOptions cop = new CodeGeneratorOptions(); CodeNamespace cdm = new CodeNamespace(nameSpace); CSharpCodeProvider cscProvider = new CSharpCodeProvider(); ICodeGenerator cscg = cscProvider.CreateGenerator(sw); CodeTypeDeclaration ctd = new CodeTypeDeclaration(tableName); ctd.IsClass = true; ctd.TypeAttributes = System.Reflection.TypeAttributes.Public; This works just fine for creating the class. But, I want to declare this a partial class for this reason. I have a main code file with methods and what not. But, I am creating the properties for the class dynamically. So I want this class to be a partial class file that is never opened and can be replaced any time. So I need to say "public partial class". Does anyone know how? Thanks, Nick

      -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #2

      nevermind, its a boolean property in the code type declaration

      -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

      M 1 Reply Last reply
      0
      • I Ista

        nevermind, its a boolean property in the code type declaration

        -------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog

        M Offline
        M Offline
        Marcos Accioly
        wrote on last edited by
        #3

        Happens to me all the time: ask a question to which I didn't bother enough/was too deep thinking to quickly find the answer myself. Best regards... :-D Vini - Csharpian

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups