private void AppendCsClassHead()
 {
     var classNameSpace = projectInfo.ProjectRuntimeScriptDefines;
     if (string.IsNullOrEmpty(classNameSpace))
     {
         Debug.LogError("项目脚本命名空间为空");
         return;
     }
     Appender.AppendLine($"namespace {projectInfo.ProjectRuntimeScriptDefines}");
     Appender.AppendLeftBracketsAndToRight();
     Appender.AppendCsComment("Excel数据表_" + SheetInfo.ChineseId);
     Appender.AppendLine("[Serializable]");
     switch (exportSetting.serializationType)
     {
         case SerializationType.ProtoBuff:
             {
                 Appender.AppendLine("[ProtoBuf.ProtoContract]");
             }
             break;
         case SerializationType.Json:
             break;
     }
     Appender.AppendLine($"public class {ScriptName}");
     var interfaceName = ExcelUtilty.EntityInterfaceName(projectInfo,SheetInfo);
     Appender.AppendLine($"    : {interfaceName}, IExcelEntity<{ScriptName}>");
     Appender.AppendLeftBracketsAndToRight();
 }
            private void AppendFieldDefine()
            {
                var protobufMemberIndex = 1;
                var propertyIdMap       = SimpleObjInfo.PropertyIdMap;
                var chineseIdMap        = SimpleObjInfo.ChineseIdMap;

                foreach (var sourceId in SimpleObjInfo.SourceIds)
                {
                    var englishId = propertyIdMap.ContainsKey(sourceId)
                        ? propertyIdMap[sourceId]
                        : sourceId;
                    var chineseId = chineseIdMap.ContainsKey(sourceId)
                        ? chineseIdMap[sourceId]
                        : "无中文注释";
                    appender.AppendCsComment(chineseId);

                    ////if (YuSetting.Instance.IsUseProtobuf)
                    ////{
                    ////    appender.AppendLine($"[ProtoBuf.ProtoMember({protobufMemberIndex})]");
                    ////    protobufMemberIndex++;
                    ////}

                    var typeStr = ExcelUtilty.GetFieldTypeStr(SimpleObjInfo.FieldType);
                    appender.AppendLine($"public {typeStr} {englishId};");
                    appender.AppendLine();
                }

                appender.AppendLine();
            }
Example #3
0
        private void ExportExcelDatas(IExcelEntity entity, string excelFilePath)
        {
            var dataRowStrs    = ExcelUtilty.GetSheetStrs(excelFilePath);
            var dataList       = entity.InitEntitys(dataRowStrs);
            var DataBytes      = Injector.Instance.Get <ISerializer>().Serialize(dataList);
            var exportFilePath = ExportDir + "/" + entity.TypeName() + DataFileExtention;

            IOUtility.WriteAllBytes(exportFilePath, DataBytes, true);
        }
Example #4
0
        private void AppendInterfaceHead()
        {
            Appender.AppendLine($"namespace {projectInfo.ProjectRuntimeScriptDefines}");
            Appender.AppendLeftBracketsAndToRight();
            Appender.AppendCsComment("Excel数据表_" + SheetInfo.ChineseId);
            var interfaceName = ExcelUtilty.EntityInterfaceName(projectInfo, SheetInfo);

            Appender.AppendLine("public interface " + interfaceName);
            Appender.AppendLeftBracketsAndToRight();
        }
Example #5
0
        private void ExportExcelDatas(Type excelEntityType, string excelFilePath)
        {
            var dataRowStrs = ExcelUtilty.GetSheetStrs(excelFilePath);

            var initEntitysMethod = excelEntityType.GetMethod("InitEntitys");
            var instance          = Activator.CreateInstance(excelEntityType);

            object[] param    = new object[] { dataRowStrs };
            var      result   = initEntitysMethod?.Invoke(instance, param);
            var      dataList = result.As <List <IExcelEntity> >();

            var DataBytes      = Injector.Instance.Get <ProtobufSerializer>().Serialize(dataList);
            var exportFilePath = ExportDir + "/" + excelEntityType.Name + DataFileExtention;

            IOUtility.WriteAllBytes(exportFilePath, DataBytes, true);
        }
            private void AppendFieldDefine()
            {
                var protobufMemberIndex = 1;

                foreach (var operateInfo in OperateInfo.PropertyDefineInfos)
                {
                    appender.AppendCsComment(operateInfo.ChineseId);
                    var typeStr = ExcelUtilty.GetFieldTypeStr(operateInfo.FieldType);
                    ////if (YuSetting.Instance.IsUseProtobuf)
                    ////{
                    ////    appender.AppendLine($"[ProtoBuf.ProtoMember({protobufMemberIndex})]");
                    ////    protobufMemberIndex++;
                    ////}
                    appender.AppendLine($"public {typeStr} {operateInfo.EnglishId};");
                    appender.AppendLine();
                }

                appender.AppendLine();
            }