private XElement ReadAssemblyHeader() {
            using (var a = new AssemblyUsage(FullName)) {
                var assembly = a.Assembly;              
                var result = new XElement("assembly");
               
                foreach (var attribute in assembly.GetCustomAttributes()) {
                    var properties = attribute.GetType().GetProperties().Where(_ => _.Name != "TypeId").ToArray();
                    if (properties.Length == 1) {
                        result.SetAttributeValue(attribute.GetType().Name, properties[0].GetValue(attribute));
                    }
                    else {
                     
                    var e = new XElement(attribute.GetType().Name);
                    foreach (var info in properties) {
                        var val = info.GetValue(attribute).ToStr();
                        e.SetAttributeValue(info.Name,val);

                    }
                    result.Add(e);   
                    }
                }

                return result;
            }
        }
 private void CheckAssemblyVersion() {
     using (var a = new AssemblyUsage(FullName)) {
         var assembly = a.Assembly;
         Version = File.GetLastWriteTimeUtc(FullName);
         Hash = assembly.GetName().Version.ToString();
     }
 }
Exemple #3
0
        static public void Run(string[] args)
        {
            try
            {
                object param = new RemoveClientNodeParam();
                CommandLineArgumentParser.CommandLineParser(ref param, args);
                cParam = (RemoveClientNodeParam)param;
                if (cParam.IsUsage)
                {
                    AssemblyUsage.PrintLogo(cParam.IsLogo);
                    AssemblyUsage.PrintUsage();
                    return;
                }

                if (!ValidateParameters())
                {
                    return;
                }

                if (cParam.Port != -1)
                {
                    NCache.Port = cParam.Port;
                }

                if (cParam.Port == -1)
                {
                    NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort;
                }


                if (cParam.Server != null || cParam.Server != string.Empty)
                {
                    NCache.ServerName = cParam.Server;
                }

                cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                config = cacheServer.GetNewConfiguration(cParam.CacheId);
                string getClusterIp = cacheServer.GetClusterIP();
                if (config == null)
                {
                    Console.Error.WriteLine("Error: The cache doesnot exist.");
                    return;
                }
                if (config.CacheSettings.CacheType == "clustered-cache")
                {
                    Console.WriteLine("Removing client node '{0}' from cache '{1}' on server '{2}:{3}'.",
                                      cParam.ClientNode, cParam.CacheId, getClusterIp, NCache.Port);
                    foreach (Address node in config.CacheDeployment.Servers.GetAllConfiguredNodes())
                    {
                        currentServerNodes.Add(node.IpAddress.ToString());
                    }
                }
                else
                {
                    Console.Error.WriteLine("Error: Client nodes cannot be removed from local caches");
                    return;
                }

                if (UpdateConfigs())
                {
                    Console.WriteLine("Client node '{0}' successfully removed from cache '{1}' on server {2}:{3}.",
                                      cParam.ClientNode, cParam.CacheId, getClusterIp, NCache.Port);
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error: {0}", ex.Message);
            }
            finally
            {
                if (cacheServer != null)
                {
                    cacheServer.Dispose();
                }
            }
        }