Пример #1
0
        public ExportEntry(IMEPackage file, Stream stream)
        {
            FileRef          = file;
            OriginalDataSize = 0;
            HeaderOffset     = (uint)stream.Position;
            switch (file.Game)
            {
            case MEGame.ME1:
            case MEGame.ME2:
            {
                long start = stream.Position;
                stream.Seek(40, SeekOrigin.Current);
                int count = stream.ReadInt32();
                stream.Seek(4 + count * 12, SeekOrigin.Current);
                count = stream.ReadInt32();
                stream.Seek(16, SeekOrigin.Current);
                stream.Seek(4 + count * 4, SeekOrigin.Current);
                long end = stream.Position;
                stream.Seek(start, SeekOrigin.Begin);

                //read header
                _header = stream.ReadToBuffer((int)(end - start));
                break;
            }

            case MEGame.ME3:
            case MEGame.UDK:
            {
                stream.Seek(44, SeekOrigin.Current);
                int count = stream.ReadInt32();
                stream.Seek(-48, SeekOrigin.Current);

                int expInfoSize = 68 + (count * 4);
                _header = stream.ReadToBuffer(expInfoSize);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            OriginalDataSize = DataSize;
            long headerEnd = stream.Position;

            stream.Seek(DataOffset, SeekOrigin.Begin);
            _data = stream.ReadToBuffer(DataSize);
            stream.Seek(headerEnd, SeekOrigin.Begin);
            if (file.Game == MEGame.ME1 && ClassName.Contains("Property") || file.Game != MEGame.ME1 && HasStack)
            {
                ReadsFromConfig = _data.Length > 25 && (_data[25] & 64) != 0;
            }
            else
            {
                ReadsFromConfig = false;
            }
        }
Пример #2
0
        private void CompareWMIClasses()
        {
            Dictionary <string, string> CatagoryPairs = new Dictionary <string, string>
            {
                { "ccm", "CCM" },
                { "cim", "CIM" },
                { "hp", "HP" },
                { "msft", "MSFT" },
                { "office2013", "Office2013" },
                { "sms", "SMS" },
                { "win32", "Win32" },
                { "win32reg", "Win32Reg" }
            };

            foreach (string ClassName in ClassNames)
            {
                int FoundClass = WMIClasses.Where(x => x.Name == ClassName).Count();

                if (FoundClass == 0)
                {
                    string category = string.Empty;
                    if (ClassName.StartsWith("_"))
                    {
                        category = "Internal";
                    }
                    else if (ClassName.Contains("perf"))
                    {
                        category = "Perf";
                    }
                    else
                    {
                        int underscore = ClassName.IndexOf('_');
                        if (underscore > 0)
                        {
                            if (CatagoryPairs.ContainsKey(ClassName.Substring(0, underscore).ToLower()))
                            {
                                category = CatagoryPairs[ClassName.Substring(0, underscore).ToLower()];
                            }
                            else
                            {
                                category = "unknown";
                            }
                        }
                    }
                    WMIClasses.Add(new WMIClass {
                        Name     = ClassName,
                        Catagory = category,
                        Status   = "Unknown"
                    });
                }
            }
        }
Пример #3
0
    private CodeCompileUnit Build()
    {
        CodeCompileUnit unit          = new CodeCompileUnit();
        CodeNamespace   codeNamespace = new CodeNamespace(CodeBuilder.OutNameSpace);

        unit.Namespaces.Add(codeNamespace);
        ClassName   = _jToken[KRoot].ToString();
        ItemName    = _jToken[KItem].ToString();
        IsItem      = ClassName.Contains(ItemName + 's');
        OutFileName = ClassName + ".cs";
        JObject             schema = _jToken[KSchema] as JObject;
        CodeTypeDeclaration codeTypeDeclaration = Build(ClassName, schema, null, null);

        codeNamespace.Types.Add(codeTypeDeclaration);
        return(unit);
    }
Пример #4
0
    public Chengji(string RawData)
    {
        var Items = RawData.Split(",").Select(x => x.Trim(Dataset.QMark)).ToArray();

        Id         = Items[0];
        Number     = Items[1];
        NumberName = Items[2].Trim();   //部分数据带Tab制表符..
        SubId      = Items[3];
        SubName    = Items[4];
        Term       = Items[5];
        Type       = Items[6];
        Sdate      = Utility.FormatTime(Items[7]);
        SdateYear  = Sdate.Split(" ")[0].Split("/")[0];
        SdateMonth = Sdate.Split(" ")[0].Split("/")[1];
        SdateDay   = Sdate.Split(" ")[0].Split("/")[2];
        StudentID  = Items[8];
        var s = Dataset.StudentList.Where(x => x.ID == StudentID);

        if (s.Count() == 1)
        {
            StudentName = s.First().Name;
            ClassID     = s.First().ClassId;
            ClassName   = s.First().ClassName;
            if (ClassName.Contains("高一"))
            {
                if (Term.StartsWith("2016-2017"))
                {
                    Grade = "初二";
                }
                if (Term.StartsWith("2017-2018"))
                {
                    Grade = "初三";
                }
                if (Term.StartsWith("2018-2019"))
                {
                    Grade = "高一";
                }
            }

            if (ClassName.Contains("高二"))
            {
                if (Term.StartsWith("2016-2017"))
                {
                    Grade = "初三";
                }
                if (Term.StartsWith("2017-2018"))
                {
                    Grade = "高一";
                }
                if (Term.StartsWith("2018-2019"))
                {
                    Grade = "高二";
                }
            }

            if (ClassName.Contains("高三"))
            {
                if (Term.StartsWith("2015-2016"))
                {
                    Grade = "初三";
                }
                if (Term.StartsWith("2016-2017"))
                {
                    Grade = "高一";
                }
                if (Term.StartsWith("2017-2018"))
                {
                    Grade = "高二";
                }
                if (Term.StartsWith("2018-2019"))
                {
                    Grade = "高三";
                }
            }
            if (String.IsNullOrEmpty(Grade))
            {
                Console.WriteLine("学号:" + StudentID + " 学期:" + Term);
            }
            //根据班级号,SUBID检索授课教师ID
            var t = Dataset.TeacherList.Where(x => x.SubId == SubId && x.ClassId == ClassID);
            if (t.Count() == 1)
            {
                TeacherID   = t.First().Id;
                TeacherName = t.First().Name;
            }
        }
        Score = float.Parse(Items[9]);
        if (Items[9].Length > 6)
        {
            Score = (float)Math.Round(Score, 2);
        }
        //Term + Type 不是Key,必须用Number
        IdForGradeExam = SubId + ":" + Number + ":" + Grade;
        ZScore         = Items[10];
        TScore         = Items[11];
        Dengdi         = Items[12];
    }
Пример #5
0
        public override string ToString()
        {
            m_Text           = m_ScriptPrescription.template;
            m_Writer         = new StringWriter();
            m_Writer.NewLine = "\n";

            // Make sure all line endings to be Unix (Mac OSX) format.
            m_Text = Regex.Replace(m_Text, @"\r\n?", delegate(Match m) { return("\n"); });

            // Class Name
            m_Text = m_Text.Replace("$ClassName", ClassName);
            m_Text = m_Text.Replace("$SpreadSheetName", SpreadSheetName);
            m_Text = m_Text.Replace("$WorkSheetClassName", WorkSheetClassName);
            m_Text = m_Text.Replace("$DataClassName", DataClassName);
            m_Text = m_Text.Replace("$AssetFileCreateFuncName", AssetFileCreateFuncName);
            m_Text = m_Text.Replace("$EnumDefineName", m_ScriptPrescription.enumDefines);

            m_Text = m_Text.Replace("$AssetPostprocessorClass", AssetPostprocessorClass);
            m_Text = m_Text.Replace("$IMPORT_PATH", ImportedFilePath);
            m_Text = m_Text.Replace("$ASSET_PATH", AssetFilePath);
            if (m_FirstMembers.ContainsKey(DataClassName))
            {
                m_Text = m_Text.Replace("$FirstMemberName", m_FirstMembers[DataClassName]);
            }
            // Other replacements
            foreach (KeyValuePair <string, string> kvp in m_ScriptPrescription.mStringReplacements)
            {
                m_Text = m_Text.Replace(kvp.Key, kvp.Value);
            }

            // Do not change tabs to spcaes of the .txt template files.
            Match match = Regex.Match(m_Text, @"(\t*)\$MemberFields");

            if (match.Success)
            {
                // Set indent level to number of tabs before $Functions keyword
                IndentLevel = match.Groups[1].Value.Length;
                if (m_ScriptPrescription.memberFields != null)
                {
                    for (int i = 0; i < m_ScriptPrescription.memberFields.Length; i++)
                    {
                        var field = m_ScriptPrescription.memberFields[i];
                        if (i == 0)
                        {
                            if (ClassName.Contains("Data") && DataClassName == "Error_Empty_DataClassName")
                            {
                                if (!m_FirstMembers.ContainsKey(ClassName))
                                {
                                    m_FirstMembers.Add(ClassName, field.Name);
                                }
                            }
                        }
                        WriteMemberField(field);
                        WriteProperty(field);
                        WriteBlankLine();
                    }
                    m_Text = m_Text.Replace(match.Value + "\n", m_Writer.ToString());
                }
            }

            // Return the text of the script
            return(m_Text);
        }
Пример #6
0
        /// <summary>
        /// Constructor for reading an export from the package
        /// </summary>
        /// <param name="file"></param>
        /// <param name="stream"></param>
        public ExportEntry(IMEPackage file, EndianReader stream)
        {
            FileRef          = file;
            OriginalDataSize = 0;
            HeaderOffset     = (uint)stream.Position;
            switch (file.Game)
            {
            case MEGame.ME1 when file.Platform == MEPackage.GamePlatform.Xenon:
            {
                long start = stream.Position;
                //Debug.WriteLine($"Export header pos {start:X8}");
                stream.Seek(0x28, SeekOrigin.Current);
                int componentMapCount = stream.ReadInt32();
                //Debug.WriteLine("Component count: " + componentMapCount);
                stream.Seek(4 + componentMapCount * 12, SeekOrigin.Current);
                int generationsNetObjectsCount = stream.ReadInt32();
                //Debug.WriteLine("GenObjs count: " + generationsNetObjectsCount);

                stream.Seek(16, SeekOrigin.Current);         // skip guid size
                stream.Seek(generationsNetObjectsCount * 4, SeekOrigin.Current);
                long end = stream.Position;
                stream.Seek(start, SeekOrigin.Begin);
                var len = (end - start);
                //Debug.WriteLine($"Len: {len:X2}");
                //read header
                _header = stream.ReadBytes((int)len);
                break;
            }

            case MEGame.ME1 when file.Platform == MEPackage.GamePlatform.PC:
            case MEGame.ME2 when file.Platform != MEPackage.GamePlatform.PS3:
            {
                long start = stream.Position;
                stream.Seek(0x28, SeekOrigin.Current);
                int componentMapCount = stream.ReadInt32();
                stream.Seek(4 + componentMapCount * 12, SeekOrigin.Current);
                int generationsNetObjectsCount = stream.ReadInt32();
                stream.Seek(16, SeekOrigin.Current);
                stream.Seek(4 + generationsNetObjectsCount * 4, SeekOrigin.Current);
                long end = stream.Position;
                stream.Seek(start, SeekOrigin.Begin);
                //read header
                _header = stream.ReadBytes((int)(end - start));
                break;
            }

            case MEGame.ME1 when file.Platform == MEPackage.GamePlatform.PS3:
            case MEGame.ME2 when file.Platform == MEPackage.GamePlatform.PS3:
            case MEGame.ME3:
            case MEGame.UDK:
            {
                stream.Seek(44, SeekOrigin.Current);
                int count = stream.ReadInt32();
                stream.Seek(-48, SeekOrigin.Current);

                int expInfoSize = 68 + (count * 4);
                _header = stream.ReadBytes(expInfoSize);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
            OriginalDataSize = DataSize;
            long headerEnd = stream.Position;

            stream.Seek(DataOffset, SeekOrigin.Begin);
            _data = stream.ReadBytes(DataSize);
            stream.Seek(headerEnd, SeekOrigin.Begin);
            if (file.Game == MEGame.ME1 && ClassName.Contains("Property") || file.Game != MEGame.ME1 && HasStack)
            {
                ReadsFromConfig = _data.Length > 25 && (_data[25] & 64) != 0; //this is endian specific!
            }
            else
            {
                ReadsFromConfig = false;
            }
        }