private void InitGetRuntimeTable() { _getRuntimeTable = LazyIndexer.Init <DataTable, Func <string, Func <Type, DataTable> > >((master) => { return(LazyIndexer.Init <string, Func <Type, DataTable> >((propertyName) => { return LazyIndexer.Init <Type, DataTable>((propertyType) => { var memberField = master.ObjectFields.FirstOrDefault((field) => { return field.GetPropertyName().EqualsIgnoreCase(propertyName); }); if (memberField == null) { //如果派生类中找不到子表,那么在基类中继续找 if (master.IsDerived) { return GetRuntimeTable(master.BaseTable, propertyName, propertyType); } throw new DataAccessException(string.Format(Strings.NotFoundTableField, master.Name, propertyName)); } Type objectType = propertyType.IsList() ? memberField.Tip.GetElementType() : propertyType; return CreateChildTable(master, memberField, objectType); }); })); }); }
public AssetDirectory() { _getFile = LazyIndexer.Init <string, AssetFile>((path) => { var assets = this.Assets; foreach (var item in assets) { var file = item as AssetFile; if (file != null) { if (file.Path == path) { return(file); } } else { var package = item as AssetPackage; if (package != null) { file = package.GetFile(path); if (file != null) { return(file); } } } } return(null); }); }
public DirectTable() { _getAddresses = LazyIndexer.Init <string, string[]>((fullName) => { return(_data.GetValues(fullName).ToArray()); }); }
public ObjectChain(IDataField source) { _source = source; _path = GetPath(source); this.PathCode = GetPathCode(); _getPathCode = LazyIndexer.Init <DataTable, string>(GetPathCodeImpl); }
protected WebPage() { _getKeyMethod = LazyIndexer.Init <string, MethodInfo>((methodName) => { return(this.GetType().ResolveMethod(methodName)); }); }
static TypeSchemaCodeInfo() { _getTypeInfo = LazyIndexer.Init <Type, Func <string, TypeSchemaCodeInfo> >((classType) => { return(LazyIndexer.Init <string, TypeSchemaCodeInfo>((schemaCode) => { return new TypeSchemaCodeInfo(classType, schemaCode); })); }); }
public TypeIndex() { _getCompleteName = LazyIndexer.Init <string, string>((typeName) => { if (typeName.StartsWith(_rootTypeNameDot)) { return(typeName); //已经包含根路径了 } return(string.Format("{0}.{1}", _rootTypeName, typeName)); }); }
//private Func<Type, MethodInfo> _getSaveData; private void InitDataAction() { _getLoadData = LazyIndexer.Init <Type, MethodInfo>((objectType) => { return(Repository.GetMethodFromRepository(objectType, this.LoadMethod)); }); //_getSaveData = LazyIndexer.Init<Type, MethodInfo>((objectType) => //{ // return Repository.GetMethodFromRepository(objectType, this.SaveMethod); //}); }
public ExpressionCache(Func <DataTable, string, QueryLevel, T> factory) { _getInstance = LazyIndexer.Init <DataTable, Func <string, Func <QueryLevel, T> > >((table) => { return(LazyIndexer.Init <string, Func <QueryLevel, T> >((expression) => { return LazyIndexer.Init <QueryLevel, T>((level) => { return factory(table, expression, level); }); })); }); }
public ConstructorParameterInfo(ConstructorRepositoryAttribute constructorTip, ParameterInfo original) { _constructorTip = constructorTip; this.Original = original; this.Tip = original.GetCustomAttribute <ParameterRepositoryAttribute>(true); this.PropertyTip = GetPropertyTip(); _getLoadData = LazyIndexer.Init <Type, MethodInfo>((objectType) => { if (this.Tip == null || string.IsNullOrEmpty(this.Tip.LoadMethod)) { return(null); } return(Repository.GetMethodFromRepository(objectType, this.Tip.LoadMethod)); }); }
/// <summary> /// 初始化一个 <see cref="MethodGenerator"/> 类的实例. /// </summary> /// <param name="writer">指令写入器</param> private MethodGenerator(ICILWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } var header = writer.MethodHeader; //检查非静态方法是否传入了声明类型 if (header.DeclaringType == null && NotStaticMethod(header)) { throw new ArgumentException("必须为非静态方法定义一个声明类型(方法所在类的类型)"); } //检查参数是否有null for (int i = 0; i < header.ParameterTypes.Length; ++i) { if (header.ParameterTypes[i] == null) { throw new ArgumentException("writer.Header.Parameters 不能包含null值", "writer"); } } _writer = writer; _header = header; //收集参数 _parameters = LazyIndexer.Init <int, Parameter>(parameterIndex => { if (NotStaticMethod(_header)) { ++parameterIndex; //如果不是静态方法,那么将参数索引值+1,因为第0个参数是this(也就是对象本身) } return(new Parameter(this, _writer.GetParameter(parameterIndex))); }); _currentScope = new Scope(this); //创建代码范围 }
public CalculateNumberCls(int waite) { _waite = waite; _getNumber = LazyIndexer.Init <string, int>(CalculateNumber); }
static TypeMakupInfo() { _getTypeInfo = LazyIndexer.Init <Type, TypeMakupInfo>(classType => new TypeMakupInfo(classType)); }
private void InitSql() { _getUpdateLRForInsertSqlBySqlServer = LazyIndexer.Init <string, string>(GetUpdateLRForInsertSqlBySqlServer); _getUpdateLRForDeleteSqlBySqlServer = LazyIndexer.Init <string, string>(GetUpdateLRForDeleteSqlBySqlServer); _getFindParentsSqlBySqlServer = LazyIndexer.Init <string, string>(GetFindParentsSqlBySqlServer); }
static TypeSerializationInfo() { _getTypeInfo = LazyIndexer.Init <Type, TypeSerializationInfo>(classType => new TypeSerializationInfo(classType)); }