/wojilu/Web/Context/MvcContext.cs
https://bitbucket.org/kingshine/wojilu · C# · 775 lines · 387 code · 123 blank · 265 comment · 107 complexity · 43d3ed5918253db948a08ecbe507957a MD5 · raw file
- /*
- * Copyright 2010 www.wojilu.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- using System;
- using System.Collections;
- using System.Collections.Specialized;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Web;
- using wojilu.Data;
- using wojilu.ORM;
- using wojilu.Web.Mvc;
- using wojilu.Web.Mvc.Routes;
- using wojilu.Web.Utils;
- namespace wojilu.Web.Context {
- /// <summary>
- /// mvc ÉÏÏÂÎÄÊý¾Ý£º¼´Õû¸öÖ´ÐÐÁ÷³ÌÖг£ÓõÄÊý¾Ý·â×°
- /// </summary>
- public class MvcContext {
- private IWebContext _context;
- private MvcContextUtils _thisUtils;
- public MvcContext( IWebContext context ) {
- _context = context;
- _thisUtils = new MvcContextUtils( this );
- }
- /// <summary>
- /// ¸ß¼¶¹¤¾ß·½·¨MvcContextUtils
- /// </summary>
- public MvcContextUtils utils {
- get {
- if (_thisUtils != null) return _thisUtils;
- _thisUtils = new MvcContextUtils( this );
- return _thisUtils;
- }
- }
- /// <summary>
- /// web ÔʼÊý¾ÝºÍ·½·¨·â×°
- /// </summary>
- public IWebContext web { get { return _context; } }
- private Result _errors = new Result();
- /// <summary>
- /// »ñÈ¡µ±Ç°ctxÖеĴíÎóÐÅÏ¢
- /// </summary>
- public Result errors { get { return _errors; } }
- /// <summary>
- /// µ±Ç°Â·ÓÉÐÅÏ¢
- /// </summary>
- public Route route { get { return utils.getRoute(); } }
- /// <summary>
- /// µ±Ç°¿ØÖÆÆ÷
- /// </summary>
- public ControllerBase controller { get { return utils.getController(); } }
- /// <summary>
- /// µ±Ç° owner(±»·ÃÎʵĶÔÏóÐÅÏ¢)
- /// </summary>
- public IOwnerContext owner { get { return utils.getOwnerContext(); } }
- /// <summary>
- /// ·ÃÎÊÕßµÄÐÅÏ¢
- /// </summary>
- public IViewerContext viewer { get { return utils.getViewerContext(); } }
- /// <summary>
- /// µ±Ç° app
- /// </summary>
- public IAppContext app { get { return utils.getAppContext(); } }
- private PageMeta _pageMeta = new PageMeta();
- /// <summary>
- /// Ò³ÃæÔªÐÅÏ¢(°üÀ¨Title/Keywords/Description/RssLink)
- /// </summary>
- /// <returns></returns>
- public PageMeta GetPageMeta() {
- return _pageMeta;
- }
- //---------------------------------------------------------
- private Hashtable _contextItems = new Hashtable();
- /// <summary>
- /// ¸ù¾Ý key »ñÈ¡´æ´¢ÔÚ ctx ÖÐijÏîµÄÖµ
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public Object GetItem( String key ) {
- return _contextItems[key];
- }
- /// <summary>
- /// ½«Ä³¸ö¶ÔÏó´æ´¢ÔÚ ctx ÖУ¬·½±ã²»Í¬µÄ controller »ò action Ö®¼äµ÷ÓÃ
- /// </summary>
- /// <param name="key"></param>
- /// <param name="val"></param>
- public void SetItem( String key, Object val ) {
- _contextItems[key] = val;
- }
- /// <summary>
- /// ÅÐ¶Ï ctx µÄ´æ´¢Æ÷ÖÐÊÇ·ñ¾ßÓÐij¸ö key ¡£
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public Boolean HasItem( string key ) {
- return _contextItems.ContainsKey( key );
- }
- //---------------------------------------------------------
- /// <summary>
- /// »ñÈ¡Á´½Ó¶ÔÏó
- /// </summary>
- /// <returns></returns>
- public Link GetLink() {
- return new Link( this );
- }
- private UrlInfo _url;
- /// <summary>
- /// »ñÈ¡¾¹ý·â×°µÄ url ÐÅÏ¢
- /// </summary>
- public UrlInfo url { get { return getUrl(); } }
- private UrlInfo getUrl() {
- if (_url == null) {
- _url = new UrlInfo( _context.Url, _context.PathApplication, _context.PathInfo );
- }
- return _url;
- }
- /// <summary>
- /// ÉèÖõ±Ç°ÍøÖ·£¬ÓÃÓÚ×Ô¶¨ÒåÍøÖ·
- /// </summary>
- /// <param name="url"></param>
- public void setUrl( String url ) {
- _url = new UrlInfo( url, _context.PathApplication, _context.PathInfo );
- }
- /// <summary>
- /// µ±Ç°¿Í»§¶ËÉÏ´«µÄËùÓÐÎļþ
- /// </summary>
- /// <returns></returns>
- public List<HttpFile> GetFiles() {
- HttpFileCollection files = _context.getUploadFiles();
- List<HttpFile> list = new List<HttpFile>();
- for (int i = 0; i < files.Count; i++) {
- list.Add( new HttpFile( files[i] ) );
- }
- return list;
- }
- /// <summary>
- /// µ±Ç°¿Í»§¶ËÉÏ´«µÄµÚÒ»¸öÎļþ
- /// </summary>
- /// <returns></returns>
- public HttpFile GetFileSingle() {
- return this.GetFiles().Count == 0 ? null : GetFiles()[0];
- }
- /// <summary>
- /// ¿Í»§¶ËÊÇ·ñÉÏ´«ÁËÎļþ
- /// </summary>
- public Boolean HasUploadFiles {
- get { return GetFiles().Count > 0 && GetFileSingle().ContentLength > 10; }
- }
- /// <summary>
- /// µ±Ç° ctx ÖÐÊÇ·ñÓдíÎóÐÅÏ¢
- /// </summary>
- public Boolean HasErrors {
- get { return errors.HasErrors; }
- }
- /// <summary>
- /// ¿Í»§¶ËÌá½»µÄ HttpMethod£¬·µ»ØGET/POST/DELETE/PUT µÈ
- /// </summary>
- public String HttpMethod { get { return getMethod(); } }
- /// <summary>
- /// µ±Ç°¿Í»§¶ËÌá½»·½·¨ÊÇ·ñÊÇ GET ·½·¨
- /// </summary>
- public Boolean IsGetMethod {
- get { return strUtil.EqualsIgnoreCase( "get", this.HttpMethod ); }
- }
- private String getMethod() {
- if ("POST".Equals( _context.post( "_httpmethod" ) )) return "POST";
- if ("DELETE".Equals( _context.post( "_httpmethod" ) )) return "DELETE";
- if ("PUT".Equals( _context.post( "_httpmethod" ) )) return "PUT";
- return _context.ClientHttpMethod;
- }
- private MethodInfo _actionMethodInfo;
- internal void setActionMethodInfo( MethodInfo mi ) {
- _actionMethodInfo = mi;
- }
- public MethodInfo ActionMethodInfo {
- get {
- if (_actionMethodInfo == null) {
- }
- return _actionMethodInfo;
- }
- }
- private List<Attribute> _attributes;
- public List<Attribute> ActionMethods {
- get {
- if (_attributes == null) {
- Object[] attrs = this.controller.utils.getAttributesAll( this.ActionMethodInfo );
- _attributes = new List<Attribute>();
- foreach (Object obj in attrs) {
- _attributes.Add( (Attribute)obj );
- }
- }
- return _attributes;
- }
- }
- /// <summary>
- /// ÇåÀíËùÓÐ×ÊÔ´£¬×¼±¸Å׳öÒì³£
- /// </summary>
- /// <param name="httpStatus">¸ø¿Í»§¶ËµÄ httpStatus ״̬ÐÅÏ¢</param>
- /// <param name="msg"></param>
- /// <returns></returns>
- public MvcException ex( String httpStatus, String msg ) {
- utils.clearResource();
- return new MvcException( httpStatus, msg );
- }
- /// <summary>
- /// ³ÊÏÖ json µ½¿Í»§¶Ë
- /// </summary>
- /// <param name="jsonContent"></param>
- public void RenderJson( String jsonContent ) {
- _context.RenderJson( jsonContent );
- }
- /// <summary>
- /// ³ÊÏÖ xml µ½¿Í»§¶Ë
- /// </summary>
- /// <param name="xmlContent"></param>
- public void RenderXml( String xmlContent ) {
- _context.RenderXml( xmlContent );
- }
- //---------------------------------------- Get ---------------------------------------------
- /// <summary>
- /// »ñÈ¡ url ÖеÄijÏîÖµ£¬½á¹ûÒѱ»¹ýÂË(²»ÔÊÐíhtml)
- /// </summary>
- /// <param name="queryItem"></param>
- /// <returns></returns>
- public String Get( String queryItem ) {
- String val = _context.get( queryItem );
- return checkClientValue( val );
- }
- /// <summary>
- /// ¼ì²é url ÖÐÊÇ·ñ¾ßÓÐijÏî key
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public Boolean GetHas( String key ) {
- return _context.getHas( key );
- }
- /// <summary>
- /// ´Ó url µÄ²éѯÐÅÏ¢ (query string) ÖлñÈ¡ id ÁÐ±í£¬½á¹û¾¹ýÁËÑéÖ¤£¬ÊÇÀàÐͰ²È«µÄ¡£Èç¹û²»ºÏ·¨£¬Ôò·µ»Ønull
- /// </summary>
- /// <param name="idname"></param>
- /// <returns></returns>
- public String GetIdList( String idname ) {
- String ids = Get( idname );
- if (!cvt.IsIdListValid( ids )) {
- return null;
- }
- return ids;
- }
- /// <summary>
- /// ´Ó url ÖлñȡijÏîµÄÖµ£¬²¢×ª»»³ÉÕûÊý
- /// </summary>
- /// <param name="queryItemName"></param>
- /// <returns></returns>
- public int GetInt( String queryItemName ) {
- if ((_context.get( queryItemName ) != null) && cvt.IsInt( _context.get( queryItemName ) )) {
- return int.Parse( _context.get( queryItemName ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó url ÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É Decimal
- /// </summary>
- /// <param name="queryItemName"></param>
- /// <returns></returns>
- public Decimal GetDecimal( String queryItemName ) {
- if ((_context.get( queryItemName ) != null)) {
- return cvt.ToDecimal( _context.get( queryItemName ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó url ÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É Double
- /// </summary>
- /// <param name="queryItemName"></param>
- /// <returns></returns>
- public Double GetDouble( String queryItemName ) {
- if ((_context.get( queryItemName ) != null)) {
- return cvt.ToDouble( _context.get( queryItemName ) );
- }
- return 0;
- }
- /// <summary>
- /// »ñÈ¡¿Í»§¶Ë ip µØÖ·
- /// </summary>
- public String Ip { get { return getIp(); } }
- private String getIp() {
- String ip;
- if (_context.ClientVar( "HTTP_VIA" ) != null)
- ip = _context.ClientVar( "HTTP_X_FORWARDED_FOR" );
- else
- ip = _context.ClientVar( "REMOTE_ADDR" );
- return checkIp( ip );
- }
- private String checkIp( String ip ) {
- int maxLength = 3 * 15 + 2;
- String unknow = "unknow";
- if (strUtil.IsNullOrEmpty( ip ) || ip.Length > maxLength || ip.Length < 7) return unknow;
- char[] arr = ip.ToCharArray();
- foreach (char c in arr) {
- if (!char.IsDigit( c ) && c != '.' && c != ',') return unknow;
- }
- return ip;
- }
- //------------------------------------------- POST ------------------------------------------
- /// <summary>
- /// »ñÈ¡¿Í»§¶Ë post µÄÖµ£¬½á¹ûÒѱ»¹ýÂË(²»ÔÊÐíhtml)
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public String Post( String postItem ) {
- String val = _context.post( postItem );
- return checkClientValue( val );
- }
- /// <summary>
- /// ¼ì²é¿Í»§¶Ë post µÄÊý¾ÝÖÐÊÇ·ñÓÐijÏî key
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- public Boolean PostHas( String key ) {
- return _context.postHas( key );
- }
- /// <summary>
- /// ´Ó¿Í»§¶Ë post µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É decimal
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public Decimal PostDecimal( String postItem ) {
- if (_context.post( postItem ) != null) {
- return cvt.ToDecimal( _context.post( postItem ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó¿Í»§¶Ë post µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É Double
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public Double PostDouble( String postItem ) {
- if (_context.post( postItem ) != null) {
- return cvt.ToDouble( _context.post( postItem ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó¿Í»§¶Ë post µÄÊý¾ÝÖлñÈ¡ id ÁÐ±í£¬½á¹û¾¹ýÁËÑéÖ¤£¬ÊÇÀàÐͰ²È«µÄ
- /// </summary>
- /// <param name="idname"></param>
- /// <returns></returns>
- public String PostIdList( String idname ) {
- String ids = Post( idname );
- if (!cvt.IsIdListValid( ids )) {
- return null;
- }
- return ids;
- }
- /// <summary>
- /// ´Ó¿Í»§¶Ë post µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³ÉÕûÊý
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public int PostInt( String postItem ) {
- if ((_context.post( postItem ) != null) && cvt.IsInt( _context.post( postItem ) )) {
- return int.Parse( _context.post( postItem ) );
- }
- return 0;
- }
- /// <summary>
- /// ¼ì²é¿Í»§¶ËÊÇ·ñÒѾ¹´Ñ¡Á˶àÑ¡¿ò£¬Èç¹û¹´Ñ¡·µ»Ø1£¬·ñÔò·µ»Ø0
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns>Èç¹û¹´Ñ¡·µ»Ø1£¬·ñÔò·µ»Ø0</returns>
- public int PostIsCheck( String postItem ) {
- String target = Post( postItem );
- if (strUtil.HasText( target ) && target.Equals( "on" )) {
- return 1;
- }
- return 0;
- }
- /// <summary>
- /// ´Ó¿Í»§¶Ë post µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³Éʱ¼äÀàÐÍ¡£Èç¹ûÎÞÌá½»Öµ»ò¸ñʽ´íÎó£¬Ôò·µ»Øµ±Ç°Ê±¼äDateTime.Now
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public DateTime PostTime( String postItem ) {
- if (_context.post( postItem ) != null) {
- return cvt.ToTime( _context.post( postItem ) );
- }
- return DateTime.Now;
- }
- /// <summary>
- /// »ñÈ¡¿Í»§¶Ë post µÄ html£¬½á¹ûÒѱ»¹ýÂË£¬Ö»ÓÐÔÚ°×Ãûµ¥ÖÐµÄ tag ²Å±»ÔÊÐí
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public String PostHtml( String postItem ) {
- String val = _context.post( postItem );
- if (val != null) {
- if (this.viewer != null && this.viewer.IsAdministrator()) return val;
- val = strUtil.TrimHtml( val );
- val = HtmlFilter.Filter( val );
- }
- return val;
- }
- /// <summary>
- /// »ñÈ¡¿Í»§¶Ë post µÄ html£¬½á¹ûÒѱ»¹ýÂË£¬Ö»ÔÊÐí allowedTags ÖÐÖ¸¶¨µÄ tag
- /// </summary>
- /// <param name="postItem"></param>
- /// <param name="allowedTags"></param>
- /// <returns></returns>
- public String PostHtml( String postItem, String allowedTags ) {
- String val = _context.post( postItem );
- if (val != null) {
- val = strUtil.TrimHtml( val );
- val = HtmlFilter.Filter( val, allowedTags );
- }
- return val;
- }
- /// <summary>
- /// ÔÚĬÈϰ×Ãûµ¥µÄ»ù´¡ÉÏ£¬ÔÊÐí allowedTags ÖÐÖ¸¶¨µÄtag
- /// </summary>
- /// <param name="postItem"></param>
- /// <param name="allowedTags"></param>
- /// <returns></returns>
- public String PostHtmlAppendTags( String postItem, String allowedTags ) {
- String val = _context.post( postItem );
- if (val != null) {
- val = strUtil.TrimHtml( val );
- val = HtmlFilter.FilterAppendTags( val, allowedTags );
- }
- return val;
- }
- /// <summary>
- /// ÔÊÐí½ÓÊÕ¿Í»§¶ËÈÎÒâ×Ö·û£¬Çë½÷É÷ʹÓÃ
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public String PostHtmlAll( String postItem ) {
- return _context.post( postItem );
- }
- //------------------------------------------- PARAMS ------------------------------------------
- /// <summary>
- /// »ñÈ¡¿Í»§¶ËÌá½»µÄÊý¾Ý(°üÀ¨getºÍpost)£¬½á¹ûÒѱ»¹ýÂË(²»ÔÊÐíhtml)
- /// </summary>
- /// <param name="itemName"></param>
- /// <returns></returns>
- public String Params( String itemName ) {
- String val = _context.param( itemName );
- return checkClientValue( val );
- }
- /// <summary>
- /// ´Ó¿Í»§¶ËÌá½»µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³ÉÕûÊý
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public int ParamInt( String postItem ) {
- if ((_context.param( postItem ) != null) && cvt.IsInt( _context.param( postItem ) )) {
- return int.Parse( _context.param( postItem ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó¿Í»§¶ËÌá½»µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É Decimal
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public Decimal ParamDecimal( String postItem ) {
- if (_context.param( postItem ) != null) {
- return cvt.ToDecimal( _context.param( postItem ) );
- }
- return 0;
- }
- /// <summary>
- /// ´Ó¿Í»§¶ËÌá½»µÄÊý¾ÝÖлñȡijÏîµÄÖµ£¬²¢×ª»»³É Double
- /// </summary>
- /// <param name="postItem"></param>
- /// <returns></returns>
- public Double ParamDouble( String postItem ) {
- if (_context.param( postItem ) != null) {
- return cvt.ToDouble( _context.param( postItem ) );
- }
- return 0;
- }
- //-------------------------------------------------------------------------------------
- /// <summary>
- /// ÑéÖ¤¶ÔÏóµÄ¸÷ÏîÊôÐÔÊÇ·ñºÏ·¨
- /// </summary>
- /// <param name="target">ÐèÒª±»ÑéÖ¤µÄ¶ÔÏó</param>
- /// <returns>·µ»ØÑéÖ¤½á¹û</returns>
- public Result Validate( IEntity target ) {
- return Validator.Validate( target );
- }
- /// <summary>
- /// »ñÈ¡¿Í»§¶ËpostµÄÊý¾Ý£¬²¢×Ô¶¯¸³Öµµ½¶ÔÏó¸÷ÊôÐÔ£¬×îºó½øÐÐÑéÖ¤
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <returns></returns>
- public T PostValue<T>() {
- EntityInfo entityInfo = Entity.GetInfo( typeof( T ) );
- Type t = typeof( T );
- T obj = (T)rft.GetInstance( t );
- setObjectProperties( entityInfo, t, obj );
- IEntity entity = obj as IEntity;
- if (entity != null) {
- Result result = Validate( entity );
- if (result.HasErrors) errors.Join( result );
- }
- return obj;
- }
- /// <summary>
- /// »ñÈ¡¿Í»§¶ËpostµÄÊý¾Ý£¬²¢×Ô¶¯¸³Öµµ½¶ÔÏó¸÷ÊôÐÔ£¬×îºó½øÐÐÑéÖ¤
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public Object PostValue( Object obj ) {
- EntityInfo entityInfo = Entity.GetInfo( obj );
- Type t = obj.GetType();
- setObjectProperties( entityInfo, t, obj );
- IEntity entity = obj as IEntity;
- if (entity != null) {
- Result result = Validate( entity );
- if (result.HasErrors) errors.Join( result );
- }
- return obj;
- }
- private void setObjectProperties( EntityInfo entityInfo, Type t, Object obj ) {
- String camelType = strUtil.GetCamelCase( t.Name );
- String prefix = camelType + ".";
- NameValueCollection posts = _context.postValueAll();
- foreach (String key in posts.Keys) {
- if (key.StartsWith( prefix ) == false) continue;
- String propertyName = strUtil.TrimStart( key, prefix );
- PropertyInfo p = t.GetProperty( propertyName );
- if (p == null) continue;
- if (entityInfo == null)
- setPropertyValue( obj, p, posts[key] );
- else {
- EntityPropertyInfo ep = entityInfo.GetProperty( propertyName );
- setEntityPropertyValue( obj, ep, posts[key] );
- }
- }
- }
- private String checkClientValue( String val ) {
- if (val != null) {
- val = val.Trim();
- val = HttpUtility.HtmlEncode( val );
- }
- return val;
- }
- private void setPropertyValue( Object obj, PropertyInfo p, String postValue ) {
- if (p.PropertyType == typeof( int )) {
- p.SetValue( obj, cvt.ToInt( postValue ), null );
- }
- else if (p.PropertyType == typeof( String )) {
- p.SetValue( obj, getAutoPostString( p, postValue ), null );
- }
- else if (p.PropertyType == typeof( Decimal )) {
- p.SetValue( obj, cvt.ToDecimal( postValue ), null );
- }
- else if (p.PropertyType == typeof( Double )) {
- p.SetValue( obj, cvt.ToDouble( postValue ), null );
- }
- else if (p.PropertyType == typeof( DateTime )) {
- p.SetValue( obj, cvt.ToTime( postValue ), null );
- }
- }
- private void setEntityPropertyValue( Object obj, EntityPropertyInfo p, String postValue ) {
- if (p.Type == typeof( int )) {
- p.SetValue( obj, cvt.ToInt( postValue ) );
- }
- else if (p.Type == typeof( String )) {
- p.SetValue( obj, getAutoPostString( p.Property, postValue ) );
- }
- else if (p.Type == typeof( Decimal )) {
- p.SetValue( obj, cvt.ToDecimal( postValue ) );
- }
- else if (p.Type == typeof( Double )) {
- p.SetValue( obj, cvt.ToDouble( postValue ) );
- }
- else if (p.Type == typeof( DateTime )) {
- p.SetValue( obj, cvt.ToTime( postValue ) );
- }
- else if (p.IsEntity) {
- IEntity objProperty = Entity.New( p.EntityInfo.FullName );
- objProperty.Id = cvt.ToInt( postValue );
- p.SetValue( obj, objProperty );
- }
- }
- private String getAutoPostString( PropertyInfo p, String postValue ) {
- Attribute htmlAttr = rft.GetAttribute( p, typeof( HtmlTextAttribute ) );
- if (htmlAttr == null) postValue = checkClientValue( postValue );
- return postValue;
- }
- private Boolean _isRunAction = true;
- internal void isRunAction( Boolean isRun ) {
- _isRunAction = isRun;
- }
- internal Boolean isRunAction() {
- return _isRunAction;
- }
- //------------------------------------------------------------------------------------
- private Link getLink() {
- return new Link( this );
- }
- /// <summary>
- /// Á´½Óµ½Ä³¸ö action
- /// </summary>
- /// <param name="action"></param>
- /// <returns></returns>
- public String to( aAction action ) {
- return getLink().To( action );
- }
- /// <summary>
- /// Á´½Óµ½Ä³¸ö action
- /// </summary>
- /// <param name="action"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public String to( aActionWithId action, int id ) {
- return getLink().To( action, id );
- }
- /// <summary>
- /// Á´½Óµ½Ä³¸ö action£¬ÍøÖ·Öв»°üÀ¨ appId ÐÅÏ¢
- /// </summary>
- /// <param name="action"></param>
- /// <returns></returns>
- public String t2( aAction action ) {
- return getLink().T2( action );
- }
- /// <summary>
- /// Á´½Óµ½Ä³¸ö action£¬ÍøÖ·Öв»°üÀ¨ appId ÐÅÏ¢
- /// </summary>
- /// <param name="action"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public String t2( aActionWithId action, int id ) {
- return getLink().T2( action, id );
- }
- }
- }