Esempio n. 1
0
        /// <summary>
        ///  FabricTransportSettings returns the default Settings .Loads the configuration file from default Config Package"Config" , if not found then try to load from  default config file "ClientExeName.Settings.xml"  from Client Exe directory.
        /// </summary>
        /// <param name="sectionName">Name of the section within the configuration file. If not found section in configuration file, it will return the default Settings</param>
        /// <returns></returns>
        private static FabricTransportSettings GetDefaultFabricTransportSettings(string sectionName = "TransportSettings")
        {
            FabricTransportSettings settings = (FabricTransportSettings)null;

            if (!FabricTransportSettings.TryLoadFrom(sectionName, out settings, (string)null, (string)null))
            {
                settings = new FabricTransportSettings();
            }
            return(settings);
        }
Esempio n. 2
0
        /// <summary>
        /// Try to load the FabricTransport settings from a sectionName specified in the configuration file.
        /// Configuration File can be specified using the filePath or using the name of the configuration package specified in the service manifest .
        /// It will first try to load config using configPackageName . if configPackageName is not specified then try to load  from filePath.
        /// </summary>
        /// <param name="sectionName">Name of the section within the configuration file. If not found section in configuration file, it return false</param>
        /// <param name="filepath"> Full path of the file where the settings will be loaded from.
        ///  If not specified , it will first try to load from default Config Package"Config" , if not found then load from Settings "ClientExeName.Settings.xml" present in Client Exe directory. </param>
        ///  <param name="configPackageName"> Name of the configuration package. If its null or empty,it will check for file in filePath</param>
        /// <param name="settings">When this method returns it sets the <see cref="FabricTransportRemotingSettings"/> settings if load from Config succeeded. If fails ,its sets settings to null/> </param>
        /// <returns><see cref="bool"/> specifies whether the settings get loaded successfully from Config.
        /// It returns true when load from Config succeeded, else return false. </returns>
        /// <remarks>
        /// The following are the parameter names that should be provided in the configuration file,to be recognizable by service fabric to load the transport settings.
        ///
        ///     1. MaxQueueSize - <see cref="MaxQueueSize"/>value in long.
        ///     2. MaxMessageSize - <see cref="MaxMessageSize"/>value in bytes.
        ///     3. MaxConcurrentCalls - <see cref="MaxConcurrentCalls"/>value in long.
        ///     4. SecurityCredentials - <see cref="SecurityCredentials"/> value.
        ///     5. OperationTimeoutInSeconds - <see cref="OperationTimeout"/> value in seconds.
        ///     6. KeepAliveTimeoutInSeconds - <see cref="KeepAliveTimeout"/> value in seconds.
        /// </remarks>
        public static bool TryLoadFrom(string sectionName, out FabricTransportRemotingSettings settings,
                                       string filepath          = null,
                                       string configPackageName = null)
        {
            FabricTransportSettings transportSettings;
            var isSucceded = FabricTransportSettings.TryLoadFrom(sectionName, out transportSettings, filepath,
                                                                 configPackageName);

            if (isSucceded)
            {
                settings = new FabricTransportRemotingSettings(transportSettings);
                return(true);
            }

            settings = null;
            return(isSucceded);
        }