예제 #1
0
        /// <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);
        }
예제 #2
0
        //----------------------------------------------------------------------
        //	解析
        //----------------------------------------------------------------------
        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);
        }
예제 #3
0
        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);
        }
예제 #4
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);
            }
        }
예제 #5
0
        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();
        }
예제 #6
0
 public bool TryGetList(string path, out Gen::IEnumerable <FileInfo> list)
 {
     return(this.TryGetList(System.DateTime.Now, path, out list));
 }
예제 #7
0
 /// <summary>
 /// System.Collections.IEnumerable を <see cref="afh.Collections.Enumerable&lt;T&gt;"/> に変換します。
 /// </summary>
 /// <param name="enumerable"><see cref="afh.Collections.Enumerable&lt;T&gt;"/>
 /// 型かどうか分からない IEnumerable を指定します。
 /// </param>
 /// <returns>指定した System.Collections.IEnumerable が
 /// <see cref="afh.Collections.Enumerable&lt;T&gt;"/> の時はその儘返します。
 /// それ以外の場合には Enumerable インスタンスに変換して返します。</returns>
 public static Enumerable <T> From <T>(Gen::IEnumerable <T> enumerable)
 {
     return(Enumerable <T> .From(enumerable));
 }