示例#1
0
        public void CheckNewMetaClass()
        {
            var assems = Rtti.RttiHelper.GetAnalyseAssemblys(ECSType.All);

            foreach (var i in assems)
            {
                var types = i.Assembly.GetTypes();
                foreach (var j in types)
                {
                    var attrs = j.GetCustomAttributes(typeof(MetaClassAttribute), true);
                    if (attrs == null || attrs.Length == 0)
                    {
                        continue;
                    }
                    var       cname = RttiHelper.GetTypeSaveString(j);
                    MetaClass klass;
                    if (Klasses.TryGetValue(cname, out klass))
                    {
                        continue;
                    }

                    CreateMetaClass(j);
                }
            }
        }
示例#2
0
        MetaClass CreateMetaClass(System.Type type)
        {
            var cname = RttiHelper.GetTypeSaveString(type);

            var klass = new MetaClass();

            klass.MetaType = type;
            var csIdx    = cname.IndexOf('|');
            var fileName = cname;

            if (csIdx >= 0)
            {
                fileName = cname.Substring(csIdx + 1);
            }
            klass.ClassName = RName.GetRName(MetaDirectory.Name + "/" + fileName);

            MetaData curVer = new MetaData();

            curVer.BuildMetaData(type);

            Hash64 hash = klass.GetFolderHash();
            string dir  = klass.ClassName.GetDirectory() + hash.ToString();

            if (EngineNS.CEngine.Instance.FileManager.DirectoryExists(dir))
            {
                bool hasRedirection = false;
                klass.LoadXnd(out hasRedirection);
#if PWindow
                //if (hasRedirection)
                //    klass.Save2Xnd(false);
#endif
                MetaData data = klass.FindMetaData(curVer.MetaHash);
                if (data == null)
                {
                    klass.RegMetaData(curVer.MetaHash, curVer);
                    var xnd = IO.XndHolder.NewXNDHolder();
                    curVer.Save2Xnd(xnd.Node);
                    IO.XndHolder.SaveXND(dir + "/" + curVer.MetaHash + ".MetaData", xnd);
                }
            }
            else
            {
                CEngine.Instance.FileManager.CreateDirectory(dir);

                var sw = new System.IO.StreamWriter(dir + "/typename.txt", false);
                sw.WriteLine(cname);
                sw.Close();

                klass.RegMetaData(curVer.MetaHash, curVer);
                var xnd = IO.XndHolder.NewXNDHolder();
                curVer.Save2Xnd(xnd.Node);
                IO.XndHolder.SaveXND(dir + "/" + curVer.MetaHash + ".MetaData", xnd);
            }

            klass.CurrentVersion = curVer;
            Klasses.Add(cname, klass);

            return(klass);
        }
 public void StelIn(string naam, double hoogte, int nummer, int matches, int hoogste, Klasses klasse)
 {
     Naam         = naam;
     Lengte       = hoogte;
     Nummer       = nummer;
     Matches      = matches;
     HoogsteScore = hoogste;
     Klasse       = klasse;
 }
 public VolleyBallSpeler(string naam, double lengte, int nummer, int matches = 0, int hoogsteScore = 0, Klasses klasse = Klasses.Vierde)
 {
     Naam         = naam;
     Lengte       = lengte;
     Nummer       = nummer;
     Matches      = matches;
     HoogsteScore = HoogsteScore;
     Klasse       = klasse;
 }
示例#5
0
        // 查找,没有返回null
        public MetaClass FindMetaClass(System.Type type)
        {
            MetaClass result;

            if (Klasses.TryGetValue(Rtti.RttiHelper.GetTypeSaveString(type), out result) == false)
            {
                return(null);
            }
            return(result);
        }
示例#6
0
        public MetaClass FindMetaClass(string typeSaveStr)
        {
            MetaClass result;

            if (Klasses.TryGetValue(typeSaveStr, out result) == false)
            {
                return(null);
            }
            return(result);
        }
