惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
博客园_首页
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
N
News | PayPal Newsroom
S
Security Archives - TechRepublic
量子位
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
C
Cisco Blogs
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Scott Helme
Scott Helme
S
Securelist
Security Latest
Security Latest
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
美团技术团队
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
月光博客
月光博客
T
Tailwind CSS Blog
Cloudbric
Cloudbric
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
D
DataBreaches.Net
博客园 - 【当耐特】
有赞技术团队
有赞技术团队

博客园 - IT 笔记

Subversion Revert File will not be shown in Modification Surprise vb.net WinForm don't require instance to access the instance value Properties.Settings show error 'System.Windows.Forms.PropertyStore' does not contain a definition for 'Settings' Add Image in MS Report RDLC by using Embedded Image 王爽汇编 Lab 13 Question 1, 用两个程序实现 王爽汇编语言 实验11 王爽汇编语言 检测点11.2 王爽 汇编语言程序课程设计1 王爽 汇编语言程序设计实验10,题三,数值转换。(Assembly experiment Convert HEX to Decimal and Show on screen ) 王爽 汇编语言程序设计 实验9 (Assembly Language Study) 王爽 汇编语言程序设计 检测点9.1 第2题 The NTVDM CPU has encountered an illegal instruction. CS:0006 IP:130a .... select files by multiple extension name Access Denied when running Spring.IocQuickStart.MovieFinder using vb.net read unix style text file How to install autotrace in fontforge My first postscript program .net 2 config - IT 笔记 A generic winform skeleton support interactive UI during large job process
Spring.NET Installation and setup the first program
IT 笔记 · 2011-12-08 · via 博客园 - IT 笔记

1. Download the file in blue box from website http://www.springsource.com/, then execute the exe file to install it

image

2. Create a sample porject called DataAccess in C# console program

3. Add C:\Program Files\Spring.NET 1.3.2\bin\net\2.0\release\Spring.Core.dll  (2.0 means framework 2)

The solution file is like

image

The code is like below

Program.cs

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Text;
   4: using Spring.Context;
   5: using Spring.Context.Support; 
   6: namespace DataAccess
   7: {
   8:   class MainApp
   9:   { 
  10:     static void Main()
  11:     {
  12:       DataAccessObject daoCategories = new Categories();
  13:       daoCategories.Run();
  14:  
  15:       DataAccessObject daoProducts = new Products();
  16:       daoProducts.Run();
  17:  
  18:       IApplicationContext context = ContextRegistry.GetContext(); 
  19:       DataAccessObject DAO = (DataAccessObject)context.GetObject("DataAccessObject");
  20:       DAO.Run();
  21:  
  22:       // Wait for user
  23:       Console.ReadKey();
  24:     }
  25:   }
  26:  
  27:   abstract class DataAccessObject
  28:   {
  29:     protected string connectionString; 
  30:  
  31:     public virtual void Connect()
  32:     {
  33:         Console.WriteLine("Connect '" + connectionString + "'"); 
  34:     }
  35:  
  36:     public abstract void Select();
  37:     public abstract void Process();
  38:  
  39:     public virtual void Disconnect()
  40:     {
  41:         Console.WriteLine("Discount\r\n");
  42:     }
  43:  
  44:     // The 'Template Method'
  45:     public void Run()
  46:     {
  47:       Connect();
  48:       Select();
  49:       Process();
  50:       Disconnect();
  51:     }
  52:   }
  53:   
  54:   class Categories : DataAccessObject
  55:   {
  56:     public override void Select()
  57:     {
  58:         Console.WriteLine("Get Categories"); 
  59:     }
  60:  
  61:     public override void Process()
  62:     {
  63:         Console.WriteLine("Process Categories"); 
  64:     }
  65:   }
  66:   
  67:   class Products : DataAccessObject
  68:   {
  69:     public override void Select()
  70:     {
  71:         Console.WriteLine("Get Products"); 
  72:     }
  73:  
  74:     public override void Process()
  75:     {
  76:         Console.WriteLine("Process Products"); 
  77:     }
  78:   }
  79: } 

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="spring">
      <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
    </sectionGroup>
  </configSections>
  <spring>
    <context>
      <resource uri="spring.xml.config"/>
    </context> 
  </spring>
</configuration>

spring.xml.config

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
  <object id="DataAccessObject" type="DataAccess.Products">
    <property name="connectionString" value="C:\db\northwind.mdb"/>
  </object>
</objects>

Running the application, the output is like

image

Now modify the spring.xml.config as below, only change “Products” to “Categories”

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
  <object id="DataAccessObject" type="DataAccess.Categories">
    <property name="connectionString" value="C:\db\northwind.mdb"/>
  </object>
</objects>

The output will be changed to

image

See the red highlight, it has changed the program direction without recompile the exe.