/// <summary> /// 列挙子から一番最初の要素を取得します。 /// </summary> /// <typeparam name="T">列挙されるオブジェクトの型を指定します。</typeparam> /// <param name="enumerable">列挙子を指定します。</param> /// <returns>一番最初の要素を返します。もし、要素が一つも含まれていない場合には、型 T の既定値を返します。</returns> public static T First <T>(this Gen::IEnumerable <T> enumerable) { T ret = default(T); foreach (T value in enumerable) { ret = value; break; } return(ret); }
//---------------------------------------------------------------------- // 解析 //---------------------------------------------------------------------- public Tree.IExpression Parse(Context startContext, Gen::IEnumerable <Word> input) { this.stk_parse = new Stack(); this.ctx = startContext; foreach (Word w in input) { switch (w.type) { case WordType.Operator: if (TryBinaryOperator(w.word)) { break; } if (TrySuffixOperator(w.word)) { break; } if (TryPrefixOperator(w.word)) { break; } if (TryPParenOperator(w.word)) { break; } if (TrySParenOperator(w.word)) { break; } break; case WordType.Identifier: this.stk_parse.Push( new ExpressionElement(new Tree.IdExpression(w.word)) ); break; case WordType.Literal: this.stk_parse.Push( new ExpressionElement(new Tree.LiteralExpression(w.word)) ); break; } } if (!this.stk_parse.IsTopExpression) { throw new System.Exception("ParseError"); } return(this.stk_parse.PopOperand(0).Expression); }
int InternalGetFileList(string rpath, out Gen::IEnumerable <FileInfo> list) { System.DateTime now = System.DateTime.Now; list = this.GetList(now, rpath); if (list == null) { return(-WinErrorCode.ERROR_FILE_NOT_FOUND); } foreach (FileInfo fi in list) { this.Reparse(now, fi); } return(0); }
public bool TryGetList(System.DateTime referenceTime, string path, out Gen::IEnumerable <FileInfo> list) { this.DiscardOld(referenceTime); DirEntries value; if (diclist.TryGetValue(path, out value)) { list = value.list; return(true); } else { list = null; return(false); } }
public void SetList(string path, Gen::IEnumerable <FileInfo> entries) { string dir = path; if (!dir.EndsWith("/")) { dir += "/"; } System.DateTime now = System.DateTime.Now; lock (this.sync_root){ Gen::List <FileInfo> list = null; if (entries != null) { list = new Gen::List <FileInfo>(); foreach (FileInfo info in entries) { dicattr[info.InternalPath] = info; if (info.InternalPath != path) { list.Add(info); } if (info.informationTime < this.oldestInfoTime) { this.oldestInfoTime = info.informationTime; } } } diclist[path] = new DirEntries(list, now); if (now < this.oldestInfoTime) { this.oldestInfoTime = now; } } this.DiscardOld(); }
public bool TryGetList(string path, out Gen::IEnumerable <FileInfo> list) { return(this.TryGetList(System.DateTime.Now, path, out list)); }
/// <summary> /// System.Collections.IEnumerable を <see cref="afh.Collections.Enumerable<T>"/> に変換します。 /// </summary> /// <param name="enumerable"><see cref="afh.Collections.Enumerable<T>"/> /// 型かどうか分からない IEnumerable を指定します。 /// </param> /// <returns>指定した System.Collections.IEnumerable が /// <see cref="afh.Collections.Enumerable<T>"/> の時はその儘返します。 /// それ以外の場合には Enumerable インスタンスに変換して返します。</returns> public static Enumerable <T> From <T>(Gen::IEnumerable <T> enumerable) { return(Enumerable <T> .From(enumerable)); }