/// <summary> /// 初始化一个新的形状候补建造者。 /// </summary> /// <param name="feature">特性。</param> /// <param name="shapeType">形状类型。</param> public ShapeAlterationBuilder(Feature feature, string shapeType) { _feature = feature; _bindingName = shapeType; var delimiterIndex = shapeType.IndexOf("__", StringComparison.Ordinal); _shapeType = delimiterIndex < 0 ? shapeType : shapeType.Substring(0, delimiterIndex); }
private static RecordBlueprint BuildRecord(Type type, Feature feature, ShellSettings settings) { var extensionDescriptor = feature.Descriptor.Extension; var extensionName = extensionDescriptor.Id.Replace('.', '_'); var dataTablePrefix = string.Empty; if (!string.IsNullOrEmpty(settings.GetDataTablePrefix())) dataTablePrefix = settings.GetDataTablePrefix() + "_"; return new RecordBlueprint { Type = type, Feature = feature, TableName = dataTablePrefix + extensionName + '_' + type.Name, }; }
private static ControllerBlueprint BuildController(Type type, Feature feature) { var areaName = feature.Descriptor.Extension.Id; var controllerName = type.Name; if (controllerName.EndsWith("Controller")) controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length); return new ControllerBlueprint { Type = type, Feature = feature, AreaName = areaName, ControllerName = controllerName, }; }
/// <summary> /// 来自哪一个特性。 /// </summary> /// <param name="feature">特性。</param> /// <returns>形状候补建造者。</returns> public ShapeAlterationBuilder From(Feature feature) { _feature = feature; return this; }
/// <summary> /// 初始化一个新的形状表格建造器。 /// </summary> /// <param name="feature">特性。</param> public ShapeTableBuilder(Feature feature) { _feature = feature; }
private static void ProcessPlacementFile(ShapeTableBuilder builder, FeatureDescriptor featureDescriptor, PlacementFile placementFile) { var feature = new Feature { Descriptor = featureDescriptor }; //反转树成叶子的列表,并在堆栈 var entries = DrillDownShapeLocations(placementFile.Nodes, Enumerable.Empty<PlacementMatch>()); foreach (var entry in entries) { var shapeLocation = entry.Item1; var matches = entry.Item2.ToArray(); string shapeType; string differentiator; GetShapeType(shapeLocation, out shapeType, out differentiator); Func<ShapePlacementContext, bool> predicate = ctx => true; if (differentiator != string.Empty) { predicate = ctx => (ctx.Differentiator ?? string.Empty) == differentiator; } if (matches.Any()) { predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate); } var placement = new PlacementInfo(); var segments = shapeLocation.Location.Split(';').Select(s => s.Trim()); foreach (var segment in segments) { if (!segment.Contains('=')) { placement.Location = segment; } else { var index = segment.IndexOf('='); var property = segment.Substring(0, index).ToLower(); var value = segment.Substring(index + 1); switch (property) { case "shape": placement.ShapeType = value; break; case "alternate": placement.Alternates = new[] { value }; break; case "wrapper": placement.Wrappers = new[] { value }; break; } } } builder.Describe(shapeType) .From(feature) .Placement(ctx => { var hit = predicate(ctx); //产生'调试'信息跟踪哪个文件起源的实际位置 if (hit) { var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info"; ctx.Source = virtualPath; } return hit; }, placement); } }
/// <summary> /// 初始化一个新的形状候补。 /// </summary> /// <param name="shapeType">形状类型。</param> /// <param name="feature">特性。</param> /// <param name="configurations">配置委托。</param> public ShapeAlteration(string shapeType, Feature feature, IList<Action<ShapeDescriptor>> configurations) { _configurations = configurations; ShapeType = shapeType; Feature = feature; }