Exemplo n.º 1
0
        private void SetDataContent(ConstructItem item)
        {
            if (item == null)
            {
                return;
            }

            ConstructItemInfoPanel infoPanel = new ConstructItemInfoPanel();

            infoPanel.DataContext = item;
            ContentTransition.ChangeContent(infoPanel, PathContentTranstitionType.NO_ANIM);
            //ItemAttrPanel.Visibility = System.Windows.Visibility.Visible;
            //ItemAttrPanel.DataContext = item;

            //if (item.ItemReadOnly)
            //{
            //    this.Name.IsEnabled = false;
            //    this.ItemCode.IsEnabled = false;
            //    this.ItemDefault.IsEnabled = false;
            //    this.ItemRepeat.IsEnabled = false;
            //}
            //else
            {
                //this.Name.IsEnabled = true;
                //this.ItemCode.IsEnabled = true;
                //this.ItemDefault.IsEnabled = true;
                //this.ItemRepeat.IsEnabled = true;
            }
        }
Exemplo n.º 2
0
        private static bool IsStringValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            return isValid;
        }
Exemplo n.º 3
0
        private static bool IsBaseTypeValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            switch (constructItem.ItemType2[0].Name)
            {
                case ConstructConfig.ITEM_TYPE_BASE_STRING:
                    isValid = IsStringValid(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.ITEM_TYPE_BASE_INT:
                    isValid = IsIntValid(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.ITEM_TYPE_BASE_FLOAT:
                    isValid = IsFloatValid(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.ITEM_TYPE_BASE_BOOL:
                    isValid = IsBoolValid(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.ITEM_TYPE_BASE_VECTOR3:
                    isValid = IsVector3Valid(constructItem, value, out errorMsg);
                    break;
            }

            return isValid;
        }
Exemplo n.º 4
0
        public ContentItem(ContentRow row, ConstructItem construct, int constructIdx)
        {
            _ItemConstruct = construct;
            _ContructRepeatIndex = constructIdx;

            ContentRow = row;
        }
Exemplo n.º 5
0
        public ConstructItem CreateNewItem(string name)
        {
            ConstructItem item = new ConstructItem(name);
            item.ItemType2.AddNewItem(new TableBaseItem());
            ConstructItems.AddNewItem(item);

            return item;
        }
Exemplo n.º 6
0
        private void Button_New(object sender, RoutedEventArgs e)
        {
            if (_ConstructFile != null)
            {
                ConstructItem item = _ConstructFile.CreateNewItem();

                SetDataContent(item);
            }
        }
Exemplo n.º 7
0
        public static ConstructItem ReadColumn(XmlElement columnEle)
        {
            ConstructItem item = new ConstructItem("");

            foreach (XmlElement childElement in columnEle.ChildNodes.OfType <XmlElement>())
            {
                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_NAME)
                {
                    item.Name = childElement.InnerText;

                    if (item.Name == ConstructConfig.NEW_FILE_DEFAULT_ID_NAME ||
                        item.Name == ConstructConfig.NEW_FILE_DEFAULT_NAME_NAME ||
                        item.Name == ConstructConfig.NEW_FILE_DEFAULT_DESC_NAME)
                    {
                        item.ItemReadOnly = true;
                    }
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_CODE)
                {
                    item.ItemCode = childElement.InnerText;
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_TYPE1)
                {
                    item.ItemType1 = childElement.InnerText;
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_TYPE2)
                {
                    foreach (XmlElement type2Ele in childElement.ChildNodes.OfType <XmlElement>())
                    {
                        item.ItemType2.AddNewItem(new TableBaseItem()
                        {
                            Name = type2Ele.InnerText
                        });
                    }
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_DEFAULT)
                {
                    item.ItemDefault = childElement.InnerText;
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_REPEAT)
                {
                    item.ItemRepeat = int.Parse(childElement.InnerText);
                }
            }

            if (string.IsNullOrEmpty(item.Name))
            {
                return(null);
            }

            return(item);
        }
Exemplo n.º 8
0
        private void StackPanel_DataContextChanged_1(object sender, DependencyPropertyChangedEventArgs e)
        {
            ConstructItem constructItem = e.NewValue as ConstructItem;

            if (constructItem == null)
            {
                return;
            }
        }
Exemplo n.º 9
0
        public ConstructItem CreateNewItem(string name)
        {
            ConstructItem item = new ConstructItem(name);

            item.ItemType2.AddNewItem(new TableBaseItem());
            ConstructItems.AddNewItem(item);

            return(item);
        }
Exemplo n.º 10
0
        private void MenuItem_Remove(object sender, RoutedEventArgs e)
        {
            ConstructItem itemInfo = LinkList.SelectedItem as ConstructItem;

            if (itemInfo == null)
            {
                return;
            }

            _ConstructFile.ConstructItems.RemoveByName(itemInfo.Name);
        }
Exemplo n.º 11
0
        private void Button_DecRelate(object sender, RoutedEventArgs e)
        {
            ConstructItem constructItem = this.DataContext as ConstructItem;

            if (constructItem == null)
            {
                return;
            }

            constructItem.ItemType2.Remove(constructItem.ItemType2.Last <TableBaseItem>());
        }
Exemplo n.º 12
0
        private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            ConstructItem constructItem = this.DataContext as ConstructItem;

            if (constructItem == null)
            {
                return;
            }

            constructItem.SetDefaultByType(e.AddedItems[0].ToString());
        }
Exemplo n.º 13
0
        public void ConItem_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //ItemAttrPanel.Visibility = System.Windows.Visibility.Visible;

            if (e.AddedItems.Count > 0)
            {
                _CurItem = e.AddedItems[0] as ConstructItem;
                SetDataContent(e.AddedItems[0] as ConstructItem);
            }

            //InitItemType1();
        }
        public void ConItem_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //ItemAttrPanel.Visibility = System.Windows.Visibility.Visible;

            if (e.AddedItems.Count > 0)
            {
                _CurItem = e.AddedItems[0] as ConstructItem;
                SetDataContent(e.AddedItems[0] as ConstructItem);
            }

            //InitItemType1();
        }
