isFile() public static method

public static isFile ( int type ) : bool
type int
return bool
示例#1
0
        void BookmarkAddClick(object sender, EventArgs e)
        {
            int    current = PLink.host.Current;
            int    index   = -1;
            string key     = "";
            string value   = "";

            if (Util.isWeb(current))
            {
                index = PLink.host.SelectWebIndex;
                KeyValuePair <string, string> obj = (KeyValuePair <string, string>)cbWebPolicy.Items[index];

                key   = string.Format("{0}", obj.Key);
                value = string.Format("WEB|{0}", obj.Value);
            }
            else if (Util.isFile(current))
            {
                index = PLink.host.SelectLocalIndex;
                KeyValuePair <string, string> obj = (KeyValuePair <string, string>)cbLocalPolicy.Items[index];

                key   = string.Format("{0}", obj.Key);
                value = string.Format("LOCAL|{0}", obj.Value);
            }

            // value 가 있는지 체크
            foreach (KeyValuePair <string, string> item in bookmarkList.Items)
            {
                if (item.Value.Equals(value))
                {
                    MessageBox.Show("Already exists bookmark.", "Alert");
                    return;
                }
            }

            bookmarkList.Items.Add(new KeyValuePair <string, string>(key, value));

            log(key + " : " + value);

            // 레지스트리에 북마크 저장
            PLink.host.setBookmark(key, value);
        }
示例#2
0
        // call by fiddler
        public void OnLoad()
        {
            msgAdmin.Visible = !Util.canModifyHosts();

            bool running = Util.getPrefBool(Util.REG_KEY_RUNNING);

            // 비정상 종료 , running 변수가 남아있으면 비정상 종료 체크 하시오.
            if (running)
            {
                PLink.host.initHostFile();
                plink.initCapture();
            }

            PLink.host.backupHostFile();

            bool   auto       = Util.getPrefBool(Util.REG_KEY_AUTO);
            bool   start      = Util.getPrefBool(Util.REG_KEY_START);
            int    current    = Util.getPrefInt(Util.REG_KEY_CURRENT_POLICY);
            int    web_select = Util.getPrefInt(Util.REG_KEY_WEB_POLICY_SELECT);
            string local_path = Util.getPref(Util.REG_KEY_LOCAL_POLICY_PATH);

            try {
                PLink.host.Current = current;

                // regist setting load
                loadWebData();

                autoStart.Checked = auto;

                if (autoStart.Checked)
                {
                    changeStatus(current);

                    if (Util.isWeb(current))
                    {
                        if (web_select > -1)
                        {
                            cbWebPolicy.SelectedIndex = web_select;
                        }

                        if (!string.IsNullOrEmpty(local_path))
                        {
                            loadLocalData(local_path);
                        }
                    }
                    else if (Util.isFile(current))
                    {
                        if (!string.IsNullOrEmpty(local_path))
                        {
                            loadLocalData(local_path, true);
                        }
                    }

                    // set start button
                    checkBox2.Checked = start;
                }
            } catch (Exception ex) {
                log(ex.Message);
            }

            Util.setPrefBool(Util.REG_KEY_RUNNING, true);

            // 북마크 로드
            ArrayList bookmark = PLink.host.getBookmarkList();

            foreach (KeyValuePair <string, string> mark in bookmark)
            {
                bookmarkList.Items.Add(mark);
            }
        }