示例#1
0
        private static string PrepareInsertPropertyDefineSql(SchemaDefine data, SchemaPropertyDefine pd)
        {
            InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(pd);

            builder.AppendItem("SchemaName", data.Name);

            return(string.Format("INSERT INTO {0}{1}", ORMapping.GetMappingInfo(pd.GetType()).TableName, builder.ToSqlString(TSqlBuilder.Instance)));
        }
        public static void Output(this SchemaPropertyDefine propertyDefine, TextWriter writer, int indent = 0)
        {
            string indentChars = new string('\t', indent);

            writer.WriteLine("{0}Name={1}, Desp={2}, Type={3}, Category={4}, SnapshotMode={5}",
                             indentChars,
                             propertyDefine.Name,
                             propertyDefine.Description,
                             propertyDefine.DataType,
                             propertyDefine.Category,
                             propertyDefine.SnapshotMode);
        }
示例#3
0
 private static object GetPropertyValue(SchemaObjectBase obj, SchemaPropertyDefine pd)
 {
     try
     {
         object defaultValue = TypeCreator.GetTypeDefaultValue(pd.DataType.ToRealType());
         return(obj.Properties.GetValue(pd.Name, defaultValue));
     }
     catch (System.Exception ex)
     {
         throw new SystemSupportException(string.Format("生成Snapshot或全文检索时,{0}属性值获取错误: {1}", pd.Name, ex.Message),
                                          ex);
     }
 }
示例#4
0
        public SchemaPropertyValueCollection ToProperties()
        {
            SchemaPropertyValueCollection result = new SchemaPropertyValueCollection();

            this.ForEach(p =>
            {
                SchemaPropertyDefine pd = new SchemaPropertyDefine
                {
                    Name         = p.Name,
                    Description  = p.Description,
                    DefaultValue = p.DefaultValue
                };
                result.Add(new SchemaPropertyValue(pd));
            });

            return(result);
        }
