예제 #1
0
        public Configuration()
        {
            // check if local read-only configuration file exists
            var localPath = ApplicationInfo.CurrentDirectory + sar.Tools.AssemblyInfo.Name + ".xml";
            var standardPath = ApplicationInfo.CommonDataDirectory + sar.Tools.AssemblyInfo.Name + ".xml";

            if (File.Exists(localPath))
            {
                this.path = localPath;
                readOnly = true;
            }
            else
            {
                this.path = standardPath;
                readOnly = false;
            }

            // read the file
            if (File.Exists(this.path))
            {
                var reader = new XML.Reader(this.path);
                this.Deserialize(reader);
                reader.Close();
            }
        }
예제 #2
0
        public Configuration(string path)
        {
            this.path = path;
            this.readOnly = true;

            if (File.Exists(this.path))
            {
                var reader = new XML.Reader(this.path);

                try
                {
                    this.Deserialize(reader);
                }
                catch
                {

                }

                reader.Close();
            }
        }
예제 #3
0
        private void ProcessIncomingBuffer(ref string bufferIn)
        {
            string packetIn = ExtractPacket(ref bufferIn);
            if (String.IsNullOrEmpty(packetIn)) return;

            using (var sr = new StringReader(packetIn))
            {
                using (var reader = new XML.Reader(sr))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                                case "SocketMessage":
                                    this.packetsIn++;
                                    var message = new SocketMessage(reader);

                                    if (!this.ProcessMessage(message) && this.IsHost)
                                    {
                                        this.parent.ProcessMessage(this, message);
                                    }

                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
        }