Lightweight. NET object Lookup service and AOP development Framework Netop.core Source Commentary (5)-Other

Source: Internet
Author: User
Tags configuration settings log4net

The main services offered by Netop.core are class factory services and AOP services, and of course other small services:

First, the dialog context Netop.Core.Context.SessionContext
This dialog context can be used in both desktop and ASP. SetData and GetData to pass data in context. Methods are:
public static bool IsWeb ()
public static string Getappmappath (string path)
public static object GetData (String key)
public static object GetData (string key, bool istosession)
public static void SetData (string key, Object value)
public static void SetData (string key, object value, bool istosession)
public static void Remove (String key)

Second, buffer
Buffer Interface Icache and Ilocalcache (local buffering) are defined, Netop.Core.Cache.MicrosoftEnterpriseLibraryCache is a class of packaging Microsoft.Practices.EnterpriseLibrary.Caching implementation Ilocalcache interface, of course, can also To make a wrapper memcached implement the Icache interface class, there is time to share it later.
The local buffer service is called by Netop.Core.Cache.AppMemoryCache, and of course the configuration file needs to be configured:
The configuration for Microsoft.Practices.EnterpriseLibrary.Caching is:

<configSections>
<section name= "Cachingconfiguration" type= " Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching "/>
<section name= "netop.application" type= "Netop.core.configuration.configurationhandler,netop.core"/>
<section name= "log4net" type= "log4net. Config.log4netconfigurationsectionhandler,log4net "/>
</configSections>

<cachingconfiguration defaultcachemanager= "Default Cache Manager" >
<backingStores>
<add name= "InMemory" type= " Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching "/>
</backingStores>
<cacheManagers>
<add name= "Default Cache Manager"
Type= "Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching "
expirationpollfrequencyinseconds= "60"
maximumelementsincachebeforescavenging= "1000"
Numbertoremovewhenscavenging= "10"
Backingstorename= "InMemory"/>
</cacheManagers>
</cachingConfiguration>

Configuration under the <Netop.Application> node:

<Application.Cache>
<Provider>Netop.Core.Cache.MicrosoftEnterpriseLibraryCache,Netop.Core</Provider>
<ApplicationLog>Application.Log</ApplicationLog>

<ExpirationPolicy.IsSet>1</ExpirationPolicy.IsSet>
<ExpirationPolicy.Expiration>60</ExpirationPolicy.Expiration>
<expirationpolicy.typefullname>microsoft.practices.enterpriselibrary.caching.expirations.slidingtime, Microsoft.practices.enterpriselibrary.caching</expirationpolicy.typefullname>
</Application.Cache>

After these configuration settings, you can use the Appmemorycache method:

public static void Addcachedata (string key, Object data)
public static void Addcachedata (string key, object data, priority priority)
public static void Addcachedataforever (string key, Object data)
public static void Addcachedataforfiledependency (string key, object data, priority priority, string fileName)
public static void Adddataforabsolutetime (string key, object data, priority priority, TimeSpan Timefromnow)
public static void Adddataforabsolutetime (string key, object data, priority priority, System.DateTime Absolutetime)
public static void Adddataforslidingtime (string key, object data, priority priority, TimeSpan slidingexpiration)
public static void Adddataforslidingtime (string key, object data, priority priority, TimeSpan slidingexpiration, SYSTEM.D Atetime Originaltimestamp)
public static object Getcachedata (String key)
public static void Removecachedata (String key)
public static bool Contains (string key)
public static int Count

Third, the log
Netop.Core.Log.Log4Net is the Log4net wrapper class that implements the Netop.Core.Log.ILog interface, and the Ilog interface is:
public interface ILog
{
void Debug (object message);
void Write (object message);
void Write (Object message, Loginfotype loginfotype);
void Write (Object message, Exception Exception);
void Write (Object message, Exception Exception, Loginfotype loginfotype);
}
Netop.Core.Log.LogManager is the factory class that uses logs, the most important processing is how to extract their own encrypted connectionstring to log4net when logging log4net database configuration, details can be seen Getlog4netlogger method and phase The configuration code for the shutdown.

The configuration associated with log4net is:
<configSections>
<section name= "netop.application" type= "Netop.core.configuration.configurationhandler,netop.core"/>
<section name= "log4net" type= "log4net. Config.log4netconfigurationsectionhandler,log4net "/>
</configSections>
Additional configuration <log4net>, such as:
<log4net>
<logger name= "Log" >
<level value= "ERROR"/>
<appender-ref ref= "LogFile"/>
</logger>
<appender name= "LogFile" type= "log4net. Appender.fileappender ">
<param name= "File" value= "Log/log-file.txt"/>
<param name= "Appendtofile" value= "true"/>
<layout type= "log4net. Layout.patternlayout ">
<param name= "Conversionpattern" value= "%d [%t]%-5p [%c]%m%n"/>
</layout>
</appender>
</log4net>

What about the configuration in netop.application? If you want to configure additional logs yourself, you can add a configuration like this in Netop.application (of course, give xxxxxx and yyyyyy a good name), such as:
<XXXXXX>
<LogCategory>Netop.Core.Log.Log4Net,Netop.Core</LogCategory>
<LogParameter>YYYYYY</LogParameter>
</XXXXXX>
One of my own systems is configured for (and of course, more than one form of log configuration):
<Application.Log>
<LogCategory>Netop.Core.Log.Log4Net,Netop.Core</LogCategory>
<LogParameter>Log</LogParameter>
</Application.Log>
Of course, the log corresponding to the log4net in the configuration you want to do well (that you refer to the relevant Log4net Information Bar), above <LogParameter>Log</LogParameter> in the Log name is the above < Logger name= "Log" > log name, to correspond to the line.

Then the program can call:
Netop.Core.Log.ILog Log = Netop.Core.Log.LogManager.GetLogger ("Application.Log");
Log. Debug ("...");

By the way, in
<Application.Cache>
...
<ApplicationLog>Application.Log</ApplicationLog>
...
</Application.Cache>
In the <ApplicationLog>Application.Log</ApplicationLog> Refers to the log configuration of Application.Log, which can be configured to record related logs in Netop.core.cache.microsoftenterpriselibrarycache,netop.core.


Some of the other small services, such as verification code and so easy to use do not say.

Lightweight. NET Object Lookup Service and AOP development Framework source netop.core3.5:http://download.csdn.net/detail/tom_cat_xie_jxdy/9837303

Lightweight. Net Object Lookup Service and AOP Development Framework test Source: http://download.csdn.Net/detail/tom_cat_xie_jxdy/9837278

netop.core--lightweight. NET Object Lookup service and AOP Development Framework Documentation: HTTP://DOWNLOAD.CSDN.NET/DETAIL/TOM_CAT_XIE_JXDY/9838212




Lightweight. NET object Lookup service and AOP development Framework Netop.core Source Commentary (5)-Other

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.