protected WeakDistributedCache(IDistributedCache distributedCache) : base(distributedCache) { fCacheTable = new ConcurrentDictionary <string, WeakReference <DistributeData> >(); TkDebug.ThrowIfNoGlobalVariable(); fLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); }
private Expression(string expressionString) { TkDebug.AssertArgumentNullOrEmpty(expressionString, "expressionString", null); fParser = ExpressionParser.ParseExpression(expressionString); TkDebug.ThrowIfNoGlobalVariable(); PlugInFactoryManager factories = BaseGlobalVariable.Current.FactoryManager; BasePlugInFactory paramFactory = factories.GetCodeFactory( ParamExpressionPlugInFactory.REG_NAME); BasePlugInFactory exprFactory = factories.GetCodeFactory( ExpressionPlugInFactory.REG_NAME); fExpressions = new List <BaseExpressionItem>(); foreach (string item in fParser.ParamArray) { string firstChar = item[0].ToString(); BaseExpressionItem expressionItem; if (paramFactory.Contains(firstChar)) { IParamExpression expression = paramFactory.CreateInstance <IParamExpression>(firstChar); string parameter = item.Substring(1); expressionItem = new ParamExpressionItem(expression, parameter); } else { IExpression expression = exprFactory.CreateInstance <IExpression>(item); expressionItem = new ExpressionItem(expression, item); } fExpressions.Add(expressionItem); } }
public static ISearch CreateSearch(string regName, bool throwIfNoRegName) { if (!throwIfNoRegName && string.IsNullOrEmpty(regName)) { return(null); } TkDebug.AssertArgumentNullOrEmpty(regName, "regName", null); try { TkDebug.ThrowIfNoGlobalVariable(); return(PlugInFactoryManager.CreateInstance <ISearch>(REG_NAME, regName)); } catch (Exception ex) { if (throwIfNoRegName) { throw ex; } else { return(null); } } }
protected virtual IParamBuilder CreateAdditionCondition(TkDbContext context, IFieldInfoIndexer indexer) { TkDebug.AssertArgumentNull(context, "context", this); TkDebug.AssertArgumentNull(indexer, "indexer", this); ParamBuilderContainer result = new ParamBuilderContainer(); if (FilterSql != null) { string sql = Expression.Execute(FilterSql, context, indexer); result.Add(sql); } if (DataRight != null) { TkDebug.ThrowIfNoGlobalVariable(); IUserInfo userInfo = BaseGlobalVariable.Current.UserInfo; IParamBuilder builder = DataRight.GetListSql(new ListDataRightEventArgs(context, userInfo, indexer)); result.Add(builder); } if (ActiveData != null) { IParamBuilder builder = ActiveData.CreateParamBuilder(context, indexer); result.Add(builder); } if (result.IsEmpty) { return(null); } return(result); }
protected virtual void CheckDataRight(IInputData input, DataRow row) { TkDebug.ThrowIfNoGlobalVariable(); var args = new DataRightEventArgs(Context, BaseGlobalVariable.Current.UserInfo, MainResolver, input.Style, row); DataRight.Check(args); }
internal PlugInManagerData() { TkDebug.ThrowIfNoGlobalVariable(); PlugInFactoryManager manager = BaseGlobalVariable.Current.FactoryManager; CodeFactories = CreateList(manager.CodeFactories); XmlConfigs = CreateList(manager.XmlConfigs); }
public void AppStarted(object application, BaseAppSetting appsetting, BaseGlobalVariable globalVariable) { TkDebug.ThrowIfNoGlobalVariable(); EvaluateAdditionPlugInFactory factory = BaseGlobalVariable.Current.FactoryManager.GetCodeFactory( EvaluateAdditionPlugInFactory.REG_NAME).Convert <EvaluateAdditionPlugInFactory>(); factory.Initialize(); }
public static string GetSimpleDefaultValue(string keyName) { TkDebug.AssertArgumentNullOrEmpty(keyName, nameof(keyName), null); TkDebug.ThrowIfNoGlobalVariable(); return(BaseGlobalVariable.Current.DefaultValue.GetSimpleDefaultValue(keyName)); }
private static object InternalReadConfig(string sectionName) { TkDebug.ThrowIfNoGlobalVariable(); var result = BaseGlobalVariable.Current.Config.GetConfig(sectionName); return(result); }
string IExpression.Execute() { TkDebug.ThrowIfNoGlobalVariable(); object orgId = BaseGlobalVariable.Current.UserInfo.MainOrgId; return(orgId == null ? string.Empty : orgId.ToString()); }
private static int ReadDefaultBufferSize() { TkDebug.ThrowIfNoGlobalVariable(); int buffer = BaseGlobalVariable.Current.DefaultValue.GetSimpleDefaultValue( "DefaultRazorBufferSize").Value <int>(DEFAULT_BUFFER_SIZE); return(buffer); }
public static IModelCreator CreateModelCreator(string pageTemplate) { TkDebug.AssertArgumentNullOrEmpty(pageTemplate, "pageTemplate", null); TkDebug.ThrowIfNoGlobalVariable(); PageTemplatePlugInFactory factory = BaseGlobalVariable.Current.FactoryManager .GetCodeFactory(REG_NAME).Convert <PageTemplatePlugInFactory>(); IModelCreator creator = factory.InternalCreateModelCreator(pageTemplate); return(creator); }
public static IEnumerable <OperatorConfig> SafeGetSubOperators(OperatorPage page, string functionKey) { TkDebug.ThrowIfNoGlobalVariable(); UserFunctionRight functionRight = WebGlobalVariable.SessionGbl.AppRight.FunctionRight as UserFunctionRight; if (functionRight == null) { return(null); } return(functionRight.GetSubOperators(page, functionKey)); }
public static IRazorEngine CreateRazorEngine(string engineName) { if (string.IsNullOrEmpty(engineName)) { return(RazorUtil.ToolkitEngine); } TkDebug.ThrowIfNoGlobalVariable(); RazorEnginePlugInFactory factory = BaseGlobalVariable.Current.FactoryManager .GetCodeFactory(REG_NAME).Convert <RazorEnginePlugInFactory>(); IRazorEngine engine = factory.CreateInstance <IRazorEngine>(engineName); return(engine); }
public static TypeTableScheme CreateTypeTableScheme(string regName) { TkDebug.AssertArgumentNullOrEmpty(regName, "regName", null); TkDebug.ThrowIfNoGlobalVariable(); TypeSchemeTypeFactory factory = BaseGlobalVariable.Current.FactoryManager. GetCodeFactory(TypeSchemeTypeFactory.REG_NAME).Convert <TypeSchemeTypeFactory>(); Type type = factory.GetType(regName); if (type == null) { return(null); } return(TypeTableScheme.Create(type)); }
public static BaseSendMessage Execute(Action <bool, string> processor, bool subscrible, string data) { TkDebug.ThrowIfNoAppSetting(); TkDebug.ThrowIfNoGlobalVariable(); if (BaseAppSetting.Current.UseWorkThread) { BaseGlobalVariable.Current.BeginInvoke(processor, subscrible, data); } else { processor(subscrible, data); } return(null); }
internal void Log(ReceiveMessage message) { if (fLog != null) { TkDebug.ThrowIfNoGlobalVariable(); TkDebug.ThrowIfNoAppSetting(); if (BaseAppSetting.Current.UseWorkThread) { BaseGlobalVariable.Current.BeginInvoke(new Action <ReceiveMessage>(ExecuteLog), message); } else { ExecuteLog(message); } } }
public static DbContextConfig Create(string name, string sqlProvider, string dbProvider, string connectionString) { TkDebug.AssertArgumentNullOrEmpty(sqlProvider, "sqlProvider", null); TkDebug.AssertArgumentNullOrEmpty(dbProvider, "dbProvider", null); TkDebug.AssertArgumentNullOrEmpty(connectionString, "connectionString", null); TkDebug.ThrowIfNoGlobalVariable(); DbContextConfig config = new DbContextConfig { Name = name, SqlProvider = sqlProvider, DbProvider = dbProvider, ConnectionString = connectionString }; return(config); }
private IParamBuilder GetCustomParamBuilder(IParamBuilder builder) { IParamBuilder result = builder; if (DataRight != null) { TkDebug.ThrowIfNoGlobalVariable(); IUserInfo userInfo = BaseGlobalVariable.Current.UserInfo; IParamBuilder dataRight = DataRight.GetListSql( new ListDataRightEventArgs(fSelector.Context, userInfo, fSelector)); result = ParamBuilder.CreateParamBuilder(result, dataRight); } if (CustomCondition != null) { result = ParamBuilder.CreateParamBuilder(result, CustomCondition); } return(result); }
public OutputData DoAction(IInputData input) { TkDebug.ThrowIfNoGlobalVariable(); if (MetaDataUtil.Equals(input.Style, (PageStyleClass)"Code")) { string factoryName = input.QueryString["Name"]; var factory = BaseGlobalVariable.Current.FactoryManager.GetCodeFactory(factoryName); return(OutputData.CreateToolkitObject(new PlugInFactoryData(factory))); } else if (MetaDataUtil.Equals(input.Style, (PageStyleClass)"Xml")) { string factoryName = input.QueryString["Name"]; var factory = BaseGlobalVariable.Current.FactoryManager.GetConfigFactory(factoryName); return(OutputData.CreateToolkitObject(new ConfigFactoryData(factory))); } else { return(OutputData.CreateToolkitObject(new PlugInManagerData())); } }
string IParamExpression.Execute(string parameter) { TkDebug.ThrowIfNoGlobalVariable(); return(WebGlobalVariable.Request.Query[parameter]); }
//public static void SetDefaultCacheCreator(ICacheCreator creator) //{ // TkDebug.AssertArgumentNull(creator, "creator", null); // TkDebug.ThrowIfNoGlobalVariable(); // BaseGlobalVariable.Current.CacheManager.fDefaultCreator = creator; //} public static object GetItem(string cacheName, string key, params object[] args) { TkDebug.ThrowIfNoGlobalVariable(); return(BaseGlobalVariable.Current.CacheManager.GetCacheItem(cacheName, key, args)); }
public static bool ContainsKey(string cacheName, string key) { TkDebug.ThrowIfNoGlobalVariable(); return(BaseGlobalVariable.Current.CacheManager .Contains(cacheName, key)); }
string IExpression.Execute() { TkDebug.ThrowIfNoGlobalVariable(); return(BaseGlobalVariable.Current.UserInfo.UserName ?? string.Empty); }
public static void RemoveKey(string cacheName, string key) { TkDebug.ThrowIfNoGlobalVariable(); BaseGlobalVariable.Current.CacheManager.Remove(cacheName, key); }
public static void ClearCache(string cacheName) { TkDebug.ThrowIfNoGlobalVariable(); BaseGlobalVariable.Current.CacheManager.Clear(cacheName); }
public static void CleanCache() { TkDebug.ThrowIfNoGlobalVariable(); BaseGlobalVariable.Current.CacheManager.Clean(); }
internal void WriteToken(JsonReader reader, int initialDepth) { do { switch (reader.TokenType) { case JsonToken.None: // read to next break; case JsonToken.StartObject: WriteStartObject(); break; case JsonToken.StartArray: WriteStartArray(); break; case JsonToken.StartConstructor: string constructorName = reader.Value.ToString(); // write a JValue date when the constructor is for a date if (string.Compare(constructorName, "Date", StringComparison.Ordinal) == 0) { WriteConstructorDate(reader); } else { WriteStartConstructor(reader.Value.ToString()); } break; case JsonToken.PropertyName: WritePropertyName(reader.Value.ToString()); break; case JsonToken.Comment: WriteComment(reader.Value.ToString()); break; case JsonToken.Integer: WriteValue((long)reader.Value); break; case JsonToken.Float: WriteValue((double)reader.Value); break; case JsonToken.String: WriteValue(reader.Value.ToString()); break; case JsonToken.Boolean: WriteValue((bool)reader.Value); break; case JsonToken.Null: WriteNull(); break; case JsonToken.Undefined: WriteUndefined(); break; case JsonToken.EndObject: WriteEndObject(); break; case JsonToken.EndArray: WriteEndArray(); break; case JsonToken.EndConstructor: WriteEndConstructor(); break; case JsonToken.Date: WriteValue((DateTime)reader.Value); break; case JsonToken.Raw: WriteRawValue((string)reader.Value); break; case JsonToken.Bytes: WriteValue((byte[])reader.Value); break; default: TkDebug.ThrowIfNoGlobalVariable(); break; } }while ( initialDepth - 1 < reader.Depth - (IsEndToken(reader.TokenType) ? 1 : 0) && reader.Read()); }
public SimpleCache(int capacity) { fCacheTable = new Dictionary <string, CacheData>(capacity); TkDebug.ThrowIfNoGlobalVariable(); fLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); }