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


C# Properties.Remove方法代码示例

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


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

示例1: Save

		public void Save(Properties parentProperties)
		{
			if (parentProperties == null)
				throw new ArgumentNullException("parentProperties");
			
			// Create properties container from container settings
			Properties formatProperties = new Properties();
			foreach (var activeOption in activeOptions) {
				object val = GetOption(activeOption);
				if (val != null) {
					formatProperties.Set(activeOption, val);
				}
			}
			if (formatProperties.Contains(AutoFormattingOptionName) && !autoFormatting.HasValue) {
				// AutoFormatting options was activated previously, remove it now
				formatProperties.Remove(AutoFormattingOptionName);
			} else {
				formatProperties.Set(AutoFormattingOptionName, autoFormatting);
			}
			
			parentProperties.SetNestedProperties("CSharpFormatting", formatProperties);
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:22,代码来源:CSharpFormattingOptionsContainer.cs

示例2: DownloadJars

        protected void DownloadJars()
        {
            Properties md5s = new Properties();
            if (File.Exists(Path.Combine(Inst.BinDir, "md5s")))
                md5s.Load(Path.Combine(Inst.BinDir, "md5s"));
            State = EnumState.DOWNLOADING;

            int[] fileSizes = new int[this.uriList.Length];
            bool[] skip = new bool[this.uriList.Length];

            // Get the headers and decide what files to skip downloading
            for (int i = 0; i < uriList.Length; i++)
            {
                Console.WriteLine("Getting header " + uriList[i].ToString());

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uriList[i]);
                request.Timeout = 1000 * 15; // Set a 15 second timeout
                request.Method = "HEAD";

                string etagOnDisk = null;
                if (md5s.ContainsKey(GetFileName(uriList[i])))
                    etagOnDisk = md5s[GetFileName(uriList[i])];

                if (!forceUpdate && !string.IsNullOrEmpty(etagOnDisk))
                    request.Headers[HttpRequestHeader.IfNoneMatch] = etagOnDisk;

                using (HttpWebResponse response = ((HttpWebResponse)request.GetResponse()))
                {
                    int code = (int)response.StatusCode;
                    if (code == 300)
                        skip[i] = true;

                    fileSizes[i] = (int)response.ContentLength;
                    this.totalDownloadSize += fileSizes[i];
                    Console.WriteLine("Got response: " + code + " and file size of " +
                                      fileSizes[i] + " bytes");
                }
            }

            int initialPercentage = Progress;

            byte[] buffer = new byte[1024 * 10];
            for (int i = 0; i < this.uriList.Length; i++)
            {
                if (skip[i])
                {
                    Progress = (initialPercentage + fileSizes[i] *
                                (100 - initialPercentage) / this.totalDownloadSize);
                }
                else
                {
                    string currentFile = GetFileName(uriList[i]);

                    if (currentFile == "minecraft.jar" && File.Exists("mcbackup.jar"))
                        File.Delete("mcbackup.jar");

                    md5s.Remove(currentFile);
                    md5s.Save(Path.Combine(Inst.BinDir, "md5s"));

                    int failedAttempts = 0;
                    const int MAX_FAILS = 3;
                    bool downloadFile = true;

                    // Download the files
                    while (downloadFile)
                    {
                        downloadFile = false;

                        HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(uriList[i]);
                        request.Headers[HttpRequestHeader.CacheControl] = "no-cache";

                        HttpWebResponse response = (HttpWebResponse) request.GetResponse();

                        string etag = "";
                        // If downloading from Mojang, use ETag.
                        if (uriList[i].ToString().StartsWith(Resources.MojangMCDLUri))
                        {
                            etag = response.Headers[HttpResponseHeader.ETag];
                            etag = etag.TrimEnd('"').TrimStart('"');
                        }
                        // If downloading from dropbox, ignore MD5s
                        else
                        {
                            // TODO add a way to verify integrity of files downloaded from dropbox
                        }

                        Stream dlStream = response.GetResponseStream();
                        using (FileStream fos =
                            new FileStream(Path.Combine(Inst.BinDir, currentFile), FileMode.Create))
                        {
                            int fileSize = 0;

                            using (MD5 digest = MD5.Create())
                            {
                                digest.Initialize();
                                int readSize;
                                while ((readSize = dlStream.Read(buffer, 0, buffer.Length)) > 0)
                                {
                                    //							Console.WriteLine("Read " + readSize + " bytes");
                                    fos.Write(buffer, 0, readSize);
//.........这里部分代码省略.........
开发者ID:Orochimarufan,项目名称:MultiMC,代码行数:101,代码来源:GameUpdater.cs

示例3: DownloadJars

        protected void DownloadJars()
        {
            Properties md5s = new Properties();
            if (File.Exists(Path.Combine(Inst.BinDir, "md5s")))
                md5s.Load(Path.Combine(Inst.BinDir, "md5s"));
            State = EnumState.DOWNLOADING;

            int[] fileSizes = new int[this.uriList.Length];
            bool[] skip = new bool[this.uriList.Length];

            // Get the headers and decide what files to skip downloading
            for (int i = 0; i < uriList.Length; i++)
            {
                Console.WriteLine("Getting header " + uriList[i].ToString());

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uriList[i]);
                request.Method = "HEAD";

                string etagOnDisk = null;
                if (md5s.ContainsKey(GetFileName(uriList[i])))
                    etagOnDisk = md5s[GetFileName(uriList[i])];

                if (!forceUpdate && !string.IsNullOrEmpty(etagOnDisk))
                    request.Headers[HttpRequestHeader.IfNoneMatch] = etagOnDisk;

                HttpWebResponse response = ((HttpWebResponse)request.GetResponse());

                int code = (int)response.StatusCode;
                if (code == 300)
                    skip[i] = true;

                fileSizes[i] = (int)response.ContentLength;
                this.totalDownloadSize += fileSizes[i];
                Console.WriteLine("Got response: " + code + " and file size of " +
                                  fileSizes[i] + " bytes");
            }

            int initialPercentage = Progress;

            byte[] buffer = new byte[1024 * 10];
            for (int i = 0; i < this.uriList.Length; i++)
            {
                if (skip[i])
                {
                    Progress = (initialPercentage + fileSizes[i] * 45 / this.totalDownloadSize);
                }
                else
                {
                    string currentFile = GetFileName(uriList[i]);
                    md5s.Remove(currentFile);
                    md5s.Save(Path.Combine(Inst.BinDir, "md5s"));

                    int failedAttempts = 0;
                    const int MAX_FAILS = 3;
                    bool downloadFile = true;

                    // Download the files
                    while (downloadFile)
                    {
                        downloadFile = false;

                        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uriList[i]);
                        request.Headers[HttpRequestHeader.CacheControl] = "no-cache";

                        Console.WriteLine("Getting response");
                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                        Console.WriteLine("Done");

                        string etag = response.Headers[HttpResponseHeader.ETag];
                        etag = etag.TrimEnd('"').TrimStart('"');

                        Stream dlStream = response.GetResponseStream();
                        FileStream fos =
                            new FileStream(Path.Combine(Inst.BinDir, currentFile), FileMode.Create);
                        int fileSize = 0;

                        MD5 digest = MD5.Create();
                        digest.Initialize();
                        int readSize;
                        while ((readSize = dlStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
            //							Console.WriteLine("Read " + readSize + " bytes");
                            fos.Write(buffer, 0, readSize);

                            this.currentDownloadSize += readSize;
                            fileSize += readSize;

                            digest.TransformBlock(buffer, 0, readSize, null, 0);

            //							Progress = fileSize / fileSizes[i];

                            Progress = (initialPercentage + this.currentDownloadSize
                                        * 70 / this.totalDownloadSize);
                        }
                        digest.TransformFinalBlock(new byte[] {}, 0, 0);

                        dlStream.Close();
                        fos.Close();

                        string md5 = HexEncode(digest.Hash);
//.........这里部分代码省略.........
开发者ID:ShaRose,项目名称:MultiMC,代码行数:101,代码来源:GameUpdater.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.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。