/// <summary>
        /// Returns what should be the mongoc configuration
        /// </summary>
        /// <returns></returns>
        public static List<ShardNode> GetShardConfigurationExpected()
        {
            List<ShardNode> ExpectedConfig = new List<ShardNode>();

            //TODO : return the list of active instances

            foreach (var instance in RoleEnvironment.Roles["MainShardRole"].Instances)
            {
                ShardNode node = new ShardNode()
                {
                    ID = instance.Id,
                    Host = instance.Id + "/" + instance.Id + ":" + instance.InstanceEndpoints["MongoDbEndpoint"].IPEndpoint.Port
                };

                ExpectedConfig.Add(node);
            }
            //ExpectedConfig.Add(new ShardNode() { ID = RoleEnvironment.CurrentRoleInstance.Id, Host = RoleEnvironment.CurrentRoleInstance.Id + ":" + RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["MongoDbEndpoint"].IPEndpoint.Port });

            return ExpectedConfig;

            //foreach (string replicaSetWorkerName in RoleEnvironment.GetConfigurationSettingValue("ReplicaSetNames").Split(';'))
            //{
            //    //For each ReplicaSet
            //    string[] names = replicaSetWorkerName.Split(':');
            //    string roleName = names[0];
            //    string replicaSetName = names[1];

            //    //Make a mongo-like host format : something like replica1/10.26.150.63:20003,10.26.156.91:20003,10.26.158.51:20003
            //    //Note : we have to ignore hidden members
            //    string Hostdesc = string.Format("{0}/{1}", replicaSetName, string.Join(",",
            //        MongoDBAzurePlatform.Instance.GetReplicaSetMembers(roleName).Where(i => MongoDBAzurePlatform.Instance.GetFunctionnalDataRole(i, roleName) != MongoDBAzurePlatform.FunctionnalDataRole.HiddenMemberAzureDrive).Select(i => i.ToString())));
            //    ExpectedConfig.Add(new ShardNode() { ID = replicaSetName, Host = Hostdesc });
            //}

            //return ExpectedConfig;
        }
        public static List<ShardNode> GetShardConfigurationFromMongoC(NodeEndPoint nodeEndpoint)
        {
            List<ShardNode> r = new List<ShardNode>();

            try
            {
                // We connect to a mongoC
                MongoServer server = CreateMongoServer(nodeEndpoint);
                MongoDatabase db = server["config"];
                MongoCollection shards = db["shards"];

                var cursor = shards.FindAllAs(typeof(BsonDocument));
                foreach (var shard in cursor)
                {
                    ShardNode cfg = new ShardNode();
                    cfg.ID = (((BsonDocument)(shard)))["_id"].AsString;
                    cfg.Host = (((BsonDocument)(shard)))["host"].AsString;
                    r.Add(cfg);
                }
            }
            catch (Exception ee)
            {
                Trace.TraceError("GetShardConfigurationFromMongoC : Error while getting inner shard configuration : " + ee.Message + " " + ee.InnerException == null ? "" : ee.InnerException.Message);
                throw;
            }

            return r;
        }