/// <summary> /// 生成集合 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterDataSet(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { //var dataDataSet = from t in screenDef.Children // where t.MemberType == EMemberType.DataSet // select t; //if (dataDataSet != null && dataDataSet.ToList().Count() > 0) //{ // int index = 0; // foreach (var item in dataDataSet.ToList()) // { // if (index == 0) htmlWriter.WriteLine("{"); // else htmlWriter.WriteLine(",{"); // index++; // htmlWriter.WriteLine("RegType:\"Collection\","); // htmlWriter.WriteLine("RegValue:{"); // DataSet ds = (DataSet)item; // var entityName = (from t in compile.ProjectItems // where t.Value.DocumentType == 1 && t.Key == ds.EntityId // select t.Value.Name).FirstOrDefault(); // if (entityName != null) // { // htmlWriter.WriteLine("Name:\"" + item.Name + "\", Entity:\"" + entityName + "\""); // } // htmlWriter.WriteLine("}"); // if (index == dataDataSet.ToList().Count()) htmlWriter.WriteLine("},"); // else htmlWriter.WriteLine("}"); // } //} }
protected virtual void CreateScreen(ScreenDefinition definition) { var item = definition.Item; IScreen screen; if (item.scene != ScreenRoot.gameObject.scene) { screen = Object.Instantiate(item, ScreenRoot).GetComponent <IScreen>(); } else { screen = item.GetComponent <IScreen>(); if (item.transform.parent != ScreenRoot) { item.transform.SetParent(ScreenRoot); } } if (screen == null) { Debug.LogWarning($"Missing IScreen component on object: '{item.name}'."); } screen?.Initialize(this); }
public static string BuildControlBindTextProp(this ControlBase controlBase, ScreenDefinition screenDef, bool isPreview) { StringBuilder result = new StringBuilder(); string controlName = controlBase.GetType().Name; if (!isPreview && controlBase.Bindings.Count > 0) { foreach (var item in controlBase.Bindings) { string bindPath = item.Path == null ? "" : item.Path.Replace("CurrentItem", "SelectedItem"); string bindProperty = item.Property == null ? "" : item.Property; #region Value if (bindProperty.ToLower() == "value") { result.Append("{{"); if (bindPath.Split('.').Length == 1) { result.AppendFormat("{0}", bindPath); } else { string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; result.AppendFormat("item.{0}", field); } result.Append("}}"); break; } #endregion } } return(result.ToString()); }
/// <summary> /// 生成属性 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterProperty(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { var dataProperty = from t in screenDef.Children where t.MemberType == EMemberType.Property select t; if (dataProperty != null && dataProperty.ToList().Count > 0) { int index = 0; foreach (var item in dataProperty.ToList()) { if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } htmlWriter.WriteLine("RegType:\"Property\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("Name:\"" + item.Name + "\""); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); index++; } } }
public PageMainTemplate(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc) { this.Compile = ionicCompile; this.ScreenDef = screenDef; this.Documnet = doc; Initial(); }
/// <summary> /// 返回所有验证 /// </summary> /// <param name="controlBase"></param> /// <param name="screenDef"></param> /// <param name="validatorFullName"></param> /// <param name="dataTypeName"></param> /// <param name="dataTypeContent"></param> /// <returns></returns> public static void GetValidators(this ControlBase controlBase, ScreenDefinition screenDef, string validatorFullName, ref List <Model.Core.Definitions.Entities.ValidatorBase> listValidators, ref EDataBaseType baseType, ref CommonDataType dataTypeContent) { if (!string.IsNullOrEmpty(validatorFullName)) { //验证成员来自 1/绑定数据集中的数据项. 2/属性 string datasetName = validatorFullName.Split('.')[0]; var pathLength = validatorFullName.Split('.').Length; if (pathLength == 1) { //属性 var dataDataSet = (from t in screenDef.Children where t.MemberType == EMemberType.Property && t.Name == datasetName select t).FirstOrDefault(); if (dataDataSet != null) { BuildMemberValidatorsContent(dataDataSet, ref listValidators, ref baseType, ref dataTypeContent); } } else { //绑定数据集中的数据项 var dataDataSet = (from t in screenDef.Children where (t.MemberType == EMemberType.DataSet || t.MemberType == EMemberType.Objects) && t.Name == datasetName select t).FirstOrDefault(); if (dataDataSet != null) { var childItems = (from t in dataDataSet.Children where t.MemberType == EMemberType.CurrentItem || t.MemberType == EMemberType.SelectedItem select t.Children).FirstOrDefault(); if (childItems != null) { BuildMemberValidators(childItems, validatorFullName, true, ref listValidators, ref baseType, ref dataTypeContent); } } } } }
/// <summary> /// 生成属性数据 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterPropertyMetaData(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { var dataProperty = from t in screenDef.Children where t.MemberType == EMemberType.Property select t; if (dataProperty != null && dataProperty.ToList().Count > 0) { int index = 0; foreach (var item in dataProperty.ToList()) { var property = item as Property; var content = property.Content; dynamic type = content; if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } htmlWriter.WriteLine("RegType:\"Property\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("Name:\"" + item.Name + "\","); if (content.GetType().GetProperty("Title") != null) { htmlWriter.WriteLine("Title:\"" + type.Title + "\","); } if (content.GetType().GetProperty("IsRequired") != null) { htmlWriter.WriteLine("IsRequired:\"" + property.IsRequired.ToString().ToLower() + "\","); } if (content.GetType().GetProperty("IsCollection") != null) { htmlWriter.WriteLine("IsCollection:\"" + property.IsCollection.ToString().ToLower() + "\","); } if (content.GetType().GetProperty("DefaultValue") != null) { htmlWriter.WriteLine("DefaultValue:\"" + type.DefaultValue + "\","); } if (content.GetType().GetProperty("MaxLength") != null) { htmlWriter.WriteLine("MaxLength:\"" + type.MaxLength + "\","); } if (content.GetType().GetProperty("MinLength") != null) { htmlWriter.WriteLine("MinLength:\"" + type.MinLength + "\""); } htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); index++; } } }
public static string BuildControlBindProperty(this ControlBase controlBase, ScreenDefinition screenDef, bool isPreview) { StringBuilder result = new StringBuilder(); string controlName = controlBase.GetType().Name; if (!isPreview && controlBase.Bindings.Count > 0) { foreach (var item in controlBase.Bindings) { string bindPath = item.Path == null ? "" : item.Path.Replace("CurrentItem", "SelectedItem"); string bindProperty = item.Property == null ? "" : item.Property; #region DataSource if (bindProperty.ToLower() == "datasource") { continue; } #endregion #region Value if (bindProperty.ToLower() == "value") { string bindReslt = $"[(ngModel)]=\"{bindPath}\""; if (controlName.ToLower() == "ionsegmentcontent") { bindReslt = $"[ngSwitch]=\"{bindPath}\""; } result.Append(bindReslt); } #endregion #region OnClick else if (bindProperty.ToLower() == "onclick") { string bindResult = $"(click)=\"{bindPath}()\""; if (controlName.ToLower() == "ionitemsliding") { bindResult = $"(click)=\"{bindPath}(item)\""; } if (controlName.ToLower() == "ionrefresher") { bindResult = $"(ionRefresh)=\"{bindPath}($event)\""; } if (controlName.ToLower() == "ioninfinitescroll") { bindResult = $"(ionInfinite)=\"{bindPath}($event)\""; } result.Append(bindResult); } #endregion #region Url if (bindProperty.ToLower() == "url") { result.AppendFormat("[root]=\"{0}\"", bindPath); } #endregion } } return(result.ToString()); }
/// <summary> /// 构造函数 /// </summary> /// <param name="isPreview">是否预览</param> /// <param name="controlHost">控件</param> /// <param name="compile">编译器对象</param> /// <param name="htmlWriter">htmlWriter</param> public ControlBuildBase(bool isPreview, ControlHost controlHost, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter) { this.IsPreview = isPreview; this.ControlHost = controlHost; this.ScreenDefinition = screenDef; this.Compile = compile; this.ProjectDocument = doc; this.PermissionData = permissionData; this.HtmlWriter = htmlWriter; }
void InitializeScreenDefinitions(DefaultScreenFactory screenFactory) { screenFactory.Definitions.Add(new ScreenDefinition("MainMenuDemoScreen", typeof(MainMenuDemoScreen))); var loadingWindowDemoScreen = new ScreenDefinition("WindowDemoScreen", typeof(DemoLoadingScreen)); loadingWindowDemoScreen.Properties["LoadedScreenName"] = "WindowDemoScreenImpl"; screenFactory.Definitions.Add(loadingWindowDemoScreen); screenFactory.Definitions.Add(new ScreenDefinition("WindowDemoScreenImpl", typeof(WindowDemoScreen))); }
private void RegisterToViewModel(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { this.RegGridEvent(controlHost, htmlWriter); htmlWriter.WriteLine("screen.RegToViewModel(["); this.RegisterMethod(controlHost, screenDef, htmlWriter); this.RegisterDataSet(controlHost, screenDef, htmlWriter); this.RegisterProperty(controlHost, screenDef, htmlWriter); htmlWriter.WriteLine("]);"); }
public void Build(string project, ScreenDefinition sd, HtmlTextWriter htmlWriter, bool isPreview) { htmlWriter.AddAttribute("dojoType", "dojox/mvc/Group"); htmlWriter.AddAttribute("style", "width:100%;height:100%;"); htmlWriter.AddAttribute("class", "groupDiv"); htmlWriter.RenderBeginTag("div"); var builder = sd.Root.GetBuilder(isPreview, sd, null, htmlWriter); builder.Build(); htmlWriter.RenderEndTag(); }
public void Build(string project, string screen, ScreenDefinition sd, HtmlTextWriter htmlWriter) { htmlWriter.WriteLine(); htmlWriter.WriteLine("<script type=\"text/javascript\">"); htmlWriter.WriteLine("function " + project + "_" + screen + "_init(screen) {"); if (sd.Children.Count > 0) { this.RegisterToMetaData(sd.Root, sd, htmlWriter); this.RegisterToViewModel(sd.Root, sd, htmlWriter); } htmlWriter.WriteLine("screen.Initialize(0);"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("</script>"); }
/// <summary> /// 生成逻辑 /// </summary> /// <param name="compile">DOJO编译器</param> /// <param name="doc">文档对象模型</param> public string Build(string project, string screen, ScreenDefinition sd, bool isPreview) { using (var writer = new StringWriter()) { //根据屏幕生成HTML var htmlWriter = new HtmlTextWriter(writer); HtmlBuilder htmlBuilder = new HtmlBuilder(); htmlBuilder.Build(project, sd, htmlWriter, isPreview); if (!isPreview) { JsBuilder jsBuilder = new JsBuilder(); jsBuilder.Build(project, screen, sd, htmlWriter); } return(writer.ToString()); } }
/// <summary> /// 生成CSS /// </summary> /// <param name="compile"></param> /// <param name="screenDef"></param> /// <param name="doc"></param> private void BuildCss(CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc) { var ionicCompile = compile as IonicCompile; string fileName = doc.Name; string outputPath = ionicCompile.OutputPath + "\\" + fileName; if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } var file = Path.Combine(outputPath, fileName + ".scss"); if (File.Exists(file)) { File.Delete(file); } string content = string.Empty; //创建HTML文件 File.WriteAllText(file, content, System.Text.UTF8Encoding.UTF8); }
public void AssociateDialogFragment <TDialogFragment>(ScreenDefinition <TViewModel> screenDefinition, Func <TDialogFragment> fragmentCreator, Type hostActivityType = null, bool?shouldClearHistory = null) where TDialogFragment : DialogFragment { DialogFragmentViewFactory res; if (hostActivityType is null) { if (_defaultFragmentHost is null) { throw new InvalidOperationException("No fragment host has been specified and none has been registered as default"); } res = new DialogFragmentViewFactory(fragmentCreator, _defaultFragmentHost.ActivityType, shouldClearHistory ?? _defaultFragmentHost.ShouldClearHistory); } else { res = new DialogFragmentViewFactory(fragmentCreator, hostActivityType, shouldClearHistory ?? false); } _factoryAssociation[screenDefinition] = res; }
/// <summary> /// 生成Module页面HTML /// </summary> /// <param name="compile"></param> /// <param name="doc"></param> private void BuildModuleHtml(CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc) { if (doc.Name.ToLower() == "startuppage") { var ionicCompile = compile as IonicCompile; var targetDirectory = new System.IO.FileInfo(new Uri(this.GetType().Assembly.CodeBase).AbsolutePath).Directory.FullName; string outputPath = Path.Combine(targetDirectory.Replace("\\Wilmar.Service\\bin\\Extension", ""), @"Wilmar.Mobile\src\projects", ionicCompile.Project.Identity); outputPath = HttpUtility.UrlDecode(outputPath); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } //Module页面 var fileModulePage = Path.Combine(outputPath, ionicCompile.Project.Identity + ".module.ts"); if (File.Exists(fileModulePage)) { File.Delete(fileModulePage); } var contentModulePage = new ModuleTemplate(ionicCompile, doc).TransformText(); File.WriteAllText(fileModulePage, contentModulePage, System.Text.UTF8Encoding.UTF8); //生成Mian页面TS var fileMainPage = Path.Combine(outputPath, ionicCompile.Project.Identity + ".ts"); if (File.Exists(fileMainPage)) { File.Delete(fileMainPage); } var contentMainPage = new PageMainTemplate(ionicCompile, screenDef, doc).TransformText(); File.WriteAllText(fileMainPage, contentMainPage, System.Text.UTF8Encoding.UTF8); //生成Mian页面CSS var fileMainCss = Path.Combine(outputPath, ionicCompile.Project.Identity + ".scss"); if (File.Exists(fileMainCss)) { File.Delete(fileMainCss); } string contentMainCss = string.Empty; File.WriteAllText(fileMainCss, contentMainCss, System.Text.UTF8Encoding.UTF8); } }
/// <summary> /// 生成方法 /// </summary> /// <param name="controlHost">控制基类</param> /// <param name="compile">编译器</param> /// <param name="screenDef">屏幕定义器</param> /// <param name="htmlWriter">输出</param> private void RegisterMethod(ControlHost controlHost, ScreenDefinition screenDef, HtmlTextWriter htmlWriter) { this.GetDataSetDefaultMethod(controlHost, htmlWriter); var dataMethod = from t in screenDef.Children where t.MemberType == EMemberType.Method select t; if (dataMethod != null && dataMethod.ToList().Count > 0) { int index = 0; foreach (var item in dataMethod.ToList()) { if (index == 0) { htmlWriter.WriteLine("{"); } else { htmlWriter.WriteLine(",{"); } index++; htmlWriter.WriteLine("RegType:\"Method\","); htmlWriter.WriteLine("RegValue:{"); htmlWriter.WriteLine("" + item.Name + ":function(e){"); htmlWriter.WriteLine("}"); htmlWriter.WriteLine("}"); if (index == dataMethod.ToList().Count()) { htmlWriter.WriteLine("},"); } else { htmlWriter.WriteLine("}"); } } } }
/// <summary> /// 当前绑定的属性是否是导航属性 /// </summary> /// <param name="screenDef"></param> /// <param name="bindPath"></param> /// <returns></returns> public static bool bindNavigatorMember(this ControlBase controlBase, ScreenDefinition screenDef, string bindPath, int pathLevel = 3) { bool isNavigatorMember = false; string datasetName = bindPath.Split('.')[0]; var dataDataSet = (from t in screenDef.Children where (t.MemberType == EMemberType.DataSet || t.MemberType == EMemberType.Objects) && t.Name == datasetName select t).FirstOrDefault(); if (dataDataSet != null) { var childItems = (from t in dataDataSet.Children where t.MemberType == EMemberType.CurrentItem || t.MemberType == EMemberType.SelectedItem select t.Children).FirstOrDefault(); if (childItems != null) { var path = bindPath; if (pathLevel == 4) { path = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "." + bindPath.Split('.')[2]; } var dataMember = (from t in childItems where t.FullName == path select t).FirstOrDefault(); if (dataMember != null) { if (pathLevel == 4) { MemberBase childMB = dataMember as MemberBase; var childMBs = (from t in childMB.Children where t.FullName == bindPath select t).FirstOrDefault(); if (childMBs != null) { if (childMBs.MemberType == EMemberType.NavigateMember || childMBs.MemberType == EMemberType.DataSet) { return(isNavigatorMember = true); } } } else if (dataMember.MemberType == EMemberType.NavigateMember) { return(isNavigatorMember = true); } } } } return(isNavigatorMember); }
public SampleNavigationService(IPresenterService <SampleViewModel> presenterService) : base(presenterService) { _presenter = presenterService; HomeSync = new ScreenDefinition <SampleViewModel>("home", _ => new SampleViewModel("home").AsTask()); Menu = new ScreenDefinition <SampleViewModel>("menu", _ => new SampleViewModel("menu").AsTask()); Profile = new ScreenDefinition <SampleViewModel>("profile", _ => new SampleViewModel("profile").AsTask()); UpdatePwd = new ScreenDefinition <SampleViewModel>("updatePwd", _ => new SampleViewModel("updatePwd").AsTask()); Cgu = new ScreenDefinition <SampleViewModel>("cgu", _ => new SampleViewModel("cgu").AsTask()); Login = new ScreenDefinition <SampleViewModel>("login", _ => new SampleViewModel("login").AsTask()); ListOffer = new ScreenDefinition <SampleViewModel>("offers", _ => new SampleViewModel("offers").AsTask()); DetailOffer = new ScreenDefinition <SampleViewModel>("{offerId}", _ => new SampleViewModel("{offerId}").AsTask()); DetailProduct = new ScreenDefinition <SampleViewModel>("{productId}", _ => new SampleViewModel("{productId}").AsTask()); //Registre scree associations. this.RegisterEntryPoint(HomeSync); this.RegisterEntryPoint(Login); this.Register(HomeSync, Profile); this.Register(Profile, UpdatePwd); this.Register(Profile, Cgu); this.Register(Login, Cgu); this.Register(HomeSync, ListOffer); this.Register(ListOffer, DetailOffer); this.Register(DetailOffer, DetailProduct); this.Register(DetailOffer, DetailOffer); this.Register(HomeSync, Menu); this.Register(Profile, Menu); this.Register(UpdatePwd, Menu); this.Register(Cgu, Menu); this.Register(ListOffer, Menu); this.Register(DetailOffer, Menu); this.Register(DetailProduct, Menu); }
/// <summary> /// 生成HTML /// </summary> /// <param name="name">屏幕名称</param> /// <param name="controlHost">控件基类</param> /// <param name="compile">编译基类</param> /// <param name="screenDef">屏幕定义</param> /// <param name="doc">项目文档</param> private void BuildHtml(ControlHost controlHost, CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc) { using (var writer = new StringWriter()) { var ionicCompile = compile as IonicCompile; Dictionary <int, Tuple <int, string> > itemPermissionData = new Dictionary <int, Tuple <int, string> >(); var xmlWriter = new HtmlTextWriter(writer); var builder = controlHost.GetBuilder(false, screenDef, compile, doc, itemPermissionData, xmlWriter); builder.Build(); //生成文件全路径 string fileName = doc.Name; string outputPath = ionicCompile.OutputPath + "\\" + fileName; if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } var file = Path.Combine(outputPath, fileName + ".html"); if (File.Exists(file)) { File.Delete(file); } //创建HTML文件 File.WriteAllText(file, writer.ToString(), System.Text.UTF8Encoding.UTF8); //启动屏幕名字暂时固定 //projets/pages中启动屏幕不生成TS文件,TS文件在外部生成 if (fileName.ToLower() != "startuppage") { //生成JS this.BuildJs(compile, screenDef, doc); //生成CSS this.BuildCss(compile, screenDef, doc); } } }
/// <summary> /// 绑定属性Path为空 /// </summary> /// <param name="screenDef"></param> /// <param name="name"></param> /// <returns></returns> private static bool IsEmptyPathType(this ControlBase controlBase, ScreenDefinition screenDef, string name) { bool isEmpty = false; if (screenDef != null) { var datas = from t in screenDef.Children where (t.MemberType == EMemberType.Property || t.MemberType == EMemberType.Method || t.MemberType == EMemberType.BuiltMethod) && t.FullName == name select t; if (datas != null && datas.ToList().Count > 0) { return(true); } List <MemberBase> list = screenDef.Children; foreach (var item in list) { var itemDatas = from t in item.Children where (t.MemberType == EMemberType.Property || t.MemberType == EMemberType.Method || t.MemberType == EMemberType.BuiltMethod) && t.FullName == name select t; if (itemDatas != null && itemDatas.ToList().Count > 0) { isEmpty = true; break; } } } return(isEmpty); }
public void AssociateModal(ScreenDefinition <TViewModel> screenDefinition, ViewCreator <TViewModel> controllerFactory) { _factoryAssociation[screenDefinition] = new ControllerInformation <TViewModel>(controllerFactory, isModal: true); }
/// <summary> /// 获取验证器 /// </summary> /// <param name="controlBase"></param> /// <param name="screenDef"></param> /// <returns></returns> private static string BuildValidators(this ControlBase controlBase, ScreenDefinition screenDef, string validatorFullName) { StringBuilder result = new StringBuilder(); StringBuilder sbValidator = new StringBuilder(); List <Model.Core.Definitions.Entities.ValidatorBase> listValidators = new List <Model.Core.Definitions.Entities.ValidatorBase>(); EDataBaseType baseType = EDataBaseType.String; CommonDataType dataTypeContent = null; GetValidators(controlBase, screenDef, validatorFullName, ref listValidators, ref baseType, ref dataTypeContent); string dataTypeName = BuildCommonMethod.GetTypeName(baseType); if (listValidators.Count > 0 && dataTypeContent != null) { string defaultValue = string.Empty, maxValue = string.Empty, minValue = string.Empty, maxLength = string.Empty, minLength = string.Empty; BuildCommonMethod.GetDataTypeValue(dataTypeContent, ref defaultValue, ref maxValue, ref minValue, ref maxLength, ref minLength); foreach (var validator in listValidators) { string validatorType = validator.ValidatorType.ToString().ToLower(); if (validator.ValidatorType == Model.Core.Definitions.Entities.EValidatorType.Phone) { validatorType = "tel"; } else if (validator.ValidatorType == Model.Core.Definitions.Entities.EValidatorType.EmailAddress) { validatorType = "email"; } else if (validator.ValidatorType == Model.Core.Definitions.Entities.EValidatorType.RegularExpression) { validatorType = "regexp"; } else if (dataTypeName == "date" && validator.ValidatorType == Model.Core.Definitions.Entities.EValidatorType.Range) { validatorType = "daterange"; } if (validator.ValidatorType != Model.Core.Definitions.Entities.EValidatorType.Compare) { sbValidator.Append("" + validatorType + ":{"); sbValidator.AppendFormat("message:'{0}'", validator.ErrorMessage); switch (validator.ValidatorType) { case Model.Core.Definitions.Entities.EValidatorType.MinLength: if (dataTypeName == "string") { sbValidator.AppendFormat(",min:{0}", minLength); } break; case Model.Core.Definitions.Entities.EValidatorType.MaxLength: if (dataTypeName == "string") { sbValidator.AppendFormat(",max:{0}", maxLength); } break; case Model.Core.Definitions.Entities.EValidatorType.Range: if (dataTypeName == "number") { sbValidator.AppendFormat(",min:{0}", minValue); sbValidator.AppendFormat(",max:{0}", maxValue); } else if (dataTypeName == "date") { if (minValue != null) { DateTime dtMin = Convert.ToDateTime(minValue); sbValidator.AppendFormat(",min:'{0}'", dtMin.ToString("yyyy-MM-dd")); } if (maxValue != null) { DateTime dtMax = Convert.ToDateTime(maxValue); sbValidator.AppendFormat(",max:'{0}'", dtMax.ToString("yyyy-MM-dd")); } } break; case Model.Core.Definitions.Entities.EValidatorType.RegularExpression: var cValidator = validator as Model.Core.Definitions.Entities.Validators.RegularExpressionValidator; sbValidator.AppendFormat(",pattern:'{0}'", cValidator.Pattern.Replace(@"\", @"\\")); break; } sbValidator.Append("},"); } } } string _sbValidator = sbValidator.ToString().Length > 0 ? sbValidator.ToString().Substring(0, sbValidator.ToString().Length - 1) : ""; if (!string.IsNullOrEmpty(_sbValidator)) { result.Append("validators:{"); result.Append(_sbValidator); result.Append("},"); } return(result.ToString()); }
/// <summary> /// 生成方法 /// </summary> public static Dictionary <string, MetaDataMethod> RegisterMethods(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc) { Dictionary <string, MetaDataMethod> MethodData = new Dictionary <string, MetaDataMethod>(); var items = screenDef.Children.Where(a => a.MemberType == EMemberType.Method).ToList(); foreach (var item in items) { MetaDataMethod methodMember = GetMethodContent(item); MethodData.Add(item.Name, methodMember); } return(MethodData); }
/// <summary> /// 获取data-dojo-props /// </summary> /// <param name="controlBase"></param> /// <param name="screenDef"></param> /// <param name="isPreview"></param> /// <param name="returnContent"></param> /// <param name="isDataGridCell"></param> /// <returns></returns> public static string BuildControlProps(this ControlBase controlBase, ScreenDefinition screenDef, bool isPreview, Dictionary <int, Tuple <int, string> > permissionData, StringBuilder returnContent, StringBuilder sbConstraints = null, bool isDataGridCell = false, bool isListBox = false, bool isGridFormat = false) { StringBuilder result = new StringBuilder(); StringBuilder sbProps = new StringBuilder(); string controlName = controlBase.GetType().Name; dynamic control = controlBase; #region 权限 if (permissionData != null && permissionData.Count > 0) { if (!string.IsNullOrEmpty(controlBase.Permissions)) { string permissionStr = string.Empty; string[] pArray = controlBase.Permissions.Split(','); foreach (var pa in pArray) { foreach (var pd in permissionData) { if (pd.Key == int.Parse(pa)) { permissionStr += pd.Value.Item2 + ":" + pd.Value.Item1 + ","; } } } if (!string.IsNullOrEmpty(permissionStr)) { if (isDataGridCell) { returnContent.AppendFormat("{0},", permissionStr.Substring(0, permissionStr.Length - 1)); } else { sbProps.AppendFormat("{0},", permissionStr.Substring(0, permissionStr.Length - 1)); } } } } #endregion #region Bindings if (!isPreview && controlBase.Bindings.Count > 0) { Dictionary <string, string> dictProperty = GetPropertyBindValue(controlBase); foreach (var item in controlBase.Bindings) { string property = string.Empty, contextStr = string.Empty; string bindPath = item.Path == null ? "" : item.Path.Replace("CurrentItem", "SelectedItem"); string bindProperty = item.Property == null ? "" : item.Property; string path = bindPath; string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; if (dictProperty.ContainsKey(bindProperty)) { if (dictProperty.TryGetValue(bindProperty, out property)) { bindProperty = property; } } if (!string.IsNullOrEmpty(bindPath) && !string.IsNullOrEmpty(bindProperty)) { #region if (bindProperty.ToLower() == "datasource") { if (controlName == "DataGrid" || controlName == "TreeGrid" || controlName == "PivotGrid" || controlName == "ListBox") { continue; } } else if (bindProperty.ToLower() == "searchvalue" || bindProperty.ToLower() == "searchfield") { continue; } #endregion #region DisplayText else if (bindProperty.ToLower() == "displaytext") { if (isDataGridCell) { string formatter = string.Empty; if (bindPath.Split('.').Length == 4) { bool isNavigatorMember = bindNavigatorMember(controlBase, screenDef, item.Path, 4); if (!isNavigatorMember) { if (!isGridFormat && controlName != "DatePicker" && controlName != "TimePicker") { string selectedStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "."; string fieldFullName = bindPath.Replace(selectedStr, ""); returnContent.AppendFormat("fieldFullName:'{0}',", fieldFullName); formatter = "formatter:function(inDatum){if(inDatum){return inDatum." + field + ";}else{return '';}}"; } } } else if (bindPath.Split('.').Length == 5) { string selectedStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "."; string fieldFullName = bindPath.Replace(selectedStr, ""); returnContent.AppendFormat("fieldFullName:'{0}',", fieldFullName); if (!isGridFormat && controlName != "DatePicker" && controlName != "TimePicker") { string relStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "." + bindPath.Split('.')[2] + "."; string relName = bindPath.Replace(relStr, ""); string relFirst = relName.Split('.')[0]; formatter = "formatter:function(inDatum){if(inDatum){if(inDatum." + relFirst + "){return inDatum." + relName + ";}else{return '';}}else{return '';}}"; } } if (!string.IsNullOrEmpty(formatter)) { returnContent.AppendFormat("{0},", formatter); } } } #endregion #region Condition else if (bindProperty.ToLower() == "condition") { if (isDataGridCell) { returnContent.AppendFormat("{0}: at('rel:{1}','{2}'),", bindProperty, "", field); continue; } } else if (bindProperty.ToLower() == "batcheditcondition") { continue; } #endregion #region Value else if (bindProperty.ToLower() == "value") { if (controlName == "ReportViewer") { continue; } #region isListBox if (isListBox) { if (bindPath.Split('.').Length == 4) { field = bindPath.Split('.')[2] + "." + bindPath.Split('.')[3]; } string itemPro = "${item." + field + "}"; sbProps.AppendFormat("{0}: {1},", bindProperty, itemPro); continue; } #endregion #region isDataGridCell if (isDataGridCell) { string formatter = string.Empty; if (bindPath.Split('.').Length == 3) { bool isNavigatorMember = bindNavigatorMember(controlBase, screenDef, item.Path); if (!isNavigatorMember) { returnContent.AppendFormat("fieldFullName:'{0}',", field); } } else if (bindPath.Split('.').Length == 4) { bool isNavigatorMember = bindNavigatorMember(controlBase, screenDef, item.Path, 4); if (!isNavigatorMember) { if (!isGridFormat && controlName != "DatePicker" && controlName != "TimePicker") { string selectedStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "."; string fieldFullName = bindPath.Replace(selectedStr, ""); returnContent.AppendFormat("fieldFullName:'{0}',", fieldFullName); formatter = "formatter:function(inDatum){if(inDatum){return inDatum." + field + ";}else{return '';}}"; } } field = bindPath.Split('.')[2]; } else if (bindPath.Split('.').Length == 5) { if (!isGridFormat && controlName != "DatePicker" && controlName != "TimePicker") { string selectedStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "."; string fieldFullName = bindPath.Replace(selectedStr, ""); returnContent.AppendFormat("fieldFullName:'{0}',", fieldFullName); string relStr = bindPath.Split('.')[0] + "." + bindPath.Split('.')[1] + "." + bindPath.Split('.')[2] + "."; string relName = bindPath.Replace(relStr, ""); string relFirst = relName.Split('.')[0]; formatter = "formatter:function(inDatum){if(inDatum){if(inDatum." + relFirst + "){return inDatum." + relName + ";}else{return '';}}else{return '';}}"; } field = bindPath.Split('.')[2]; } returnContent.AppendFormat("field:'{0}',", field); if (!string.IsNullOrEmpty(formatter)) { returnContent.AppendFormat("{0},", formatter); } continue; } #endregion #region ComboBox if (controlName == "ComboBox") { if (bindPath.Split('.').Length == 3) { bool isNavigatorMember = bindNavigatorMember(controlBase, screenDef, item.Path); if (isNavigatorMember) { bindProperty = "item"; } } } #endregion else if (controlName == "CheckBox" || controlName == "RadioBox" || controlName == "ToggleButton") { bindProperty = "checked"; } else if (controlName == "SelectBox" || controlName == "CheckedMultiSelect" || controlName == "SearchMultiSelect" || controlName == "SelectPage") { bindProperty = "values"; } } #endregion #region Max/Min if (bindProperty.ToLower() == "maximum") { if (controlName == "Numeric" || controlName == "ProgressBar") { bindProperty = "max"; } } else if (bindProperty.ToLower() == "minimum") { if (controlName == "Numeric" || controlName == "ProgressBar") { bindProperty = "min"; } } #endregion #region OnClick else if (bindProperty.ToLower() == "onclick") { if (controlName == "TreeView") { bindProperty = "onNodeClick"; } } #endregion #region OnRowDoubleClick 网格双击行事件 else if (bindProperty.ToLower() == "onrowdblclick") { returnContent.AppendFormat("rowdblclick:at('rel:{0}','{1}').direction(1),", "", path); continue; } #endregion #region Rended 网格渲染完成事件 else if (bindProperty.ToLower() == "rended") { returnContent.AppendFormat("rended:at('rel:{0}','{1}').direction(1),", "", path); continue; } #endregion #region GotoPage 网格分页事件 else if (bindProperty.ToLower() == "gotopage") { returnContent.AppendFormat("GotoPage:at('rel:{0}','{1}').direction(1),", "", path); continue; } #endregion #region if (bindPath.Split('.').Length == 1) { if (IsEmptyPathType(controlBase, screenDef, bindPath)) { path = ""; } if (controlName == "DataGrid") { path = ""; } } else if (bindPath.Split('.').Length == 2) { path = bindPath.Split('.')[0]; } else { path = bindPath.Replace("." + field, ""); } if (!string.IsNullOrEmpty(path) && (controlName == "Button" || controlName == "MenuItem")) { contextStr = string.Format("context:at('rel:','{0}'),", path); } sbProps.AppendFormat("{0}: at('rel:{1}','{2}'),{3}", bindProperty, path, field, contextStr); #endregion } } } #endregion #region DataSource if (!isPreview && controlBase.ExistProperty("DataSource")) { string bindPath = control.DataSource; if (isDataGridCell && !string.IsNullOrEmpty(bindPath)) { sbProps.AppendFormat("store: at('rel:{0}', '{1}').direction(1),", "", bindPath); } } #endregion #region ValueMember/DispalyMember/ChildMember/ParentMember/FocusDisplayMember/CheckedAttr/ResultAttr if (!isPreview && controlBase.ExistProperty("ValueMember")) { string bindPath = control.ValueMember; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; if (controlName == "TreeView" || controlName == "Menu") { path = "idAttr"; } else { path = "valueAttr"; } sbProps.AppendFormat("{0}:'{1}',", path, field); } } if (!isPreview && controlBase.ExistProperty("DisplayMember")) { string bindPath = control.DisplayMember; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; if (controlName == "TreeView" || controlName == "Menu") { path = "labelAttr"; } else if (controlName == "SelectBox" || controlName == "CheckedMultiSelect" || controlName == "SearchMultiSelect" || controlName == "RadioButtonList" || controlName == "SelectPage") { path = "displayAttr"; } else { path = "searchAttr"; } sbProps.AppendFormat("{0}:'{1}',", path, field); } } if (!isPreview && controlBase.ExistProperty("ChildMember")) { string bindPath = control.ChildMember; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; if (controlName == "TreeView") { sbProps.AppendFormat("{0}:'{1}',", "childrenAttr", field); } } } if (!isPreview && controlBase.ExistProperty("ParentMember")) { string bindPath = control.ParentMember; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; if (controlName == "TreeView") { sbProps.AppendFormat("{0}:'{1}',", "parentAttr", field); } } } if (!isPreview && controlBase.ExistProperty("FocusDisplayMember")) { string bindPath = control.FocusDisplayMember; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; path = "focusAttr"; sbProps.AppendFormat("{0}:'{1}',", path, field); } } if (!isPreview && controlBase.ExistProperty("CheckedAttr")) { string bindPath = control.CheckedAttr; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; path = "checkedAttr"; sbProps.AppendFormat("{0}:'{1}',", path, field); } } if (!isPreview && controlBase.ExistProperty("ResultAttr")) { string bindPath = control.ResultAttr; if (!string.IsNullOrEmpty(bindPath)) { string path = string.Empty; //string field = bindPath.Split('.')[bindPath.Split('.').Length - 1]; string field = bindPath; path = "resultAttr"; sbProps.AppendFormat("{0}:'{1}',", path, field); } } #endregion #region Max/Min if (controlBase.ExistProperty("Maximum") && control.Maximum != null) { if (controlName == "DatePicker" || controlName == "ProgressBar") { string atName = string.Empty, atValue = string.Empty; if (controlName == "ProgressBar") { atName = "max"; atValue = control.Maximum.ToString(); } else { atName = "maximum"; atValue = "'" + control.Maximum.ToString("yyyy-MM-dd") + "'"; } sbProps.AppendFormat("{0}:{1},", atName, atValue); } else if (controlName == "Numeric") { sbConstraints.AppendFormat("max:{0},", control.Maximum.ToString()); } } if (controlBase.ExistProperty("Minimum") && control.Minimum != null) { if (controlName == "DatePicker") { string atName = string.Empty, atValue = string.Empty; { atName = "minimum"; atValue = "'" + control.Minimum.ToString("yyyy-MM-dd") + "'"; } sbProps.AppendFormat("{0}:{1},", atName, atValue); } else if (controlName == "Numeric") { sbConstraints.AppendFormat("min:{0},", control.Minimum.ToString()); } } #endregion #region Value if (controlBase.ExistProperty("Value") && control.Value != null) { if (!string.IsNullOrEmpty(control.Value.ToString())) { #region if (controlName == "ReportViewer") { } else if (controlName == "DatePicker" || controlName == "Calendar") { sbProps.AppendFormat("value:'{0}',", control.Value.ToString("yyyy-MM-dd")); } else if (controlName == "CheckBox" || controlName == "RadioBox") { if (control.Value) { sbProps.AppendFormat("checked:'{0}',", control.Value == true ? "checked" : ""); } } else if (controlName == "SelectBox" || controlName == "CheckedMultiSelect" || controlName == "SearchMultiSelect") { sbProps.AppendFormat("values:'{0}',", control.Value.ToString()); } else if (controlName == "ToggleButton") { sbProps.AppendFormat("checked:'{0}',iconClass:'dijitCheckBoxIcon',", control.Value == true ? "checked" : ""); } else if (controlName == "TimePicker") { sbProps.AppendFormat("value:'T{0}',", control.Value.TimeOfDay.ToString().Substring(0, 5)); } else if (controlName == "ProgressBar") { sbProps.AppendFormat("value:{0},", control.Value.ToString()); } else if (controlName == "Accordion" || controlName == "TabControl") { sbProps.AppendFormat("selectedIndex:{0},", control.Value.ToString()); } else { sbProps.AppendFormat("value:'{0}',", control.Value.ToString()); } #endregion } } #endregion #region PlaceHolder if (controlBase.ExistProperty("Watermark") && control.Watermark != null) { sbProps.AppendFormat("placeHolder:'{0}',", control.Watermark); } #endregion #region Url if (controlBase.ExistProperty("Url") && control.Url != null) { sbProps.AppendFormat("url:'{0}',", control.Url); } #endregion #region 验证器 string validatorFullName = string.Empty; if (controlBase.Bindings.Count > 0) { var bindValue = (from t in controlBase.Bindings where t.Path != null && t.Property != null && t.Property.ToLower() == "value" select t).FirstOrDefault(); if (bindValue != null) { validatorFullName = bindValue.Path; bool isBindNavigatorMember = bindNavigatorMember(controlBase, screenDef, validatorFullName); if (isBindNavigatorMember) { var validatorMember = (from t in controlBase.Bindings where t.Path != null && t.Property != null && t.Property.ToLower() == "validatormember" select t).FirstOrDefault(); if (validatorMember != null) { validatorFullName = validatorMember.Path; } } } if (!string.IsNullOrEmpty(validatorFullName)) { string validatorsStr = BuildValidators(controlBase, screenDef, validatorFullName); sbProps.Append(validatorsStr); } } #endregion if (sbProps.ToString().Length > 0) { result.Append(sbProps.ToString().Substring(0, sbProps.ToString().Length - 1)); } return(result.ToString()); }
/// <summary> /// 获取生成器 /// </summary> /// <param name="control">控件对象</param> /// <returns>返回控件对应的生成器</returns> public static ControlBuildBase GetBuilder(this ControlHost controlHost, bool isPreview, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter) { //图表控件名字为空自动生成一个默认名字 var controlName = controlHost.Content.GetType().Name; if (controlName == "ChartPane" || controlName == "DropDownButton") { if (string.IsNullOrEmpty(controlHost.Name)) { controlHost.Name = controlName + ctlNumber++; } } if (!isPreview && doc != null && !string.IsNullOrEmpty(controlHost.Name)) { controlHost.Name = doc.Name + "_" + controlHost.Name; } if (controlHost.Content != null) { var assembly = Assembly.GetAssembly(typeof(ControlExtend)); string typeName = string.Format("Wilmar.Build.Core.Dojo.Default.Builders.{0}Build", controlHost.Content.GetType().Name); if (assembly.GetType(typeName) == null) { throw new Exception(string.Format("类型【{0}】没对应的生成器。", typeName)); } ControlBuildBase builder = Activator.CreateInstance(assembly.GetType(typeName), isPreview, controlHost, screenDef, compile, doc, permissionData, htmlWriter) as ControlBuildBase; return(builder); } else { return(null); } }
/// <summary> /// 生成HTML /// </summary> /// <param name="name">屏幕名称</param> /// <param name="controlHost">控件基类</param> /// <param name="compile">编译基类</param> /// <param name="screenDef">屏幕定义</param> /// <param name="doc">项目文档</param> private void BuildHtml(string name, ControlHost controlHost, CompileBase compile, ScreenDefinition screenDef, ProjectDocument doc) { using (var writer = new StringWriter()) { var dojoCompile = compile as DojoCompile; #region 写入权限操作 //序号,权限ID,权限作用 Dictionary <int, Tuple <int, string> > itemPermissionData = new Dictionary <int, Tuple <int, string> >(); var permissionConfigure = screenDef.PermissionConfigure; if (permissionConfigure != null && permissionConfigure.EnableAuth) { int permissionItemId = 1; string identity = dojoCompile.Project.Identity; var permissionItems = screenDef.PermissionConfigure.PermissionItems; foreach (var item in permissionItems) { short purpose = DojoCompile.PermissionScreen; switch (item.Purpose) { case EPermissionPurpose.Operate: purpose = DojoCompile.PermissionOperate; break; case EPermissionPurpose.Visible: purpose = DojoCompile.PermissionVisible; break; case EPermissionPurpose.Custom: purpose = DojoCompile.PermissionCustom; break; } permissionItemId = int.Parse(item.Id); string title = item.Title; string desc = doc.Title + " " + item.Description; int permissionId = dojoCompile.Permission.Write(doc.Id, purpose, item.Id, title, desc); itemPermissionData.Add(permissionItemId, new Tuple <int, string>(permissionId, item.Purpose.ToString().ToLower())); } } #endregion //根据屏幕生成HTML var xmlWriter = new HtmlTextWriter(writer); xmlWriter.AddAttribute("dojoType", "dojox/mvc/Group"); xmlWriter.AddAttribute("style", "width:100%;height:100%;position:relative;"); xmlWriter.AddAttribute("class", "groupDiv"); xmlWriter.RenderBeginTag("div"); var builder = controlHost.GetBuilder(false, screenDef, compile, doc, itemPermissionData, xmlWriter); builder.Build(); xmlWriter.RenderEndTag(); //生成屏幕JS BuildScreenJs.BuildJs(controlHost, compile, screenDef, xmlWriter, doc); //生成文件全路径 var file = Path.Combine(((DojoCompile)compile).OutputPath, name + ".html"); if (File.Exists(file)) { File.Delete(file); } //创建HTML文件 File.WriteAllText(file, writer.ToString(), System.Text.UTF8Encoding.UTF8); ControlExtend.ctlNumber = 1; } }
void InitializeScreenDefinitions(DefaultScreenFactory screenFactory) { screenFactory.Definitions.Add(new ScreenDefinition("MainMenuDemoScreen", typeof(MainMenuDemoScreen))); var loadingWindowDemoScreen = new ScreenDefinition("WindowDemoScreen", typeof(DemoLoadingScreen)); loadingWindowDemoScreen.Properties["LoadedScreenName"] = "WindowDemoScreenImpl"; screenFactory.Definitions.Add(loadingWindowDemoScreen); screenFactory.Definitions.Add(new ScreenDefinition("WindowDemoScreenImpl", typeof(WindowDemoScreen))); }
public TooltipDialogBuild(bool isPreview, ControlHost controlHost, ScreenDefinition screenDef, CompileBase compile, ProjectDocument doc, Dictionary <int, Tuple <int, string> > permissionData, HtmlTextWriter htmlWriter) : base(isPreview, controlHost, screenDef, compile, doc, permissionData, htmlWriter) { }
/// <summary> /// 生成数据集 /// </summary> /// <param name="ionicCompile"></param> /// <param name="screenDef"></param> /// <param name="doc"></param> /// <returns></returns> public static Dictionary <string, MetaDataDataSet> RegisterDataSets(IonicCompile ionicCompile, ScreenDefinition screenDef, ProjectDocument doc) { Dictionary <string, MetaDataDataSet> DataSetData = new Dictionary <string, MetaDataDataSet>(); var items = screenDef.Children.Where(a => a.MemberType == EMemberType.DataSet || a.MemberType == EMemberType.Objects).ToList(); foreach (var item in items) { if (item.MemberType == EMemberType.DataSet) { #region 远程数据集(有实体) DataSet dats = item as DataSet; var entityItem = ionicCompile.ProjectItems.Where(a => a.Value.DocumentType == GlobalIds.DocumentType.Entity && a.Key == dats.EntityId).FirstOrDefault(); if (entityItem.Value != null) { MetaDataDataSet metaDataSet = BuildMetaDataDataSet(entityItem.Value.Name, item); if (metaDataSet != null) { DataSetData.Add(item.Name, metaDataSet); } } #endregion } else { Objects objs = item as Objects; var entityItem = ionicCompile.ProjectItems.Where(a => a.Value.DocumentType == GlobalIds.DocumentType.Entity && a.Key == objs.EntityId).FirstOrDefault(); if (entityItem.Value != null) { #region 本地对象(有实体) MetaDataDataSet metaDataSet = BuildMetaDataDataSet(entityItem.Value.Name, item); if (metaDataSet != null) { DataSetData.Add(item.Name, metaDataSet); } #endregion } else { #region 本地对象(无实体) MetaDataDataSet metaDataSet = BuildMetaDataDataSet("", item); if (metaDataSet != null) { DataSetData.Add(item.Name, metaDataSet); } #endregion } } } return(DataSetData); }