예제 #1
0
        private string GetBasePath(string fileStoreKey)
        {
            XmlNode configSection = CSConfiguration.GetConfig().GetConfigSection("CommunityServer/CentralizedFileStorage");
            string  basePath      = null;

            if (configSection != null)
            {
                foreach (XmlNode xmlNode in configSection.ChildNodes.Cast <XmlNode>().Where(xmlNode => xmlNode.NodeType != XmlNodeType.Comment))
                {
                    if (xmlNode.Name == "fileStoreGroup")
                    {
                        if (xmlNode.Attributes != null &&
                            xmlNode.Attributes["default"] != null &&
                            xmlNode.Attributes["default"].Value == "true" &&
                            xmlNode.Attributes["basePath"] != null &&
                            !String.IsNullOrEmpty(xmlNode.Attributes["basePath"].Value) &&
                            basePath == null)
                        {
                            basePath = xmlNode.Attributes["basePath"].Value;
                        }

                        foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
                        {
                            if (xmlNode2.Name == "fileStore" &&
                                xmlNode2.Attributes != null &&
                                xmlNode2.Attributes["name"] != null &&
                                xmlNode2.Attributes["name"].Value == fileStoreKey &&
                                xmlNode2.Attributes["basePath"] != null &&
                                !String.IsNullOrEmpty(xmlNode2.Attributes["basePath"].Value))
                            {
                                basePath = xmlNode2.Attributes["basePath"].Value;
                                break;
                            }
                        }

                        continue;
                    }

                    if (xmlNode.Name == "fileStore" &&
                        xmlNode.Attributes != null &&
                        xmlNode.Attributes["name"] != null &&
                        xmlNode.Attributes["name"].Value == fileStoreKey &&
                        xmlNode.Attributes["basePath"] != null &&
                        !String.IsNullOrEmpty(xmlNode.Attributes["basePath"].Value))
                    {
                        basePath = xmlNode.Attributes["basePath"].Value;
                        break;
                    }
                }
            }

            return(basePath);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            var config = new CSConfiguration
            {
                Host           = "192.168.1.11",
                Port           = 3456,
                SerializerType = typeof(Serializer)
            };
            var server = new ClientServer4Net.Server.Server(config);

            server.Start(new FactoryServerHandler <ClientHandler>());
            Console.WriteLine("Server stop");
            Console.ReadLine();
        }
예제 #3
0
        public static void Main(string[] args)
        {
            Thread.Sleep(1000);
            var config = new CSConfiguration
            {
                Host           = "192.168.1.11",
                Port           = 3456,
                SerializerType = typeof(Serializer)
            };
            var client = new ClientServer4Net.Client.Client(config);

            client.Start(new ClientHandler());
            Console.WriteLine("Client stop");
            Console.ReadLine();
        }
예제 #4
0
 protected SerializationContext(CSConfiguration configuration)
 {
     _serializer = (ISerializer)Activator.CreateInstance(configuration.SerializerType);
 }
예제 #5
0
 public Client(CSConfiguration configuration) : base(configuration)
 {
     _configuration = configuration;
     _isConnected   = false;
 }
예제 #6
0
 public Server(CSConfiguration configuration) : base(configuration)
 {
     _configuration = configuration;
     _isConnected   = false;
 }