zoukankan      html  css  js  c++  java
  • AutoCAD中static 和 instance class的区别

    using Autodesk.AutoCAD.ApplicationServices;
    
    using Autodesk.AutoCAD.Runtime;
    
    using Autodesk.AutoCAD.EditorInput;
    
    [assembly: CommandClass(typeof(CommandClasses.FirstClass))]
    
    [assembly: CommandClass(typeof(CommandClasses.SecondClass))]
    
    namespace CommandClasses
    
    {
    
      static public class FirstClass
    
      {
    
        private static int counter = 0;
    
        [Autodesk.AutoCAD.Runtime.CommandMethod("glob")]
    
        public static void global()
    
        {
    
          Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
    
          ed.WriteMessage("
    Counter value is: " + counter++);
    
        }
    
      }
    
      public class SecondClass
    
      {
    
        private int counter = 0;
    
        [Autodesk.AutoCAD.Runtime.CommandMethod("loc")]
    
        public void local()
    
        {
    
          Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
    
          ed.WriteMessage("
    Counter value is: " + counter++);
    
        }
    
      }
    
    }

    Here’s what happens when you execute the two commands in two separate documents:

    [From first drawing...]

    Command: glob

    Counter value is: 0

    Command: glob

    Counter value is: 1

    Command: glob

    Counter value is: 2

    Command: loc

    Counter value is: 0

    Command: loc

    Counter value is: 1

    Command: loc

    Counter value is: 2

    Command: new

    [From second drawing...]

    Command: glob

    Counter value is: 3

    Command: glob

    Counter value is: 4

    Command: glob

    Counter value is: 5

    Command: loc

    Counter value is: 0

    Command: loc

    Counter value is: 1

    Command: loc

    Counter value is: 2

  • 相关阅读:
    17_8_30 Mybatis 入门
    17_8_29 mysql 导入导出备份还原
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [MAC OSX
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
  • 原文地址:https://www.cnblogs.com/swtool/p/8283320.html
Copyright © 2011-2022 走看看