示例#7
0
        private void HandleDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                PrinterSettings printer = new PrinterSettings()
                {
                    PrinterName = @"Magicard Rio Pro (V2)"
                };

                if (printer.IsValid)
                {
                    Console.WriteLine("Supported Resolutions:");

                    foreach (PrinterResolution resolution in
                             printer.PrinterResolutions)
                    {
                        Console.WriteLine("  {0}", resolution);
                    }
                    Console.WriteLine();

                    // Display the list of valid paper sizes.
                    Console.WriteLine("Supported Paper Sizes:");

                    foreach (PaperSize size in printer.PaperSizes)
                    {
                        if (Enum.IsDefined(size.Kind.GetType(), size.Kind))
                        {
                            Console.WriteLine("  {0}", size);
                        }
                    }
                    int aktSj = DateTime.Now.Month >= 8 ? DateTime.Now.Year : DateTime.Now.AddYears(-1).Year;
                    klasses = new Klasses(aktSj);
                    //MessageBox.Show(klasses.Count() + " Klassen");
                    schuelers = new Schuelers(aktSj);
                    //MessageBox.Show(schuelers.Count() + " Schüler");
                    for (int i = 0; i < klasses.Count; i++)
                    {
                        if (!(from s in schuelers where s.Klasse == klasses[i].NameAtlantis select s).Any())
                        {
                            klasses.Remove(klasses[i]);
                        }
                    }
                }
                else
                {
                    throw new Exception("Der Drucker ist nicht bereit. \n\nIst der Drucker '" + printer.PrinterName + "' installiert und eingeschaltet? \n\nIst das Netzwerkkabel eingesteckt? \n\nDer Drucker hat die IP 192.168.134.164");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
示例#8
0
        public void RefreshMetaClass(Rtti.VAssembly assm)
        {
            if (assm == null)
            {
                return;
            }
            var types = assm.Assembly.GetTypes();

            foreach (var j in types)
            {
                var attrs = j.GetCustomAttributes(typeof(MetaClassAttribute), true);
                if (attrs == null || attrs.Length == 0)
                {
                    continue;
                }
                var       cname = RttiHelper.GetTypeSaveString(j);
                MetaClass klass;
                if (Klasses.TryGetValue(cname, out klass))
                {
                    bool hasRedirection = false;
                    if (klass.MetaNum == 0)
                    {
                        klass.LoadXnd(out hasRedirection);
                    }
                    if (!hasRedirection)
                    {
                        MetaData curVer = new MetaData();
                        curVer.BuildMetaData(j);

                        MetaData data = klass.FindMetaData(curVer.MetaHash);
                        if (data == null)
                        {
                            klass.RegMetaData(curVer.MetaHash, curVer);
#if PWindow
                            var xnd = IO.XndHolder.NewXNDHolder();
                            curVer.Save2Xnd(xnd.Node);
                            var hash = klass.GetFolderHash();
                            var file = klass.ClassName.GetRootFolder() + "MetaClasses/" + hash.ToString() + "/" + curVer.MetaHash + ".MetaData";
                            IO.XndHolder.SaveXND(file, xnd);
                            klass.CurrentVersion = curVer;
#endif
                        }
                        else
                        {
                            klass.CurrentVersion = data;
                        }
                    }
                }
                else
                {
                    CreateMetaClass(j);
                }
            }
        }
示例#9
0
        // 查找,没有则创建
        public MetaClass GetMetaClass(System.Type type)
        {
            var       className = Rtti.RttiHelper.GetTypeSaveString(type);
            MetaClass result;

            if (Klasses.TryGetValue(className, out result))
            {
                return(result);
            }

            result = CreateMetaClass(type);
            return(result);
        }
示例#10
0
        private void New()
        {
            string           messageBoxText = "Existing diagram will be overwritten";
            string           caption        = "New Diagram";
            MessageBoxButton button         = MessageBoxButton.OKCancel;
            MessageBoxImage  icon           = MessageBoxImage.Warning;

            MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon);

            if (result == MessageBoxResult.OK)
            {
                Klasses.Clear();
                Relations.Clear();
            }
        }
示例#11
0
        private void Copy(Avdeling copyFrom, TimeplanEntities db)
        {
            Navn = copyFrom.Navn;
            fk_AvdelingslederAnsattId = copyFrom.AvdelingsLeder.Id;

            Klasses.Clear();
            foreach (var klasse in copyFrom.Klasses)
            {
                Klasses.Add(Klasse.GetById(klasse.Id, db));
            }

            Ansatts.Clear();
            foreach (var ansatt in copyFrom.Ansatts)
            {
                Ansatts.Add(Ansatt.GetById(ansatt.Id, db));
            }
        }
示例#12
0
        private void Load()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title            = "Open Diagram";
            dialog.Filter           = "Diagram files (*.dia)|*.dia";
            dialog.RestoreDirectory = true;

            if ((bool)dialog.ShowDialog())
            {
                // Load data from file
                IFormatter formatter = new BinaryFormatter();
                FileStream s         = new FileStream(dialog.FileName, FileMode.Open);

                try
                {
                    ObservableCollection <Klass> t = (ObservableCollection <Klass>)formatter.Deserialize(s);
                    // Clear existing Klasses and Relations
                    Klasses.Clear();
                    Relations.Clear();

                    // Add loaded data
                    foreach (Klass k in t)
                    {
                        // Add Klass
                        Klasses.Add(k);

                        // Add Relations
                        foreach (Relation r in k.Relations)
                        {
                            if (!Relations.Contains(r))
                            {
                                Relations.Add(r);
                            }
                        }
                    }

                    _filepath = dialog.FileName;
                }
                catch (Exception)
                {
                    MessageBox.Show("Please choose a valid Diagram file.");
                }
            }
        }