Exemplo n.º 15
0
        private void Button_AddRelate(object sender, RoutedEventArgs e)
        {
            ConstructItem constructItem = this.DataContext as ConstructItem;

            if (constructItem == null)
            {
                return;
            }

            constructItem.ItemType2.AddNewItem(new TableBaseItem());
            constructItem.WriteFlag = true;
        }
Exemplo n.º 16
0
        private static bool IsIntValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            int valueInt;
            if (!Int32.TryParse((string)value, out valueInt))
            {
                isValid = false;
                errorMsg = "不是32位整数";
            }

            return isValid;
        }
Exemplo n.º 17
0
        public static void ReadFile(FileInfo fileInfo)
        {
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(fileInfo.FullName);

                string        fileName = fileInfo.Name.Remove(fileInfo.Name.LastIndexOf("."));
                ConstructFile file     = new ConstructFile(fileName, false);
                ConstructFold.Instance.AddFile(file);

                file.Path = fileInfo.FullName.Replace(_ConstructPath, "").Replace(fileInfo.Name, "");

                XmlNode root = xmlDoc.SelectSingleNode(ConstructConfig.DOC_ROOT_STR);
                foreach (XmlElement childElement in root.ChildNodes.OfType <XmlElement>())
                {
                    if (childElement.Name == ConstructConfig.CONSTRUCT_TABLE_CLASS)
                    {
                        file.Class = childElement.InnerText;
                    }
                    else if (childElement.Name == ConstructConfig.CONSTRUCT_TABLE_DESC)
                    {
                        file.Desc = childElement.InnerText;
                    }
                    else if (childElement.Name == ConstructConfig.CONSTRUCT_TABLE_OLD_NAME)
                    {
                        file.OldName = childElement.InnerText;
                    }
                    else if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_COLUMN)
                    {
                        ConstructItem item = ReadColumn(childElement);
                        if (item != null)
                        {
                            file.ConstructItems.AddNewItem(item);

                            //重置写标记
                            item.WriteFlag = false;
                        }
                    }
                }

                //重置写标记
                file.ConstructItems.WriteFlag = false;
                file.WriteFlag = false;
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 18
0
        private void MenuItem_Rename(object sender, RoutedEventArgs e)
        {
            ConstructItem itemInfo = LinkList.SelectedItem as ConstructItem;

            if (itemInfo == null)
            {
                return;
            }

            string newName = DialogMessage.DialogString();

            if (!string.IsNullOrEmpty(newName))
            {
                itemInfo.Name = newName;
            }
        }
