Code Snnipt for Unity Framework

Unity是一个不错的DI的框架,最近在写程序的时候一直有在使用,今天收了些时间写了关于它在app.config文件时会用到snippet.

(1) configSections 里的引用信息

 

(2) 关于container的配置信息

<?xml version="1.0" encoding="utf-8"?>

<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

  <Header>

    <Title>

      <!-- _locID_text="title" _locComment="" -->Define Unity Configuration Section Info</Title>

    <Author>Microsoft Corporation</Author>

    <Shortcut>UnitConfigSection</Shortcut>

    <Description>

      <!-- _locID_text="description" _locComment="" -->Define Unity Configuration Section Info</Description>

    <SnippetTypes>

      <SnippetType>Expansion</SnippetType>

      <SnippetType>SurroundsWith</SnippetType>

    </SnippetTypes>

  </Header>

  <Snippet>

    <Declarations>

      <Literal>

        <ID>name</ID>

        <ToolTip>

          <!-- _locID_text="tooltip" _locComment="" -->Define Unity Configuration information</ToolTip>

        <Default>element</Default>

      </Literal>

    </Declarations>

    <Code Language="XML"><![CDATA[ <section name="unity"

           type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,

                 Microsoft.Practices.Unity.Configuration" />]]></Code>

  </Snippet>

</CodeSnippet>

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  
<Header>
    
<Title>
      
<!-- _locID_text="title" _locComment="" -->Define Unity Container information</Title>
    
<Author>Microsoft Corporation</Author>
    
<Shortcut>element</Shortcut>
    
<Description>
      
<!-- _locID_text="description" _locComment="" -->Define Unity Container information</Description>
    
<SnippetTypes>
      
<SnippetType>Expansion</SnippetType>
      
<SnippetType>SurroundsWith</SnippetType>
    
</SnippetTypes>
  
</Header>
  
<Snippet>
    
<Declarations>
      
<Literal>
        
<ID>name</ID>
        
<ToolTip>
          
<!-- _locID_text="tooltip" _locComment="" -->Define Unity Container information.</ToolTip>
        
<Default>element</Default>
      
</Literal>
    
</Declarations>
    
<Code Language="XML"><![CDATA[
    <unity>
       <containers>

      <container name="containerOne">
        <types>
          <!-- Default (un-named) mapping for IMyInterface to MyRealObject-->
          <type type="IMyInterface" mapTo="MyRealObject" name="MyRealObject" >
            <lifetime type="singleton" />
          </type>
      
      </container>

    </containers>

  </unity>
    
]]></Code>
  
</Snippet>
</CodeSnippet
原文地址:https://www.cnblogs.com/buhaiqing/p/1372581.html