private DagNetConfig FetchConfigInternal()
        {
            DagNetConfig result;

            lock (this.dagNetConfigLock)
            {
                string text;
                if (DagNetEnvironment.TryRegistryRead <string>("DagNetConfig", null, out text) == null && !string.IsNullOrEmpty(text))
                {
                    int hashCode = text.GetHashCode();
                    if (this.serializedNetConfig == null || this.serializedNetConfigHashCode != hashCode)
                    {
                        DagNetEnvironment.Tracer.TraceDebug((long)this.GetHashCode(), "NetConfig change detected.", new object[0]);
                        Exception    ex;
                        DagNetConfig dagNetConfig = DagNetEnvironment.TryDeserializeConfig(text, out ex);
                        if (dagNetConfig != null)
                        {
                            this.currentNetConfig = dagNetConfig;
                        }
                        this.serializedNetConfig         = text;
                        this.serializedNetConfigHashCode = hashCode;
                    }
                }
                if (this.currentNetConfig == null)
                {
                    this.currentNetConfig = new DagNetConfig();
                }
                result = this.currentNetConfig;
            }
            return(result);
        }
Esempio n. 2
0
        private void LoadMapIfNeeded()
        {
            DagNetConfig dagNetConfig = DagNetEnvironment.FetchNetConfig();

            if (!object.ReferenceEquals(dagNetConfig, this.netConfig))
            {
                this.LoadMap(dagNetConfig);
            }
        }
        public static Exception PublishDagNetConfig(DagNetConfig cfg)
        {
            Exception result;

            try
            {
                string persistString = cfg.Serialize();
                result = DagNetEnvironment.PublishDagNetConfig(persistString);
            }
            catch (SerializationException ex)
            {
                result = ex;
            }
            return(result);
        }
Esempio n. 4
0
        private DagNetChooser.OutboundNetInfo[] FetchNetworkOrdering()
        {
            DagNetChooser.OutboundNetInfo[] array = new DagNetChooser.OutboundNetInfo[this.outboundNets.Length];
            int num = this.roundRobinIndex;

            this.roundRobinIndex = DagNetEnvironment.CircularIncrement(this.roundRobinIndex, this.roundRobinLimit);
            int num2 = 0;

            for (int i = num; i < this.roundRobinLimit; i++)
            {
                array[num2++] = this.outboundNets[i];
            }
            for (int i = 0; i < num; i++)
            {
                array[num2++] = this.outboundNets[i];
            }
            for (int i = this.roundRobinLimit; i < this.outboundNets.Length; i++)
            {
                array[num2++] = this.outboundNets[i];
            }
            return(array);
        }
Esempio n. 5
0
        private int GetCurrentReplicationPort()
        {
            DagNetConfig dagNetConfig = DagNetEnvironment.FetchLastKnownNetConfig();

            return(dagNetConfig.ReplicationPort);
        }