Exemplo n.º 19
0
        public static ConstructItem ReadColumn(XmlElement columnEle)
        {
            ConstructItem item = new ConstructItem("");
            foreach (XmlElement childElement in columnEle.ChildNodes.OfType<XmlElement>())
            {
                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_NAME)
                {
                    item.Name = childElement.InnerText;

                    if (item.Name == ConstructConfig.NEW_FILE_DEFAULT_ID_NAME
                        || item.Name == ConstructConfig.NEW_FILE_DEFAULT_NAME_NAME
                        || item.Name == ConstructConfig.NEW_FILE_DEFAULT_DESC_NAME)
                    {
                        item.ItemReadOnly = true;
                    }
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_CODE)
                    item.ItemCode = childElement.InnerText;

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_TYPE1)
                    item.ItemType1 = childElement.InnerText;

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_TYPE2)
                {
                    foreach (XmlElement type2Ele in childElement.ChildNodes.OfType<XmlElement>())
                    {
                        item.ItemType2.AddNewItem(new TableBaseItem() { Name = type2Ele.InnerText });
                    }
                }

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_DEFAULT)
                    item.ItemDefault = childElement.InnerText;

                if (childElement.Name == ConstructConfig.CONSTRUCT_ELEMENT_REPEAT)
                    item.ItemRepeat = int.Parse(childElement.InnerText);
            }

            if (string.IsNullOrEmpty(item.Name))
                return null;

            return item;
        }
Exemplo n.º 20
0
        private void MenuItem_New(object sender, RoutedEventArgs e)
        {
            ConstructItem itemInfo = LinkList.SelectedItem as ConstructItem;

            if (itemInfo == null)
            {
                return;
            }

            int pos = _ConstructFile.ConstructItems.IndexOf(itemInfo);

            if (_ConstructFile != null)
            {
                ConstructItem item = _ConstructFile.CreateNewItem();
                SetDataContent(item);

                _ConstructFile.ConstructItems.MovePosToPos(_ConstructFile.ConstructItems.IndexOf(item), pos);
            }
        }
Exemplo n.º 21
0
        public static bool IsValueValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";
            switch (constructItem.ItemType1)
            {
                case ConstructConfig.CONSTRUCT_ITEM_TYPE_BASE:
                    isValid = IsBaseTypeValid(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.CONSTRUCT_ITEM_TYPE_ENUM:
                    isValid = IsValueEnum(constructItem, value, out errorMsg);
                    break;
                case ConstructConfig.CONSTRUCT_ITEM_TYPE_TABLE_ID:
                    isValid = IsValueTableIdx(constructItem, value, out errorMsg);
                    break;
            }

            return isValid;
        }
Exemplo n.º 22
0
        private static bool IsBoolValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            bool valueType;
            if (!bool.TryParse((string)value, out valueType))
            {
                isValid = false;
                errorMsg = "不是布尔型";
            }

            return isValid;
        }
Exemplo n.º 23
0
        private static bool IsVector3Valid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            var valueList = ContentItem.GetSplitValue((string)value);
            if (valueList.Count != 3)
            {
                isValid = false;
                errorMsg = "类型错误";
            }

            foreach (var valueSingle in valueList)
            {
                isValid = IsFloatValid(constructItem, valueSingle, out errorMsg);
                if (!isValid)
                    break;
            }

            return isValid;
        }
