Esempio n. 1
0
        private static bool InitializeFromConfigPkgWithCallerHoldingLock(string configPackageName)
        {
            ConfigurationPackage configurationPackage = null;

            if (TryGetConfigPackageObject(configPackageName, out configurationPackage))
            {
                instance = new FabricServiceConfig();
                instance.configurationSettings = configurationPackage.Settings;
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public bool Initialize()
        {
            var config = FabricServiceConfig.GetConfig();

            //File is not Present
            if (config == null || (IsExeSettingsFileEmpty(config) && DoesConfigurationSectionExist(config)))
            {
                AppTrace.TraceSource.WriteInfo(
                    TraceType,
                    "FabricServiceConfig instance is null .This can happen if Settings File is not Present");
                return(false);
            }


            if (config.configurationSettings != null)
            {
                if (config.configurationSettings.Sections.Contains(this.sectionName))
                {
                    this.configSection = config.configurationSettings.Sections[this.sectionName];
                    this.onInitialize();
                    return(true);
                }
                return(false);
            }

            foreach (var section in config.Settings.Section)
            {
                if (section.Name.Equals(this.sectionName.Trim()))
                {
                    this.exeSection = section;
                    this.onInitialize();
                    return(true);
                }
            }
            AppTrace.TraceSource.WriteInfo(
                TraceType,
                "Section :{0} is not present in FabricServiceConfig ",
                this.sectionName);
            return(false);
        }
Esempio n. 3
0
        private static bool InitializeWithCallerHoldingLock(string fullFilePath, IFabricServiceConfigParser configParser = null)
        {
            if (CheckifFileIsPresent(fullFilePath))
            {
                instance = new FabricServiceConfig();
                if (configParser == null)
                {
                    configParser = new SettingsConfigParser();
                }

                instance.Settings = configParser.Parse(fullFilePath);
                AppTrace.TraceSource.WriteInfo(TraceType, "Initialize Config From File:{0}", fullFilePath);
                return(true);
            }
            else
            {
                AppTrace.TraceSource.WriteInfo(
                    TraceType,
                    "Couldn't load config as Settings File {0} is not Found",
                    fullFilePath);
                return(false);
            }
        }
Esempio n. 4
0
 private static bool IsExeSettingsFileEmpty(FabricServiceConfig config)
 {
     return((config.Settings == null) || config.Settings.Section == null);
 }
Esempio n. 5
0
 private static bool DoesConfigurationSectionExist(FabricServiceConfig config)
 {
     return(config.configurationSettings == null);
 }
Esempio n. 6
0
 internal bool InitializeConfigFile(string filePath)
 {
     return(FabricServiceConfig.Initialize(filePath));
 }
Esempio n. 7
0
 internal bool InitializeConfigFileFromConfigPackage(string configPackageName)
 {
     return(FabricServiceConfig.InitializeFromConfigPackage(configPackageName));
 }