public ActiveTimeCacheAttribute(int hour) { TkDebug.AssertArgument(hour > 0, "hour", "hour参数不能为负数", null); Hour = hour; fTimeSpan = new TimeSpan(hour, 0, 0); }
public EnumCodeTable(Type type, bool useIntValue) { TkDebug.AssertArgumentNull(type, "type", null); TkDebug.AssertArgument(type.IsEnum, "type", "参数type不是枚举类型", type); fEnumType = type; FieldInfo[] infos = type.GetFields(); foreach (var field in infos) { if (!field.FieldType.IsEnum) { continue; } DisplayNameAttribute attr = System.Attribute.GetCustomAttribute(field, typeof(DisplayNameAttribute)) as DisplayNameAttribute; string name = attr == null ? field.Name : attr.DisplayName; string value; if (useIntValue) { value = ((int)Enum.Parse(type, field.Name)).ToString(ObjectUtil.SysCulture); } else { value = field.Name; } Add(new CodeItem(value, name)); } }
private PageStyleClass(PageStyle style) { TkDebug.AssertArgument(IsNormalStyle(style), "style", "Style不支持Custom,All和AllNoList", null); Style = style; }
public IListSqlContext GetListSql(string selectFields, string tableName, IFieldInfo[] keyFields, string whereClause, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(selectFields, "selectFields", this); TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); string sql; if (endNum == 0) { sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1} {2} {3}", selectFields, tableName, whereClause, orderBy); } else { sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1} {2} {3} LIMIT {4}, {5}", selectFields, tableName, whereClause, orderBy, startNum, endNum - startNum); } return(new NormalListSqlContext(sql)); }
string ISqlProvider.GetRowNumSql(string tableName, IFieldInfo[] keyFields, string whereClause, string rowNumFilter, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); StringBuilder sql = new StringBuilder(); sql.Append("SELECT TOOLKIT__ ROWNUMBER_ FROM (SELECT ROWNUM TOOLKIT__, DD.* FROM (SELECT * FROM "); sql.AppendFormat(ObjectUtil.SysCulture, "{0} {1} {2}) DD", tableName, whereClause, orderBy); if (endNum >= 0) { sql.Append(" WHERE ROWNUM <= ").Append(endNum); } sql.Append(") YY"); if (startNum >= 0 || !string.IsNullOrEmpty(rowNumFilter)) { sql.Append(" WHERE "); int index = 0; if (startNum > 0) { SqlBuilder.JoinStringItem(sql, index++, "TOOLKIT__ > " + startNum, " AND "); } if (!string.IsNullOrEmpty(rowNumFilter)) { SqlBuilder.JoinStringItem(sql, index++, rowNumFilter, " AND "); } } return(sql.ToString()); }
IListSqlContext ISqlProvider.GetListSql(string selectFields, string tableName, IFieldInfo[] keyFields, string whereClause, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(selectFields, "selectFields", this); TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); string sql; if (endNum == 0) { sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1} {2} {3}", selectFields, tableName, whereClause, orderBy); } else { sql = string.Format(ObjectUtil.SysCulture, "SELECT * FROM (SELECT ROWNUM ROWNUMBER_, DD.* FROM (SELECT {0} " + " FROM {1} {2} {3}) DD WHERE ROWNUM <= {4}) YY WHERE ROWNUMBER_ > {5}", selectFields, tableName, whereClause, orderBy, endNum, startNum); } return(new NormalListSqlContext(sql)); }
protected internal BaseSchemeEasySearch(ITableScheme scheme, string idField, string nameField, bool canCache) { TkDebug.AssertArgumentNull(scheme, "scheme", null); TkDebug.AssertArgument(scheme is IDisplayObject, "scheme", "scheme需要支持IDisplayObject接口", scheme); fDisplay = scheme.Convert <IDisplayObject>(); TkDebug.Assert(fDisplay.SupportDisplay, "scheme的SupportDisplay必须为true,当前是false", scheme); SourceScheme = scheme; fDisplay = new TempDisplay(fDisplay, scheme, idField, nameField); if (canCache) { canCache = idField == null && nameField == null; } if (canCache) { fScheme = new EasySearchProxyScheme(scheme, fDisplay); } else { fScheme = new NoCacheEasySearchProxyScheme(scheme, fDisplay); } ValueField = fDisplay.Id; NameField = fDisplay.Name; }
public void Encode(byte[] buffer, int index, int count) { TkDebug.AssertArgumentNull(buffer, "buffer", this); TkDebug.AssertArgument(index >= 0, "index", "参数index必须非负数", this); TkDebug.AssertArgument(count >= 0 && count <= (buffer.Length - index), "count", string.Format(ObjectUtil.SysCulture, "参数count必须在0和{0}之间", buffer.Length - index), this); //if (index < 0) // throw new ArgumentOutOfRangeException("index"); //if (count < 0) // throw new ArgumentOutOfRangeException("count"); //if (count > (buffer.Length - index)) // throw new ArgumentOutOfRangeException("count"); if (fLeftOverBytesCount > 0) { int leftOverBytesCount = fLeftOverBytesCount; while (leftOverBytesCount < 3 && count > 0) { fLeftOverBytes[leftOverBytesCount++] = buffer[index++]; count--; } if (count == 0 && leftOverBytesCount < 3) { fLeftOverBytesCount = leftOverBytesCount; return; } int num2 = Convert.ToBase64CharArray(fLeftOverBytes, 0, 3, fCharsLine, 0); WriteChars(fCharsLine, 0, num2); } fLeftOverBytesCount = count % 3; if (fLeftOverBytesCount > 0) { count -= fLeftOverBytesCount; if (fLeftOverBytes == null) { fLeftOverBytes = new byte[3]; } for (int i = 0; i < fLeftOverBytesCount; i++) { fLeftOverBytes[i] = buffer[(index + count) + i]; } } int num4 = index + count; int length = LINE_SIZE_IN_BYTES; while (index < num4) { if ((index + length) > num4) { length = num4 - index; } int num6 = Convert.ToBase64CharArray(buffer, index, length, fCharsLine, 0); WriteChars(fCharsLine, 0, num6); index += length; } }
public StringMinLengthConstraint(IFieldInfo field, int minLength) : base(field) { TkDebug.AssertArgument(minLength > 0, "minLength", "最小长度至少是1", null); MinLength = minLength; fMessage = string.Format(ObjectUtil.SysCulture, "{0}长度至少为{1}", field.DisplayName, minLength); }
protected BaseCacheItemCreator(int capacity) { TkDebug.AssertArgument(capacity >= 0, "capacity", string.Format(ObjectUtil.SysCulture, "参数capacity必须不小于0,现在值为{0}", capacity), null); //CacheCreator = new SimpleCacheCreator(capacity); Initialize(); }
public FieldDecoderAttribute(DecoderType type, string regName) { TkDebug.AssertArgument((type != DecoderType.None && !string.IsNullOrEmpty(regName)) || (type == DecoderType.None), "regName", "参数regName不能为空", null); Type = type; RegName = regName; }
private List <ViewBufferPage> fMultiplePages; // Allocated only if necessary public ViewBuffer(IViewBufferScope bufferScope, string name, int pageSize) { TkDebug.AssertArgumentNull(bufferScope, nameof(bufferScope), null); TkDebug.AssertArgument(pageSize > 0, nameof(pageSize), $"{nameof(pageSize)}必须大于0", null); fBufferScope = bufferScope; fName = name; fPageSize = pageSize; }
protected void CopyTo(Array array, int index) { TkDebug.AssertArgumentNull(array, "array", this); AssertIndex(index, array.Length); TkDebug.AssertArgument(array.Length - index >= Count, "arrayIndex", string.Format( ObjectUtil.SysCulture, "当前有{0}个元素,而数组的空间为{1},空间不够", Count, array.Length - index), this); fList.CopyTo(array, index); }
protected virtual void SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet, int startRecord, int maxRecords, string srcTable) { TkDebug.AssertArgument(startRecord >= 0, "startRecord", string.Format( ObjectUtil.SysCulture, "参数startRecord不能为负数,现在的值为{0}", startRecord), this); TkDebug.AssertArgument(maxRecords >= 0, "number", string.Format(ObjectUtil.SysCulture, "参数maxRecords不能为负数,现在的值为{0}", maxRecords), this); DbUtil.FillDataSet(adapter, dataSet, srcTable, startRecord, maxRecords); }
public FixLengthConstraint(IFieldInfo field, int length) : base(field) { Length = length; TkDebug.AssertArgument(length > 0, "length", string.Format( ObjectUtil.SysCulture, "length参数的值必须大于0,现在值为{0}", length), null); fMessage = string.Format(ObjectUtil.SysCulture, TkWebApp.FixLengthCMsg, field.DisplayName, length); }
public static string GetColClass(int col) { TkDebug.AssertArgument(col > 0 && col <= 12, "col", string.Format(ObjectUtil.SysCulture, "col必须在1到12之间,当前值是{0}越界了", col), null); string result = string.Format(ObjectUtil.SysCulture, "col-xs-{0} col-sm-{0} col-md-{0} col-lg-{0}", col); return(result); }
/// <summary> /// Initializes a new instance of the XmlConfigFactoriesDependency class. /// </summary> /// <param name="configFactories"></param> public XmlConfigFactoriesDependency(ICollection <BaseXmlConfigFactory> configFactories) { TkDebug.AssertArgumentNull(configFactories, "configFactories", null); TkDebug.AssertArgument(configFactories.Count > 1, "configFactories", "List列表中的数量应至少多于1个,否则可以考虑使用XmlConfigFactoryDependency", null); fConfigFactories = configFactories; fCounts = (from factory in configFactories select factory.Count).ToArray(); }
protected BaseSchemeCodeTable(ITableScheme scheme) { TkDebug.AssertArgumentNull(scheme, "scheme", null); TkDebug.AssertArgument(scheme is IDisplayObject, "scheme", "scheme需要支持IDisplayObject接口", scheme); fScheme = scheme; fDisplay = scheme.Convert <IDisplayObject>(); TkDebug.Assert(fDisplay.SupportDisplay, "scheme的SupportDisplay必须为true,当前是false", scheme); }
public FileSystemRazorProject(string root, string extension) { TkDebug.AssertArgumentNullOrEmpty(extension, nameof(extension), this); TkDebug.AssertArgumentNullOrEmpty(root, nameof(root), this); TkDebug.AssertArgument(Directory.Exists(root), nameof(root), $"Root directory {root} not found", this); Extension = extension; Root = root; fFileProvider = new PhysicalFileProvider(Root); }
IListSqlContext ISqlProvider.GetListSql(string selectFields, string tableName, IFieldInfo[] keyFields, string whereClause, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(selectFields, "selectFields", this); TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); return(GetListSql(selectFields, tableName, keyFields, whereClause, orderBy, startNum, endNum)); }
public CorpTagUserResult RemoveMembers(IEnumerable <string> userList, IEnumerable <int> partyList) { TkDebug.AssertArgument(userList != null || partyList != null, "userList", "参数userList或者partyList不能全为空", this); CorpPostTagUser postData = new CorpPostTagUser(Id, userList, partyList); string url = WeCorpUtil.GetCorpUrl(WeCorpConst.REMOVE_TAG_USER, WeixinSettings.Current.CorpUserManagerSecret); CorpTagUserResult result = WeUtil.PostToUri(url, postData.WriteJson(WeConst.WRITE_SETTINGS), new CorpTagUserResult()); return(result); }
void ISqlProvider.SetListData(IListSqlContext context, ISimpleAdapter adapter, DataSet dataSet, int startRecord, int maxRecords, string srcTable) { TkDebug.AssertArgumentNull(adapter, "adapter", this); TkDebug.AssertArgumentNull(dataSet, "dataSet", this); TkDebug.AssertArgumentNullOrEmpty(srcTable, "srcTable", this); TkDebug.AssertArgument(startRecord >= 0, "startRecord", string.Format(ObjectUtil.SysCulture, "参数startRecord不能为负数,现在的值为{0}", startRecord), this); TkDebug.AssertArgument(maxRecords >= 0, "number", string.Format(ObjectUtil.SysCulture, "参数maxRecords不能为负数,现在的值为{0}", maxRecords), this); DbUtil.FillDataSet(adapter, dataSet, srcTable, startRecord, maxRecords); }
public virtual async Task <RazorCodeDocument> CreateCodeDocumentAsync(TkRazorProjectItem projectItem) { TkDebug.AssertArgumentNull(projectItem, nameof(projectItem), this); TkDebug.AssertArgument(projectItem.Exists, nameof(projectItem), $"Project can not find template with key {projectItem.Key}", this); using (var stream = projectItem.Read()) { RazorSourceDocument source = RazorSourceDocument.ReadFrom(stream, projectItem.Key); IEnumerable <RazorSourceDocument> imports = await GetImportsAsync(projectItem); return(RazorCodeDocument.Create(source, imports)); } }
IListSqlContext ISqlProvider.GetListSql(string selectFields, string tableName, IFieldInfo[] keyFields, string whereClause, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(selectFields, "selectFields", this); TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); string topCount = (endNum == 0) ? string.Empty : "TOP " + endNum.ToString(ObjectUtil.SysCulture); string sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} {1} FROM {2} {3} {4}", topCount, selectFields, tableName, whereClause, orderBy); return(new NormalListSqlContext(sql)); }
public override void Write(char[] buffer, int index, int count) { TkDebug.AssertArgumentNull(buffer, nameof(buffer), this); TkDebug.AssertArgument(index >= 0 && index < buffer.Length, nameof(index), $"{nameof(index)}必须在0和{buffer.Length}之间,当前值为{index}", this); TkDebug.AssertArgument(count >= 0 && count < buffer.Length, nameof(count), $"{nameof(count)}必须在0和{buffer.Length}之间,当前值为{count}", this); if (IsBuffering) { Buffer.AppendHtml(new string(buffer, index, count)); } else { fInner.Write(buffer, index, count); } }
public override Task WriteAsync(char[] buffer, int index, int count) { TkDebug.AssertArgumentNull(buffer, nameof(buffer), this); TkDebug.AssertArgument(index >= 0 && index < buffer.Length, nameof(index), $"{nameof(index)}必须在0和{buffer.Length}之间,当前值为{index}", this); TkDebug.AssertArgument(count >= 0 && count <= buffer.Length - index, nameof(count), $"{nameof(count)}必须在0和{buffer.Length - index}之间,当前值为{count}", this); if (IsBuffering) { Buffer.AppendHtml(new string(buffer, index, count)); return(Task.CompletedTask); } else { return(fInner.WriteAsync(buffer, index, count)); } }
public KeyData(string[] nickNames, string[] values) { TkDebug.AssertArgumentNull(nickNames, "nickNames", null); TkDebug.AssertArgumentNull(values, "values", null); TkDebug.AssertArgument(nickNames.Length == values.Length, "nickNames", string.Format( ObjectUtil.SysCulture, "nickNames和values的长度不一致,nickNames长度为{0},values的长度为{1}", nickNames.Length, values.Length), this); TkDebug.AssertArgument(nickNames.Length > 1, "nickNames", string.Format( ObjectUtil.SysCulture, "nickNames的长度必须大于1,当前为{0}", nickNames.Length), this); Data = new Dictionary <string, string>(); int len = nickNames.Length; for (int i = 0; i < len; ++i) { Data.Add(nickNames[i], values[i]); } IsSingleValue = false; }
/// <summary> /// 对DataRow中指定的字段进行赋值 /// </summary> /// <param name="row">需要赋值的DataRow</param> /// <param name="names">指定的字段序列</param> /// <param name="values">相应的值</param> /// <example>例如: /// <code> /// DataSetUtil.SetRowValues(row, new string[] {"LD_NAME", "LD_DATE", "LD_USERID"}, /// new object[] {"Hello", DateTime.Now, Info.UserId}); /// </code> /// </example> public static void SetRowValues(DataRow row, string[] names, params object[] values) { TkDebug.AssertArgumentNull(row, "row", null); TkDebug.AssertEnumerableArgumentNullOrEmpty(names, "names", null); TkDebug.AssertArgumentNull(values, "values", null); TkDebug.AssertArgument(names.Length == values.Length, "values", string.Format(ObjectUtil.SysCulture, "参数names的个数是{0},参数values的个数是{1},两者个数不匹配,请确认", names.Length, values.Length), null); row.BeginEdit(); try { for (int i = 0; i < names.Length; ++i) { row[names[i]] = values[i] ?? DBNull.Value; } } finally { row.EndEdit(); } }
public ViewBufferValue[] GetPage(int pageSize) { TkDebug.AssertArgument(pageSize > 0, nameof(pageSize), $"{nameof(pageSize)}必须大于0,当前值是{pageSize}", this); if (fDisposed) { throw new ObjectDisposedException(typeof(MemoryPoolViewBufferScope).FullName); } if (fLeased == null) { fLeased = new List <ViewBufferValue[]>(1); } ViewBufferValue[] segment = null; // Reuse pages that have been returned before going back to the memory pool. if (fAvailable != null && fAvailable.Count > 0) { segment = fAvailable[fAvailable.Count - 1]; fAvailable.RemoveAt(fAvailable.Count - 1); return(segment); } try { segment = fViewBufferPool.Rent(Math.Max(pageSize, MinimumSize)); fLeased.Add(segment); } catch when(segment != null) { fViewBufferPool.Return(segment); throw; } return(segment); }
protected override string GetRowNumSql(string tableName, IFieldInfo[] keyFields, string whereClause, string rowNumFilter, string orderBy, int startNum, int endNum) { TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this); TkDebug.AssertArgument(!string.IsNullOrEmpty(orderBy) || (keyFields != null && keyFields.Length > 0), "keyFields", "在参数orderBy为空时,keyFields不能为空或者是空数组", this); TkDebug.AssertArgument(startNum >= 0, "startNum", string.Format(ObjectUtil.SysCulture, "参数startNum不能为负数,现在的值为{0}", startNum), this); TkDebug.AssertArgument(endNum >= 0, "endNum", string.Format(ObjectUtil.SysCulture, "参数endNum不能为负数,现在的值为{0}", endNum), this); ProcessOrderBy(keyFields, ref orderBy); StringBuilder sql = new StringBuilder(); sql.Append("SELECT ROWNUMBER_ FROM (SELECT ROW_NUMBER() OVER (").Append(orderBy); sql.Append(") ROWNUMBER_, * FROM ").Append(tableName).Append(" ").Append(whereClause); sql.Append(") _TOOLKIT"); if (startNum >= 0 || endNum >= 0 || !string.IsNullOrEmpty(rowNumFilter)) { int index = 0; sql.Append(" WHERE "); if (startNum >= 0) { SqlBuilder.JoinStringItem(sql, index++, "ROWNUMBER_ > " + startNum, " AND "); } if (endNum >= 0) { SqlBuilder.JoinStringItem(sql, index++, "ROWNUMBER_ <= " + endNum, " AND "); } if (!string.IsNullOrEmpty(rowNumFilter)) { SqlBuilder.JoinStringItem(sql, index++, rowNumFilter, " AND "); } } return(sql.ToString()); }