Exemplo n.º 24
0
        private string CSTableItemTypeCode(ConstructItem constructItem)
        {
            string typeCode = "";
            if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_BASE)
            {
                switch (constructItem.ItemType2[0].Name)
                {
                    case ConstructConfig.ITEM_TYPE_BASE_INT:
                        typeCode = "int";
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_FLOAT:
                        typeCode = "float";
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_STRING:
                        typeCode = "string";
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_BOOL:
                        typeCode = "bool";
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_VECTOR3:
                        typeCode = "Vector3";
                        break;
                }
            }
            else if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_ENUM)
            {
                typeCode = constructItem.ItemType2[0].Name;
            }
            else if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_TABLE_ID)
            {
                if (constructItem.ItemType2.Count == 1)
                {
                    typeCode = constructItem.ItemType2[0].Name + "Record";
                }
                else
                {
                    typeCode = "MultiTable";
                }
            }

            if (constructItem.ItemRepeat > 1)
            {
                typeCode = "List<" + typeCode + ">";
            }

            return typeCode;
        }
        private void SetDataContent(ConstructItem item)
        {
            if (item == null)
                return;

            ConstructItemInfoPanel infoPanel = new ConstructItemInfoPanel();
            infoPanel.DataContext = item;
            ContentTransition.ChangeContent(infoPanel, PathContentTranstitionType.NO_ANIM);
            //ItemAttrPanel.Visibility = System.Windows.Visibility.Visible;
            //ItemAttrPanel.DataContext = item;

            //if (item.ItemReadOnly)
            //{
            //    this.Name.IsEnabled = false;
            //    this.ItemCode.IsEnabled = false;
            //    this.ItemDefault.IsEnabled = false;
            //    this.ItemRepeat.IsEnabled = false;
            //}
            //else
            {
                //this.Name.IsEnabled = true;
                //this.ItemCode.IsEnabled = true;
                //this.ItemDefault.IsEnabled = true;
                //this.ItemRepeat.IsEnabled = true;
            }
        }
Exemplo n.º 26
0
        public static bool IsValueTableIdx(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            string valueType = (string)value;
            if (string.IsNullOrEmpty(valueType))
            {//空值直接返回
                return true;
            }

            if (constructItem.ItemType2.Count == 1)
            {
                isValid = IsValueTableSingle(constructItem, value, out errorMsg);
            }
            else
            {
                isValid = IsValueTableMulti(constructItem, value, out errorMsg);
            }

            return isValid;
        }
Exemplo n.º 27
0
        public ConstructFile(string name, bool createDefaultColumn = true)
        {
            Name = name;

            //新建表,自动添加ID,名称,描述项
            if (createDefaultColumn)
            {
                ConstructItem idItem = CreateNewItem(ConstructConfig.NEW_FILE_DEFAULT_ID_NAME);
                idItem.ItemCode  = ConstructConfig.NEW_FILE_DEFAULT_ID_CODE;
                idItem.ItemType1 = ConstructConfig.NEW_FILE_DEFAULT_ID_TYPE1;
                if (idItem.ItemType2.Count != 0)
                {
                    idItem.ItemType2[0] = new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_ID_TYPE2
                    };
                }
                else
                {
                    idItem.ItemType2.AddNewItem(new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_ID_TYPE2
                    });
                }
                idItem.ItemDefault  = ConstructConfig.NEW_FILE_DEFAULT_ID_DEFAULT;
                idItem.ItemRepeat   = ConstructConfig.NEW_FILE_DEFAULT_ID_REPEAT;
                idItem.ItemReadOnly = true;

                ConstructItem nameItem = CreateNewItem(ConstructConfig.NEW_FILE_DEFAULT_NAME_NAME);
                nameItem.ItemCode  = ConstructConfig.NEW_FILE_DEFAULT_NAME_CODE;
                nameItem.ItemType1 = ConstructConfig.NEW_FILE_DEFAULT_NAME_TYPE1;
                if (nameItem.ItemType2.Count != 0)
                {
                    nameItem.ItemType2[0] = new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_NAME_TYPE2
                    };
                }
                else
                {
                    nameItem.ItemType2.AddNewItem(new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_NAME_TYPE2
                    });
                }
                nameItem.ItemDefault  = ConstructConfig.NEW_FILE_DEFAULT_NAME_DEFAULT;
                nameItem.ItemRepeat   = ConstructConfig.NEW_FILE_DEFAULT_NAME_REPEAT;
                nameItem.ItemReadOnly = true;

                ConstructItem descItem = CreateNewItem(ConstructConfig.NEW_FILE_DEFAULT_DESC_NAME);
                descItem.ItemCode  = ConstructConfig.NEW_FILE_DEFAULT_DESC_CODE;
                descItem.ItemType1 = ConstructConfig.NEW_FILE_DEFAULT_DESC_TYPE1;
                if (descItem.ItemType2.Count != 0)
                {
                    descItem.ItemType2[0] = new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_DESC_TYPE2
                    };
                }
                else
                {
                    descItem.ItemType2.AddNewItem(new TableBaseItem()
                    {
                        Name = ConstructConfig.NEW_FILE_DEFAULT_DESC_TYPE2
                    });
                }
                descItem.ItemDefault  = ConstructConfig.NEW_FILE_DEFAULT_DESC_DEFAULT;
                descItem.ItemRepeat   = ConstructConfig.NEW_FILE_DEFAULT_DESC_REPEAT;
                descItem.ItemReadOnly = true;
            }
        }