示例#13
0
        public void Update(string navn, int avdelingsLederId, IList <int> ansatteIds, IList <int> klasserIds)
        {
            if (Navn != navn)
            {
                Navn      = navn;
                IsChanged = true;
            }

            if (AvdelingsLeder == null || AvdelingsLeder.Id != avdelingsLederId)
            {
                AvdelingsLeder = Ansatt.GetById(avdelingsLederId);
                IsChanged      = true;
            }

            var klasserIdsOld = Klasses.OrderBy(klasse => klasse.Id).Select(klasse => klasse.Id).ToList();

            if (klasserIdsOld.Count != klasserIds.Count ||
                klasserIdsOld.SequenceEqual(klasserIds.OrderBy(i => i)) == false)
            {
                Klasses.Clear();
                foreach (var klasseId in klasserIds)
                {
                    Klasses.Add(Klasse.GetById(klasseId));
                }
                IsChanged = true;
            }

            var ansattIdsOld = Ansatts.OrderBy(ansatt => ansatt.Id).Select(ansatt => ansatt.Id).ToList();

            if (ansattIdsOld.Count != ansatteIds.Count ||
                ansattIdsOld.SequenceEqual(ansatteIds.OrderBy(i => i)) == false)
            {
                Ansatts.Clear();
                foreach (var ansattId in ansatteIds)
                {
                    Ansatts.Add(Ansatt.GetById(ansattId));
                }
                IsChanged = true;
            }
        }
示例#14
0
        public void LoadMetaClasses()
        {
            var t1   = Support.Time.HighPrecision_GetTickCount();
            var dirs = CEngine.Instance.FileManager.GetDirectories(MetaDirectory.Address);

            if (dirs == null)
            {
                Profiler.Log.WriteLine(Profiler.ELogTag.Error, "MetaData", $"MetaDirectory.Address is null:{MetaDirectory.Address}");
                return;
            }
            foreach (var i in dirs)
            {
                if (false == CEngine.Instance.FileManager.FileExists(i + "/typename.txt"))
                {
                    continue;
                }

                //System.IO.StreamReader sr = new System.IO.StreamReader(i + "/typename.txt", System.Text.Encoding.ASCII);
                //string className = sr.ReadLine();
                //sr.Close();

                byte[] bytes     = IO.FileManager.ReadFile(i + "/typename.txt");
                string className = System.Text.Encoding.ASCII.GetString(bytes);
                className = className.Replace("\r\n", "");

                ///////////////////////////////////////////////////////////////////
                //if (className.Contains("enginecore"))
                //{
                //    using (var sw = new System.IO.StreamWriter(i + "/typename.txt", false, System.Text.Encoding.ASCII))
                //    {
                //        className = className.Replace("enginecore", "EngineCore");
                //        sw.WriteLine(className);
                //    }
                //}
                //if (className.Contains("Common|EngineCore"))
                //{
                //    using (var sw = new System.IO.StreamWriter(i + "/typename.txt", false, System.Text.Encoding.ASCII))
                //    {
                //        className = className.Replace("Common|EngineCore", "Client|EngineCore");
                //        sw.WriteLine(className);
                //    }
                //}
                ///////////////////////////////////////////////////////////////////
                bool isRedirection;
                var  type = RttiHelper.GetTypeFromSaveString(className, out isRedirection);
                if (type == null)
                {
                    continue;
                }

                if (CIPlatform.Instance.PlayMode != CIPlatform.enPlayMode.Game)
                {
                    var noUsedFile = i + "/" + type.FullName + ".noused";
                    if (CEngine.Instance.FileManager.FileExists(noUsedFile) == false)
                    {
                        CEngine.Instance.FileManager.CreateFile(noUsedFile);
                    }
                }

                MetaClass klass = new MetaClass();
                klass.MetaType = type;
                var csIdx   = className.IndexOf('|');
                var fileStr = className;
                if (csIdx >= 0)
                {
                    fileStr = className.Substring(csIdx + 1);
                }
                klass.ClassName = RName.GetRName(MetaDirectory.Name + "/" + fileStr);
                bool hasRedirection = false;
                klass.LoadXnd(out hasRedirection);
#if PWindow
                //if (hasRedirection)
                //    klass.Save2Xnd(false);
#endif

                // 重定向后由于原来的类型已不存在,不再进行当前版本的处理
                if (!isRedirection)
                {
                    MetaData curVer = new MetaData();
                    curVer.BuildMetaData(type);

                    MetaData data = klass.FindMetaData(curVer.MetaHash);
                    if (data == null)
                    {
                        klass.RegMetaData(curVer.MetaHash, curVer);

#if PWindow
                        var xnd = IO.XndHolder.NewXNDHolder();
                        curVer.Save2Xnd(xnd.Node);
                        var hash = klass.GetFolderHash();
                        var file = klass.ClassName.GetRootFolder() + "MetaClasses/" + hash.ToString() + "/" + curVer.MetaHash + ".MetaData";
                        IO.XndHolder.SaveXND(file, xnd);
                        klass.CurrentVersion = curVer;
#endif
                    }
                    else
                    {
                        klass.CurrentVersion = data;
                    }
                }

                Klasses.Add(className, klass);
            }

            var t2 = Support.Time.HighPrecision_GetTickCount();
            Profiler.Log.WriteLine(Profiler.ELogTag.Info, "MetaData", $"LoadMetaClasses Time:{t2-t1}");
            //MetaDatas.Clear();
            //foreach (var i in Klasses)
            //{
            //    foreach (var j in i.Value.Metas)
            //    {
            //        MetaDatas.Add(j.Key, j.Value);
            //    }
            //}
        }