示例#5
0
        private static string GetFieldName(ORMappingItemCollection mapping, SchemaPropertyDefine pd)
        {
            string result = pd.SnapshotFieldName;

            if (result.IsNullOrEmpty())
            {
                result = pd.Name;

                ORMappingItem item = mapping.Find(m => m.PropertyName == pd.Name);

                if (item != null)
                {
                    result = item.DataFieldName;
                }
            }

            return(result);
        }
        public static ClientPropertyDefine ToClientPropertyDefine(this SchemaPropertyDefine pcpd)
        {
            pcpd.NullCheck("pcpd");

            return(new ClientPropertyDefine()
            {
                AllowOverride = pcpd.AllowOverride,
                Category = pcpd.Category,
                DataType = (ClientPropertyDataType)pcpd.DataType,
                DefaultValue = pcpd.DefaultValue,
                Description = pcpd.Description,
                DisplayName = pcpd.DisplayName,
                EditorKey = pcpd.EditorKey,
                EditorParams = pcpd.EditorParams,
                IsRequired = pcpd.IsRequired,
                MaxLength = pcpd.MaxLength,
                Name = pcpd.Name,
                PersisterKey = pcpd.PersisterKey,
                ReadOnly = pcpd.ReadOnly,
                SortOrder = pcpd.SortOrder,
                Visible = pcpd.Visible,
            });
        }
        private SchemaPropertyDefine ToProperty(XElement item)
        {
            SchemaPropertyDefine define = new SchemaPropertyDefine();
            XAttribute           attr;
            XElement             elem;

            if ((attr = item.Attribute("name")) != null)
            {
                define.Name = attr.Value;
            }
            if ((attr = item.Attribute("allowOverride")) != null)
            {
                define.AllowOverride = bool.Parse(attr.Value);
            }
            if ((attr = item.Attribute("category")) != null)
            {
                define.Category = attr.Value;
            }
            if ((attr = item.Attribute("dataType")) != null)
            {
                define.DataType = (PropertyDataType)Enum.Parse(typeof(PropertyDataType), attr.Value);
            }
            if ((attr = item.Attribute("defaultValue")) != null)
            {
                define.DefaultValue = attr.Value;
            }
            if ((attr = item.Attribute("description")) != null)
            {
                define.Description = attr.Value;
            }
            if ((attr = item.Attribute("displayName")) != null)
            {
                define.DisplayName = attr.Value;
            }
            if ((attr = item.Attribute("editorKey")) != null)
            {
                define.EditorKey = attr.Value;
            }
            if ((attr = item.Attribute("editorParams")) != null)
            {
                define.EditorParams = attr.Value;
            }
            if ((attr = item.Attribute("editorParamsSettingsKey")) != null)
            {
                define.EditorParamsSettingsKey = attr.Value;
            }
            if ((attr = item.Attribute("isRequired")) != null)
            {
                define.IsRequired = bool.Parse(attr.Value);
            }
            if ((attr = item.Attribute("maxLength")) != null)
            {
                define.MaxLength = int.Parse(attr.Value, CultureInfo.InvariantCulture);
            }
            if ((attr = item.Attribute("persisterKey")) != null)
            {
                define.PersisterKey = attr.Value;
            }
            if ((attr = item.Attribute("readOnly")) != null)
            {
                define.ReadOnly = bool.Parse(attr.Value);
            }
            if ((attr = item.Attribute("showTitle")) != null)
            {
                define.ShowTitle = bool.Parse(attr.Value);
            }
            if ((attr = item.Attribute("tab")) != null)
            {
                define.Tab = attr.Value;
            }
            if ((attr = item.Attribute("visible")) != null)
            {
                define.Visible = bool.Parse(attr.Value);
            }
            else
            {
                define.Visible = true;
            }

            if ((elem = item.Element("validators")) != null)
            {
                ReadValidators(define.Validators, elem);
            }

            return(define);
        }
        private XElement ToElement(SchemaPropertyDefine item)
        {
            XElement xElem = new XElement("property");

            xElem.Add(new XAttribute("name", item.Name));
            xElem.Add(new XAttribute("allowOverride", item.AllowOverride));
            if (string.IsNullOrEmpty(item.Category) == false)
            {
                xElem.Add(new XAttribute("category", item.Category));
            }
            xElem.Add(new XAttribute("dataType", item.DataType));
            if (item.DefaultValue != null)
            {
                xElem.Add(new XAttribute("defaultValue", item.DefaultValue));
            }
            if (string.IsNullOrEmpty(item.Description) == false)
            {
                xElem.Add(new XAttribute("description", item.Description));
            }
            if (string.IsNullOrEmpty(item.DisplayName) == false)
            {
                xElem.Add(new XAttribute("displayName", item.DisplayName));
            }
            if (string.IsNullOrEmpty(item.EditorKey) == false)
            {
                xElem.Add(new XAttribute("editorKey", item.EditorKey));
            }
            if (string.IsNullOrEmpty(item.EditorParams) == false)
            {
                xElem.Add(new XAttribute("editorParams", item.EditorParams));
            }
            if (string.IsNullOrEmpty(item.EditorParamsSettingsKey) == false)
            {
                xElem.Add(new XAttribute("editorParamsSettingsKey", item.EditorParamsSettingsKey));
            }
            xElem.Add(new XAttribute("isRequired", item.IsRequired));
            if (item.MaxLength > 0)
            {
                xElem.Add(new XAttribute("maxLength", item.MaxLength));
            }
            if (string.IsNullOrEmpty(item.PersisterKey) == false)
            {
                xElem.Add(new XAttribute("persisterKey", item.PersisterKey));
            }
            if (item.ReadOnly)
            {
                xElem.Add(new XAttribute("readOnly", "true"));
            }
            xElem.Add(new XAttribute("showTitle", item.ShowTitle));
            if (string.IsNullOrEmpty(item.Tab) == false)
            {
                xElem.Add(new XAttribute("tab", item.Tab));
            }
            if (item.Visible == false)
            {
                xElem.Add(new XAttribute("visible", item.Visible));
            }
            if (item.Validators != null && item.Validators.Count > 0)
            {
                var xValidators = new XElement("validators");
                xElem.Add(xValidators);
                foreach (var v in item.Validators)
                {
                    ValidatorToNode(v, xValidators);
                }
            }

            return(xElem);
        }