Exemplo n.º 28
0
        public static void ReadItem(ConstructItem constructItem, DataRecord data, ref ContentRow row)
        {
            for (int i = 0; i < constructItem.ItemRepeat; ++i)
            {
                ContentItem contentItem = new ContentItem(row, constructItem, i + 1);
                string columnName = constructItem.Name;
                if (constructItem.ItemRepeat > 1)
                {
                    columnName = (constructItem.Name + (i + 1).ToString());
                }
                columnName = "\"" + columnName + "\"";
                if (data.HeaderRecord.Contains(columnName))
                {
                    contentItem.Value = data[columnName];
                }
                else
                {
                    contentItem.Value = "";
                }

                row.AddContentItem(contentItem);
            }
        }
Exemplo n.º 29
0
        public static bool IsValueTableSingle(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            ContentFile contentFile = TableContentManager.Instance.GetFileByName(constructItem.ItemType2[0].Name);
            if (contentFile == null)
            {
                errorMsg = "表格无效";
                return false;
            }

            string valueType = (string)value;
            ContentRow contentRow = contentFile.ContentRow.GetRowByID(valueType);
            if (contentRow == null)
            {
                errorMsg = "表格ID无效";
                return false;
            }

            return isValid;
        }
Exemplo n.º 30
0
        private void CSCreateTableItem(ConstructItem constructItem, ref StringBuilder builder)
        {
 
        }
Exemplo n.º 31
0
 public static bool IsValueValid(ConstructItem constructItem, object value)
 {
     string errorMsg = "";
     return IsValueValid(constructItem, value, out errorMsg);
 }
