コード例 #1
0
 protected override void OnRemoving()
 {
     base.OnRemoving();
     try
     {
         AdminRoles.Clear(); //foreach thing in AdminRoles en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete Team in AdminRoles delete", ex);
     }
     try
     {
         Scopes.Clear(); //foreach thing in Scopes en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete Team in Scopes delete", ex);
     }
     try
     {
         Updates.Clear(); //foreach thing in Updates en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete Team in Updates delete", ex);
     }
     FlushCache();
 }
コード例 #2
0
 public virtual void RemoveAllScopes()
 {
     foreach (var scope in Scopes)
     {
         scope.RemoveAllUserClaims();
     }
     Scopes.Clear();
 }
コード例 #3
0
ファイル: context.cs プロジェクト: RenolY2/ssc
        public void Clear()
        {
            DataTable.Clear();
            SymbolTable.Clear();
            Scopes.Clear();
            Loops.Clear();
            mNameStack.Clear();

            // reinstall system symbols
            AddSystemSymbols();
        }
コード例 #4
0
 protected override void OnRemoving()
 {
     base.OnRemoving();
     try
     {
         DocumentSets.Clear(); //foreach thing in DocumentSets en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete DocumentSet in DocumentSets delete", ex);
     }
     try
     {
         Histories.Clear(); //foreach thing in Histories en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete DocumentSet in Histories delete", ex);
     }
     try
     {
         Scopes.Clear(); //foreach thing in Scopes en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete DocumentSet in Scopes delete", ex);
     }
     try
     {
         Stats.Clear(); //foreach thing in Stats en.Remove();
     }
     catch (Exception ex)
     {
         throw new DocException("Failed to delete DocumentSet in Stats delete", ex);
     }
     FlushCache();
 }
コード例 #5
0
        /// <summary>
        /// surfaces.txt を読み込む
        /// </summary>
        public virtual void Load()
        {
            var charsetPattern = new Regex(@"charset\s,\s*(.+?)\s*\z");

            // 既存の値はクリア
            Scopes.Clear();
            // ファイル更新日時セット
            LastWriteTime = File.GetLastWriteTime(Path);

            // まずはエンコーディングの判定を行うために、対象ファイルの内容を1行ずつ読み込む
            var sjis     = Encoding.GetEncoding(932);
            var encoding = sjis;
            var preLines = File.ReadLines(Path, encoding: sjis);

            foreach (var line in preLines)
            {
                // charset行が見つかった場合は、文字コードを設定してループ終了
                var matched = charsetPattern.Match(line);
                if (matched.Success)
                {
                    var charset = matched.Groups[1].Value;
                    encoding = Encoding.GetEncoding(charset);
                    break;
                }

                // 空行でない行が見つかった場合は、文字コードを設定せずにループ終了
                if (!string.IsNullOrEmpty(line.Trim()))
                {
                    break;
                }
            }

            // エンコーディングが確定したら、読み込みメイン処理
            var    lines           = File.ReadLines(Path, encoding: encoding);
            string preTrimmedLine  = null; // 前行
            string currentScope    = null; // 現在のスコープ
            var    valueSeparators = new[] { ',' };

            foreach (var line in lines)
            {
                var trimmedLine = line.Trim();

                // コメントは無視 (仕様にはないが、行の途中からコメントが始まっている場合も許容)
                if (trimmedLine.Contains("//"))
                {
                    trimmedLine = trimmedLine.Remove(trimmedLine.IndexOf("//")).Trim();
                }

                if (string.IsNullOrEmpty(trimmedLine))  // 空行
                {
                    // 空行の場合はスキップ
                    continue;
                }
                else if (trimmedLine == "{")  // 開きブレス処理
                {
                    // 直前行がない場合は不正としてスキップ
                    if (preTrimmedLine == null)
                    {
                        continue;
                    }

                    // スコープを設定
                    currentScope = preTrimmedLine; // 直前行の記載内容をスコープ名とする
                    continue;
                }
                else if (trimmedLine.EndsWith("{"))  // 開きブレス かつスコープ名がある場合の処理 (仕様上は不正)
                {
                    // スコープを設定

                    currentScope = trimmedLine.Replace("{", "").Trim(); // ブレスを削除し、前後の空白を削除した後の結果をスコープ名とする
                    continue;
                }

                else if (trimmedLine == "}")  // 閉じブレス
                {
                    // スコープ内にいない場合は不正としてスキップ
                    if (currentScope == null)
                    {
                        continue;
                    }

                    // スコープをクリア
                    currentScope = null;
                    continue;
                }
                else if (trimmedLine.Contains(","))   // 上記以外でカンマを含む
                {
                    var pair = trimmedLine.Split(valueSeparators, 2);

                    // スコープ内にいれば、対象スコープの値として追加
                    if (currentScope != null)
                    {
                        if (!Scopes.ContainsKey(currentScope))
                        {
                            Scopes[currentScope] = new Scope();
                        }

                        Scopes[currentScope].Entries.Add(Tuple.Create(pair[0].Trim(), pair[1].Trim())); // 仕様上は不正と思われるが、たまに大文字混じりでキーを指定しているケースがあるためdowncase
                    }
                }

                // 前行として保存
                preTrimmedLine = trimmedLine;
            }
        }
コード例 #6
0
 public virtual void RemoveAllScopes()
 {
     Scopes.Clear();
 }