当前位置: 首页>>代码示例>>C#>>正文


C# Properties.Store方法代码示例

本文整理汇总了C#中Properties.Store方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.Store方法的具体用法?C# Properties.Store怎么用?C# Properties.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Properties的用法示例。


在下文中一共展示了Properties.Store方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveFrom

        public void SaveFrom(IConfiguration config, ConfigurationLevel level, Stream outputStream)
        {
            try {
                var keys = config.GetKeys(level);
                var properties = new Properties();

                foreach (var configKey in keys) {
                    var configValue = config.GetValue(configKey);
                    object value;
                    if (configValue == null || configValue.Value == null) {
                        value = configKey.DefaultValue;
                    } else {
                        value = configValue.Value;
                    }

                    var stringValue = Convert.ToString(value, CultureInfo.InvariantCulture);
                    properties.SetProperty(configKey.Name, stringValue);
                }

                properties.Store(outputStream, String.Empty);
            } catch (DatabaseConfigurationException) {
                throw;
            } catch (Exception ex) {
                throw new DatabaseConfigurationException("Could not save the configurations to the given stream.", ex);
            }
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:26,代码来源:PropertiesConfigFormatter.cs

示例2: OnManagersClear

        protected override void OnManagersClear()
        {
            // Write the manager server address to the properties file,
            Properties p = new Properties();
            p.SetProperty("manager_server_address", "");

            // Contains the root properties,
            string propFile = Path.Combine(path, "00.properties");
            FileStream fout = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
            p.Store(fout, null);
            fout.Close();
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:12,代码来源:FileSystemRootService.cs

示例3: OnManagersSet

        protected override void OnManagersSet(IServiceAddress[] addresses)
        {
            StringBuilder b = new StringBuilder();
            for (int i = 0; i < addresses.Length; ++i) {
                b.Append(addresses[i].ToString());
                if (i < addresses.Length - 1) {
                    b.Append(",");
                }
            }

            // Write the manager server address to the properties file,
            Properties p = new Properties();
            p.SetProperty("manager_server_address", b.ToString());

            // Contains the root properties,
            string propFile = Path.Combine(path, "00.properties");
            FileStream fout = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None);
            p.Store(fout, null);
            fout.Close();

            base.OnManagersSet(addresses);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:22,代码来源:FileSystemRootService.cs

示例4: OnUnbindingWithManager

        protected override void OnUnbindingWithManager(IServiceAddress managerAddress)
        {
            // Contains the root properties,
            string propFile = Path.Combine(basePath, "00.properties");
            using (FileStream fileStream = new FileStream(propFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)) {
                // Write the manager server address to the properties file,
                Properties p = new Properties();
                if (fileStream.Length > 0)
                    p.Load(fileStream);

                p.Remove("manager_address");

                fileStream.SetLength(0);
                p.Store(fileStream, null);
                fileStream.Close();
            }
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:17,代码来源:FileSystemRootService.cs


注:本文中的Properties.Store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。