Exemplo n.º 32
0
        private StringBuilder CSTableItemParseCode(ConstructItem constructItem, int dataIdx, int repeatIdx)
        {
            var parseBuilder = new StringBuilder();
            string parseValueStart = " = ";
            string parseValueEnd = "";
            if (repeatIdx > -1)
            {
                parseValueStart = ".Add(";
                parseValueEnd = ")";
            }
            
            
            if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_BASE)
            {
                switch (constructItem.ItemType2[0].Name)
                {
                    case ConstructConfig.ITEM_TYPE_BASE_INT:
                        parseBuilder.Append("                pair.Value." 
                            + constructItem.ItemCode + parseValueStart + "TableReadBase.ParseInt(pair.Value.ValueStr[" 
                            + dataIdx + "])" + parseValueEnd  + ";");
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_FLOAT:
                        parseBuilder.Append("                pair.Value."
                            + constructItem.ItemCode + parseValueStart + "TableReadBase.ParseFloat(pair.Value.ValueStr["
                            + dataIdx + "])" + parseValueEnd + ";");
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_STRING:
                        parseBuilder.Append("                pair.Value."
                            + constructItem.ItemCode + parseValueStart + "TableReadBase.ParseString(pair.Value.ValueStr["
                            + dataIdx + "])" + parseValueEnd + ";");
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_BOOL:
                        parseBuilder.Append("                pair.Value."
                            + constructItem.ItemCode + parseValueStart + "TableReadBase.ParseBool(pair.Value.ValueStr["
                            + dataIdx + "])" + parseValueEnd + ";");
                        break;
                    case ConstructConfig.ITEM_TYPE_BASE_VECTOR3:
                        parseBuilder.Append("                pair.Value."
                            + constructItem.ItemCode + parseValueStart + "TableReadBase.ParseVector3(pair.Value.ValueStr["
                            + dataIdx + "])" + parseValueEnd + ";");
                        break;
                }
            }
            else if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_ENUM)
            {
                parseBuilder.Append("                pair.Value." + constructItem.ItemCode
                    + parseValueStart + " (" + constructItem.ItemType2[0].Name + ")TableReadBase.ParseInt(pair.Value.ValueStr["
                    + dataIdx + "])" + parseValueEnd + ";");
            }
            else if (constructItem.ItemType1 == ConstructConfig.CONSTRUCT_ITEM_TYPE_TABLE_ID)
            {
                if (constructItem.ItemType2.Count == 1)
                {
                    parseBuilder.Append("                if (!string.IsNullOrEmpty(pair.Value.ValueStr[" + dataIdx + "]))\n");
                    parseBuilder.Append("                {\n");
                    //parseBuilder.Append("                    pair.Value.Step.Add(TableReader." + constructItem.ItemType2[0].Name + ".GetRecord(pair.Value.ValueStr[" + dataIdx + "]));\n");
                    parseBuilder.Append("                    pair.Value." + constructItem.ItemCode
                        + parseValueStart + " TableReader." + constructItem.ItemType2[0].Name + ".GetRecord(pair.Value.ValueStr["
                        + dataIdx + "])" + parseValueEnd + ";");
                    parseBuilder.Append("                }\n");
                    parseBuilder.Append("                else\n");
                    parseBuilder.Append("                {\n");
                    parseBuilder.Append("                    pair.Value." + constructItem.ItemCode
                        + parseValueStart + "null" + parseValueEnd + ";\n");
                    parseBuilder.Append("                }");
                }
                else
                {
                    parseBuilder.Append("                pair.Value." + constructItem.ItemCode
                        + parseValueStart + " TableReadBase.ParseMultiTable(pair.Value.ValueStr["
                        + dataIdx + "])" + parseValueEnd + ";");
                }
            }

            if (constructItem.ItemRepeat > 1)
            {
                //parseBuilder.Append("List<" + parseCode + ">");
            }
            parseBuilder.Append("\n");
            //parseBuilder.Append(parseCode);
            return parseBuilder;
        }
Exemplo n.º 33
0
        private static bool IsFloatValid(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            float valueType;
            if (!float.TryParse((string)value, out valueType))
            {
                isValid = false;
                errorMsg = "不是32位浮点数数";
            }

            return isValid;
        }
Exemplo n.º 34
0
        public static bool IsValueEnum(ConstructItem constructItem, object value, out string errorMsg)
        {
            bool isValid = true;
            errorMsg = "";

            string valueType = (string)value;
            if (string.IsNullOrEmpty(valueType))
            {//空值直接返回
                return true;
            }

            EnumInfo enumInfo = EnumManager.Instance.GetEnum(constructItem.ItemType2[0].Name);
            if (enumInfo == null)
            {
                errorMsg = "枚举无效";
                return false;
            }

            EnumItem enumItem = enumInfo.GetEnumItemByValue(valueType);
            if (enumItem == null)
            {
                errorMsg = "枚举值无效";
                return false;
            }

            return isValid;
        }
Exemplo n.º 35
0
        public static bool IsValueTableMulti(ConstructItem constructItem, object value, out string errorMsg)
        {
            errorMsg = "";

            var valueList = ContentItem.GetSplitValue((string)value);
            if (valueList.Count != 2)
            {
                errorMsg = "格式无效";
                return false;
            }

            if (string.IsNullOrEmpty(valueList[0]) || string.IsNullOrEmpty(valueList[1]))
            {
                errorMsg = "";
                return true;
            }

            if (constructItem.ItemType2.GetByName(valueList[0]) == null)
            {
                errorMsg = "不支持该表";
                return false;
            }

            ContentFile contentFile = TableContentManager.Instance.GetFileByName(valueList[0]);
            if (contentFile == null)
            {
                errorMsg = "表格无效";
                return false;
            }

            ContentRow contentRow = contentFile.ContentRow.GetRowByID(valueList[1]);
            if (contentRow == null)
            {
                errorMsg = "表格ID无效";
                return false;
            }

            return true;
        }