예제 #1
0
        public void Load()
        {
            if (!FilesystemUtil.Sys.FileExists(Path))
            {
                Valid = false;
                Sys.Ref.ConsoleSys.Error("Tried to init config at " + Path + " but it is not presented");
                return;
            }

            string Config = FilesystemUtil.Sys.FileRead(Path);

            if (Config == null)
            {
                Valid = false;
                Sys.Ref.ConsoleSys.Error("Tried to init config at " + Path + " but it was empty");
                return;
            }

            Dictionary <string, JObject> Entries;

            try
            {
                Entries = JsonConvert.DeserializeObject <Dictionary <string, JObject> >(Config);
            }
            catch (Exception Exception)
            {
                Valid = false;
                Sys.Ref.ConsoleSys.Error("Failed to load config at " + Path);
                Sys.Ref.ConsoleSys.Error(Exception.Message);
                return;
            }

            AssemblySys AssemblySys = Sys.Ref.Shared.GetNode <AssemblySys>();

            foreach (var Entry in Entries)
            {
                string TypeName = Entry.Value["Type"].ToString();

                Type Type = AssemblySys.GetType(TypeName);

                if (Type == null)
                {
                    Sys.Ref.ConsoleSys.Error(TypeName + " is not a valid type");
                    continue;
                }

                try
                {
                    object Test = JsonConvert.DeserializeObject(Entry.Value["Value"].ToString(Formatting.None), Type);
                    Set(Entry.Key, Test);
                }
                catch (Exception Exception)
                {
                    Sys.Ref.ConsoleSys.Error("Failed at parse of variable " + Entry.Key + " at " + Path);
                    Sys.Ref.ConsoleSys.Error(Exception.Message);
                    continue;
                }
            }
        }
예제 #2
0
        public SubscriberManager()
        {
            AssemblySys = Sys.Ref.Shared.GetNode <AssemblySys>();
            RegistrySys = Sys.Ref.Shared.GetObject <RegistrySys>();

            Subscribers    = new Dictionary <string, Dictionary <IntPtr, Subscriber> >();
            SubscribeOrder = new Dictionary <string, List <IntPtr> >();
        }