コード例 #1
0
ファイル: EcsLanguageService.cs プロジェクト: Shaykh/Loyc
		public IListSource<LNode> Parse(IListSource<Token> input, ISourceFile file, IMessageSink msgs, Symbol inputType = null)
		{
			// For efficiency we'd prefer to re-use our _parser object, but
			// when parsing lazily, we can't re-use it because another parsing 
			// operation could start before this one is finished. To force 
			// greedy parsing, we can call ParseStmtsGreedy(), but the caller may 
			// prefer lazy parsing, especially if the input is large. As a 
			// compromise I'll check if the source file is larger than a 
			// certain arbitrary size. Also, ParseExprs() is always greedy 
			// so we can always re-use _parser in that case.
			bool exprMode = inputType == ParsingService.Exprs;
			char _ = '\0';
			if (inputType == ParsingService.Exprs || file.Text.TryGet(255, ref _)) {
				EcsParser parser = _parser;
				if (parser == null)
					_parser = parser = new EcsParser(input, file, msgs);
				else {
					parser.ErrorSink = msgs ?? MessageSink.Current;
					parser.Reset(input, file);
				}
				if (inputType == ParsingService.Exprs)
					return parser.ParseExprs();
				else
					return parser.ParseStmtsGreedy();
			} else {
				var parser = new EcsParser(input, file, msgs);
				return parser.ParseStmtsLazy().Buffered();
			}
		}
コード例 #2
0
ファイル: EcsTriviaInjector.cs プロジェクト: qwertie/ecsharp
		protected override VList<LNode> AttachTriviaTo(ref LNode node, IListSource<Token> trivia, TriviaLocation loc, LNode parent, int indexInParent)
		{
			int nli;
			if (loc == TriviaLocation.Trailing && indexInParent == 1 && parent != null && parent.Calls(CodeSymbols.If, 3) && 
				(nli = trivia.LastIndexWhere(t => t.Type() == TokenType.Newline)) != -1) {
				// The 'else' keyword is invisible here, but it often appears on a line by 
				// itself; remove a newline to avoid creating a blank line when printing.
				var triviaSans = new DList<Token>(trivia);
				triviaSans.RemoveAt(nli);
				trivia = triviaSans;
			}
			return base.AttachTriviaTo(ref node, trivia, loc, parent, indexInParent);
		}
コード例 #3
0
ファイル: PowerDataGrid2.cs プロジェクト: radtek/datacenter
        /// <summary>
        /// 重写 <see cref="GridView"/>.OnDataBinding 事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDataBinding(EventArgs e)
        {
            IListSource listSource = this.DataSource as IListSource;

            if (listSource != null)
            {
                base.RecordCount = listSource.GetList().Count;
            }
            else
            {
                ICollection collection = this.DataSource as ICollection;
                if (collection != null)
                {
                    base.RecordCount = collection.Count;
                }
            }

            base.OnDataBinding(e);
        }
コード例 #4
0
        public void WriteData(AMFWriter writer, object data)
        {
            if (data is IList)
            {
                IList    list  = data as IList;
                object[] array = new object[list.Count];
                list.CopyTo(array, 0);
                writer.WriteArray(ObjectEncoding.AMF0, array);
                return;
            }
#if !(SILVERLIGHT)
            IListSource listSource = data as IListSource;
            if (listSource != null)
            {
                IList    list  = listSource.GetList();
                object[] array = new object[list.Count];
                list.CopyTo(array, 0);
                writer.WriteArray(ObjectEncoding.AMF0, array);
                return;
            }
#endif
            if (data is IDictionary)
            {
                writer.WriteAssociativeArray(ObjectEncoding.AMF0, data as IDictionary);
                return;
            }
            if (data is Exception)
            {
                writer.WriteASO(ObjectEncoding.AMF0, new ExceptionASO(data as Exception));
                return;
            }
            if (data is IEnumerable)
            {
                List <object> tmp = new List <object>();
                foreach (object element in (data as IEnumerable))
                {
                    tmp.Add(element);
                }
                writer.WriteArray(ObjectEncoding.AMF0, tmp.ToArray());
                return;
            }
            writer.WriteObject(ObjectEncoding.AMF0, data);
        }
コード例 #5
0
ファイル: TextComboBox.cs プロジェクト: sillsdev/WorldPad
        protected void DrawDataBoundMember(Graphics g, Brush brush, int index, Point point)
        {
            string text = string.Empty;

            if (DataSource != null)
            {
                IList list = null;
                // We coud be bound to an array list which implement the IList interface
                // or we could be bound to a DataSet which implements the IListSource from which
                // we can get the IList interface
                if (DataSource is IList)
                {
                    // Assume this is an array object and try to get the data based
                    // on this assumption
                    list = (IList)DataSource;
                    Debug.Assert(list != null, "ComboBox is bound to unrecognized DataSource");
                    // Now extract the actual text to be displayed
                    object o          = list[index];
                    Type   objectType = o.GetType();
                    // Now invoke the method that is associate with the
                    // Display name property of the ComboBox
                    PropertyInfo pi = objectType.GetProperty(DisplayMember);
                    text = (string)pi.GetValue(o, null);
                }
                else
                {
                    // Data set object
                    if (DataSource is IListSource)
                    {
                        IListSource ls = (IListSource)DataSource;
                        list = ls.GetList();
                        Debug.Assert(list != null, "ComboBox is bound to unrecognized DataSource");
                        // This is a data set object, get the value under that assumption
                        DataRowView dataRowView = (DataRowView)list[index];
                        DataRow     dataRow     = dataRowView.Row;
                        object      o           = dataRow[DisplayMember];
                        text = o.ToString();
                    }
                }
                g.DrawString(text, Font, brush, point);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: racoltacalin/LLLPG-Samples
        static void Main(string[] args)
        {
            Console.WriteLine(
                "Welcome to EC# parser demo.\n\n" +
                "Please type a valid C# or EC# statement such as x = 7; or class Man:Beast {}\n" +
                "or while(true) Console.WriteLine(\"I'm not crazy!\"); (or exit to quit).\n");
            Console.WriteLine(
                "The parser produces Loyc trees, and they are printed out using the default\n" +
                "printer which is the LES printer.\n");
            Console.WriteLine(
                "The parser was ripped out of Loyc.Ecs.dll for this demo. Loyc.Ecs.dll, unlike \n" +
                "this demo, also contains the EC# printer (which LLLPG uses to write output).\n");
            Console.WriteLine(
                "Exercise for the reader: write a REPL for C#. Just kidding.\n");

            string line;

            while ((line = Console.ReadLine()) != "exit")
            {
                while (line.EndsWith(" "))                 // user can add additional lines this way
                {
                    line += "\n" + Console.ReadLine();
                }
                try {
                    // Parse EC#!
                    IListSource <LNode> stmts = EcsLanguageService.Value.Parse(line, MessageSink.Console);
                    // If you'd like to parse LES instead of EC#, write this instead:
                    // IListSource<LNode> stmts = Loyc.Syntax.Les.LesLanguageService.Value.Parse(line, MessageSink.Console);

                    var c = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    foreach (var stmt in stmts)
                    {
                        Console.WriteLine("Syntax tree (LES format): " + stmt.ToString());
                    }
                    Console.ForegroundColor = c;
                } catch (Exception ex) {
                    Console.WriteLine(ex.GetType().Name + ": " + ex.Message);
                }
                Console.WriteLine();
            }
        }
コード例 #7
0
        public static IEnumerable GetDataMember(IListSource dataSource, string dataMember)
        {
            IEnumerable enumerable = null;
            IList       list       = dataSource.GetList();

            if ((list != null) && (list is ITypedList))
            {
                if (!dataSource.ContainsListCollection)
                {
                    if ((dataMember != null) && (dataMember.Length != 0))
                    {
                        throw new ArgumentException(System.Design.SR.GetString("DesignTimeData_BadDataMember"));
                    }
                    return(list);
                }
                PropertyDescriptorCollection itemProperties = ((ITypedList)list).GetItemProperties(new PropertyDescriptor[0]);
                if ((itemProperties == null) || (itemProperties.Count == 0))
                {
                    return(enumerable);
                }
                PropertyDescriptor descriptor = null;
                if ((dataMember == null) || (dataMember.Length == 0))
                {
                    descriptor = itemProperties[0];
                }
                else
                {
                    descriptor = itemProperties.Find(dataMember, true);
                }
                if (descriptor != null)
                {
                    object component = list[0];
                    object obj3      = descriptor.GetValue(component);
                    if ((obj3 != null) && (obj3 is IEnumerable))
                    {
                        enumerable = (IEnumerable)obj3;
                    }
                }
            }
            return(enumerable);
        }
コード例 #8
0
        protected virtual void OnSourceChanged(IListSource <T> source)
        {
            BeginUpdate();

            Items.Clear();

            if (_imageList != null)
            {
                _imageList.Images.Clear();
            }

            if (_currentSource != null)
            {
                Bitmap bmp;
                int    index = 0;

                T[] items = _currentSource.ListItems;
                if (items != null)
                {
                    foreach (T item in items)
                    {
                        item.ImageIndex = -1;
                        if (item is TextureDefinition)
                        {
                            if ((bmp = (item as TextureDefinition).Texture) != null)
                            {
                                ImageList.Images.Add(bmp);
                                item.ImageIndex = index++;
                            }
                        }
                        Items.Add(item);
                    }
                }
            }
            else
            {
                SelectedResource = null;
            }

            EndUpdate();
        }
コード例 #9
0
        public static IEnumerable GetSelectedDataSource(IComponent component, string dataSource, string dataMember)
        {
            IEnumerable enumerable         = null;
            object      selectedDataSource = GetSelectedDataSource(component, dataSource);

            if (selectedDataSource == null)
            {
                return(enumerable);
            }
            IListSource source = selectedDataSource as IListSource;

            if (source != null)
            {
                if (!source.ContainsListCollection)
                {
                    return(source.GetList());
                }
                return(GetDataMember(source, dataMember));
            }
            return((IEnumerable)selectedDataSource);
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: jeasonyoung/csharp_sfit
 static void WriteData(ref TextBox text, IListSource sources)
 {
     text.Text = "正在加载数据....";
     if (sources != null)
     {
         System.Collections.IList list = sources.GetList();
         if (list != null && list.Count > 0)
         {
             StringBuilder sb = new StringBuilder();
             for (int i = 0; i < list.Count; i++)
             {
                 object obj = list[i];
                 if (obj != null)
                 {
                     sb.AppendLine(string.Format("{0}.{1}", i + 1, obj));
                 }
             }
             text.Text = sb.ToString();
         }
     }
 }
コード例 #11
0
        public void OnListChanging(IListSource <T> sender, ListChangeInfo <T> e)
        {
            if (_parent is IListChanging <T> )
            {
                (_parent as IListChanging <T>).OnListChanging(sender, e);
            }
            int addCount    = e.NewItems.Count;
            int removeCount = addCount - e.SizeChange;

            for (int i = e.Index; i < e.Index + removeCount; i++)
            {
                try {
                    _list[i].OnBeingRemoved(_parent);                     // could throw
                } catch {
                    // Notify earlier items that changes are being "undone"
                    for (int j = e.Index; j < i; j++)
                    {
                        try { _list[i].OnBeingAdded(_parent); } catch { }
                    }
                    throw;
                }
            }
            for (int i = 0; i < addCount; i++)
            {
                try {
                    e.NewItems[i].OnBeingAdded(_parent);                     // could throw
                } catch {
                    // Notify children that changes are being "undone"
                    for (int j = 0; j < i; j++)
                    {
                        try { e.NewItems[j].OnBeingRemoved(_parent); } catch { }
                    }
                    for (int j = e.Index; j < e.Index + removeCount; j++)
                    {
                        try { _list[i].OnBeingAdded(_parent); } catch { }
                    }
                    throw;
                }
            }
        }
コード例 #12
0
ファイル: LesLanguageService.cs プロジェクト: bel-uwa/Loyc
        public IListSource <LNode> Parse(IListSource <Token> input, ISourceFile file, IMessageSink msgs, Symbol inputType = null)
        {
            // For efficiency we'd prefer to re-use our _parser object, but
            // when parsing lazily, we can't re-use it because another parsing
            // operation could start before this one is finished. To force
            // greedy parsing, we can call ParseStmtsGreedy(), but the caller may
            // prefer lazy parsing, especially if the input is large. As a
            // compromise I'll check if the source file is larger than a
            // certain arbitrary size. Also, ParseExprs() is always greedy
            // so we can always re-use _parser in that case.
            bool exprMode = inputType == ParsingService.Exprs;
            char _        = '\0';

            if (inputType == ParsingService.Exprs || file.Text.TryGet(255, ref _))
            {
                LesParser parser = _parser;
                if (parser == null)
                {
                    _parser = parser = new LesParser(input, file, msgs);
                }
                else
                {
                    parser.MessageSink = msgs;
                    parser.Reset(input, file);
                }
                if (inputType == ParsingService.Exprs)
                {
                    return(parser.ParseExprs());
                }
                else
                {
                    return(parser.ParseStmtsGreedy());
                }
            }
            else
            {
                var parser = new LesParser(input, file, msgs);
                return(parser.ParseStmtsLazy().Buffered());
            }
        }
コード例 #13
0
 public static IEnumerable GetDataMember(IListSource dataSource, string dataMember)
 {
     IEnumerable enumerable = null;
     IList list = dataSource.GetList();
     if ((list != null) && (list is ITypedList))
     {
         if (!dataSource.ContainsListCollection)
         {
             if ((dataMember != null) && (dataMember.Length != 0))
             {
                 throw new ArgumentException(System.Design.SR.GetString("DesignTimeData_BadDataMember"));
             }
             return list;
         }
         PropertyDescriptorCollection itemProperties = ((ITypedList) list).GetItemProperties(new PropertyDescriptor[0]);
         if ((itemProperties == null) || (itemProperties.Count == 0))
         {
             return enumerable;
         }
         PropertyDescriptor descriptor = null;
         if ((dataMember == null) || (dataMember.Length == 0))
         {
             descriptor = itemProperties[0];
         }
         else
         {
             descriptor = itemProperties.Find(dataMember, true);
         }
         if (descriptor != null)
         {
             object component = list[0];
             object obj3 = descriptor.GetValue(component);
             if ((obj3 != null) && (obj3 is IEnumerable))
             {
                 enumerable = (IEnumerable) obj3;
             }
         }
     }
     return enumerable;
 }
コード例 #14
0
ファイル: ObjectAdapter.cs プロジェクト: vivsrane/TestReports
        private List <string> GetColumns(object source)
        {
            List <string> result;
            // first handle DataSet/DataTable
            object      innerSource;
            IListSource iListSource = source as IListSource;

            if (iListSource != null)
            {
                innerSource = iListSource.GetList();
            }
            else
            {
                innerSource = source;
            }

            DataView dataView = innerSource as DataView;

            if (dataView != null)
            {
                result = ScanDataView(dataView);
            }
            else
            {
                // now handle lists/arrays/collections
                IEnumerable iEnumerable = innerSource as IEnumerable;
                if (iEnumerable != null)
                {
                    Type childType = Utilities.GetChildItemType(
                        innerSource.GetType());
                    result = ScanObject(childType);
                }
                else
                {
                    // the source is a regular object
                    result = ScanObject(innerSource.GetType());
                }
            }
            return(result);
        }
コード例 #15
0
 public static IEnumerable ToIEnumerable(Object dataSource)
 {
     if (dataSource == null)
     {
         return(null);
     }
     if (dataSource is IListSource)
     {
         IListSource source = (IListSource)dataSource;
         IList       list   = source.GetList();
         if (!source.ContainsListCollection)
         {
             return(list);
         }
         if ((list != null) && (list is ITypedList))
         {
             PropertyDescriptorCollection itemProperties = ((ITypedList)list).GetItemProperties(new PropertyDescriptor[0]);
             if ((itemProperties == null) || (itemProperties.Count == 0))
             {
                 return(null);
             }
             PropertyDescriptor descriptor = itemProperties[0];
             if (descriptor != null)
             {
                 Object component = list[0];
                 Object value     = descriptor.GetValue(component);
                 if ((value != null) && (value is IEnumerable))
                 {
                     return((IEnumerable)value);
                 }
             }
             return(null);
         }
     }
     if (dataSource is IEnumerable)
     {
         return((IEnumerable)dataSource);
     }
     return(null);
 }
コード例 #16
0
        public IListSource <LNode> Parse(IListSource <Token> input, ISourceFile file, IMessageSink msgs, IParsingOptions options)
        {
            // For efficiency we'd prefer to re-use our _parser object, but
            // when parsing lazily, we can't re-use it because another parsing
            // operation could start before this one is finished. To force
            // greedy parsing, we can call ParseStmtsGreedy(), but the caller may
            // prefer lazy parsing, especially if the input is large. As a
            // compromise I'll check if the source file is larger than a
            // certain arbitrary size. Also, ParseExprs() is always greedy
            // so we can always re-use _parser in that case.
            bool exprMode = options.Mode == ParsingMode.Expressions;

            if (options.Mode == ParsingMode.Expressions || file.Text.TryGet(255).HasValue)
            {
                Les2Parser parser = _parser;
                if (parser == null)
                {
                    _parser = parser = new Les2Parser(input, file, msgs);
                }
                else
                {
                    parser.ErrorSink = msgs;
                    parser.Reset(input.AsList(), file);
                }
                if (options.Mode == ParsingMode.Expressions)
                {
                    return(parser.ExprList());
                }
                else
                {
                    return(parser.Start(new Holder <TokenType>(TokenType.Semicolon)).Buffered());
                }
            }
            else
            {
                var parser = new Les2Parser(input, file, msgs);
                return(parser.Start(new Holder <TokenType>(TokenType.Semicolon)).Buffered());
            }
        }
コード例 #17
0
        private List <string> GetColumns(object source)
        {
            List <string> result;

            object      innerSource;
            IListSource iListSource = source as IListSource;

            if (iListSource != null)
            {
                innerSource = iListSource.GetList();
            }
            else
            {
                innerSource = source;
            }

            DataView dataView = innerSource as DataView;

            if (dataView != null)
            {
                result = ScanDataView(dataView);
            }
            else
            {
                IEnumerable iEnumerable = innerSource as IEnumerable;
                if (iEnumerable != null)
                {
                    Type childType = Utilities.GetChildItemType(
                        innerSource.GetType());
                    result = ScanObject(childType);
                }
                else
                {
                    result = ScanObject(innerSource.GetType());
                }
            }
            return(result);
        }
コード例 #18
0
        // To recognize a scribble we require the simplified line to reverse
        // direction at least three times. There are separate criteria for
        // erasing a shape currently being drawn and for erasing existing
        // shapes.
        //
        // The key difference between an "erase scribble" and a "cancel
        // scribble" is that an erase scribble starts out as such, while
        // a cancel scribble indicates that the user changed his mind, so
        // the line will not appear to be a scribble at the beginning.
        // The difference is detected by timestamps. For example, the
        // following diagram represents an "erase" operation and a "cancel"
        // operation. Assume the input points are evenly spaced in time,
        // and that the dots represent points where the input reversed
        // direction.
        //
        // Input points         ..........................
        // Reversals (erase)      .  .  .  .     .     .
        // Reversals (cancel)              .   .   .   .
        //
        // So, a scribble is considered an erasure if it satisfies t0 < t1,
        // where t0 is the time between mouse-down and the first reversal,
        // and t1 is the time between the first and third reversals. A cancel
        // operation satisfies t0 > t1 instead.
        //
        // Both kinds of scribble need to satisfy the formula LL*c > CHA,
        // where c is a constant factor in pixels, LL is the drawn line
        // length and CHA is the area of the Convex Hull that outlines the
        // drawn figure. This formula basically detects that the user
        // is convering the same ground repeatedly; if the pen reverses
        // direction repeatedly but goes to new places each time, it's not
        // considered an erasure scribble. For a cancel scribble, LL is
        // computed starting from the first reversal.
        IEnumerable <Shape> RecognizeScribbleForEraseOrCancel(DragState state, out bool cancel, out List <PointT> simplifiedSS)
        {
            cancel       = false;
            simplifiedSS = null;
            var tolerance    = state._inputTransform.Transform(new VectorT(0, 10)).Length();
            var simplifiedMP = LineMath.SimplifyPolyline(
                state.UnfilteredMousePoints.Select(p => p.Point), tolerance);
            List <int> reversals = FindReversals(simplifiedMP, 3);

            if (reversals.Count >= 3)
            {
                simplifiedSS = simplifiedMP.Select(p => state._inputTransform.Transform(p)).ToList();
                // 3 reversals confirmed. Now decide: erase or cancel?
                int[] timeStampsMs = FindTimeStamps(state.UnfilteredMousePoints, simplifiedMP);
                int   t0 = timeStampsMs[reversals[0]], t1 = timeStampsMs[reversals[2]] - t0;
                cancel = t0 > t1 + 500;

                // Now test the formula LL*c > CHA as explained above
                IListSource <PointT> simplifiedMP_ = cancel ? simplifiedMP.Slice(reversals[0]) : simplifiedMP.AsListSource();
                float LL   = simplifiedMP_.AdjacentPairs().Sum(pair => pair.A.Sub(pair.B).Length());
                var   hull = PointMath.ComputeConvexHull(simplifiedMP);
                float CHA  = PolygonMath.PolygonArea(hull);
                if (LL * EraseNubWidth > CHA)
                {
                    // Erasure confirmed.
                    if (cancel)
                    {
                        return(EmptyList <Shape> .Value);
                    }

                    // Figure out which shapes to erase. To do this, we compute for
                    // each shape the amount of the scribble that overlaps that shape.
                    var simplifiedSS_ = simplifiedSS;
                    return(_doc.Shapes.Where(s => ShouldErase(s, simplifiedSS_)).ToList());
                }
            }
            return(null);
        }
コード例 #19
0
ファイル: MySqlAccesor.cs プロジェクト: obatatan/DocMag
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataTable"></param>
        /// <returns></returns>
        protected virtual string CreateValuesString(IListSource dataTable)
        {
            DataTable dt         = (DataTable)dataTable;
            var       rowStrList = new List <string>();

            foreach (var row in dt.Rows)
            {
                var colStrList = new List <string>();
                foreach (var col in dt.Columns)
                {
                    if (((DataColumn)col).DataType == typeof(String))
                    {
                        colStrList.Add($"'{((DataRow)row)[((DataColumn)col).ColumnName].ToString()}'");
                    }
                    else
                    {
                        colStrList.Add(((DataRow)row)[((DataColumn)col).ColumnName].ToString());
                    }
                }
                rowStrList.Add($"({string.Join(",", colStrList)})");
            }
            return(string.Join(",", rowStrList));
        }
コード例 #20
0
ファイル: AListInner.cs プロジェクト: sizzles/ecsharp
        public override AListNode <int, T> InsertRange(uint index, IListSource <T> source, ref int sourceIndex, out AListNode <int, T> splitRight, IAListTreeObserver <int, T> tob)
        {
            Debug.Assert(!IsFrozen);
            Entry e;
            int   i = PrepareToInsertAt(index + (uint)sourceIndex, out e, tob);

            // Perform the insert
            int oldSourceIndex = sourceIndex;
            AListNode <int, T> splitLeft;

            do
            {
                splitLeft = e.Node.InsertRange(index - e.Index, source, ref sourceIndex, out splitRight, tob);
            } while (sourceIndex < source.Count && splitLeft == null);

            // Adjust base index of nodes that follow
            int change = sourceIndex - oldSourceIndex;

            AdjustIndexesAfter(i, change);

            // Handle child split
            return(splitLeft == null ? null : HandleChildSplit(i, splitLeft, ref splitRight, tob));
        }
コード例 #21
0
ファイル: MySqlAccesor.cs プロジェクト: obatatan/DocMag
        ///<para>データをインサートします。</para>
        /// <para>指定したキーでデータが存在する場合、キー以外をアップデートする。</para>
        /// </summary>
        /// <param name="dataTable"></param>
        /// <returns>影響のあった行数(エラーの場合は-1を返却)</returns>
        public virtual int ExecuteDuplicateInsert(IListSource dataTable)
        {
            if (Status() != ConnectionState.Open)
            {
                if (Connect())
                {
                    return(-1);
                }
            }

            DataTable dt = (DataTable)dataTable;

            #region クエリ
            string query = $@"INSERT INTO
       {dt.TableName} ({CreateColumnsString(dataTable)})
   VALUES
       {CreateValuesString(dataTable)}
   ON DUPLICATE KEY UPDATE
        {CreateDuplicateUpdateString(dataTable)};";
            #endregion

            return(InsertOrUpdateOrDelete(query));
        }
コード例 #22
0
        public static string[] GetDataMembers(object dataSource)
        {
            IListSource source = dataSource as IListSource;

            if ((source != null) && source.ContainsListCollection)
            {
                ITypedList list = ((IListSource)dataSource).GetList() as ITypedList;
                if (list != null)
                {
                    PropertyDescriptorCollection itemProperties = list.GetItemProperties(new PropertyDescriptor[0]);
                    if (itemProperties != null)
                    {
                        ArrayList list3 = new ArrayList(itemProperties.Count);
                        foreach (PropertyDescriptor descriptor in itemProperties)
                        {
                            list3.Add(descriptor.Name);
                        }
                        return((string[])list3.ToArray(typeof(string)));
                    }
                }
            }
            return(null);
        }
コード例 #23
0
        public static int CopyTo <T>(this IListSource <T> c, T[] array, int arrayIndex)
        {
            int space = array.Length - arrayIndex;
            int count = c.Count;

            if (space < count)
            {
                if ((uint)arrayIndex >= (uint)count)
                {
                    throw new ArgumentOutOfRangeException("arrayIndex");
                }
                else
                {
                    throw new ArgumentException(string.Format("CopyTo: array is too small ({0} < {1})", space, count));
                }
            }

            for (int i = 0; i < count; i++)
            {
                array[arrayIndex + i] = c[i];
            }

            return(arrayIndex + count);
        }
コード例 #24
0
        public ListRegion(IListSource <T> source)
        {
            m_source        = source;
            source.Updated += () =>
            {
                m_scrollY           = 0;
                SelectedSourceIndex = null;
                Layout();
            };

            OnWheel += (_, delta) =>
            {
                if (delta < 0)
                {
                    ScrollY += ItemHeight * 2;
                }
                else
                {
                    ScrollY -= ItemHeight * 2;
                }
                if (ScrollY < 0)
                {
                    ScrollY = 0;
                }
                else if (ScrollY > MaxScrollY)
                {
                    ScrollY = MaxScrollY;
                }
                Layout();
            };

            ItemLeftClicked += (i, content) =>
            {
                // Todo: select
            };
        }
コード例 #25
0
ファイル: EcsTriviaInjector.cs プロジェクト: qwertie/ecsharp
		public EcsTriviaInjector(IListSource<Token> sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix) 
			: base(sortedTrivia, sourceFile, newlineTypeInt, mlCommentPrefix, mlCommentSuffix, slCommentPrefix)
		{
		}
 public ListSourceDataSourceItem(string dataSourceName, IListSource runtimeListSource) : base(dataSourceName, null)
 {
     this.runtimeListSource = runtimeListSource;
 }
コード例 #27
0
 public ReversedListSource(IListSource <T> list)
 {
     _list = list;
 }
コード例 #28
0
 public SelectNegListSources(IListSource <T> list)
 {
     _list = list;
 }
コード例 #29
0
 /// <summary>Inserts a list of items at the specified index. This method
 /// may not insert all items at once, so there is a sourceIndex parameter
 /// which points to the next item to be inserted. When sourceIndex reaches
 /// source.Count, the insertion is complete.</summary>
 /// <param name="index">The index at which to insert the contents of
 /// source. Important: if sourceIndex > 0, insertion of the remaining
 /// items starts at [index + sourceIndex].</param>
 /// <returns>Returns non-null if the node is split, as explained
 /// in the documentation of <see cref="Insert"/>.</returns>
 /// <remarks>This method can only be called for ALists, since other tree
 /// types don't allow insertion at a specific index.</remarks>
 /// <exception cref="NotSupportedException">This node does not allow insertion at an arbitrary location (e.g. BList node).</exception>
 public virtual AListNode <K, T> InsertRange(uint index, IListSource <T> source, ref int sourceIndex, out AListNode <K, T> splitRight, IAListTreeObserver <K, T> tob)
 {
     throw new NotSupportedException();
 }
コード例 #30
0
ファイル: ListSourceAsSparse.cs プロジェクト: sizzles/ecsharp
 public ListSourceAsSparse(Loyc.Collections.IListSource <T> list)
 {
     _list = list;
 }
コード例 #31
0
ファイル: IParsingService.cs プロジェクト: jonathanvdc/Loyc
		static LNode Single(IListSource<LNode> e)
		{
			LNode node = e.TryGet(0, null);
			if (node == null)
				throw new InvalidOperationException(Localize.Localized("ParseSingle: result was empty."));
			if (e.TryGet(1, null) != null) // don't call Count because e is typically Buffered()
				throw new InvalidOperationException(Localize.Localized("ParseSingle: multiple parse results."));
			return node;
		}
コード例 #32
0
			public IListSource<DragPoint> ToShapeSpace(IListSource<DragPoint> mousePoints)
			{
				return mousePoints.Select(dp => new DragPoint(dp, _inputTransform));
			}
コード例 #33
0
		private static int[] FindTimeStamps(IListSource<DragPoint> original, List<PointT> simplified)
		{
			int o = -1, timeMs = 0;
			int[] times = new int[simplified.Count];
			for (int s = 0; s < simplified.Count; s++)
			{
				var p = simplified[s];
				do
				{
					o++;
					timeMs += original[o].MsecSincePrev;
				} while (original[o].Point != p);
				times[s] = timeMs;
			}
			return times;
		}
コード例 #34
0
ファイル: TestHelpers.cs プロジェクト: bel-uwa/Loyc
 protected static void ExpectList <T>(IListSource <T> list, bool useEnumerator, params T[] expected)
 {
     ExpectList(list, expected as IList <T>, useEnumerator);
 }
コード例 #35
0
ファイル: ListSourceAsSparse.cs プロジェクト: sizzles/ecsharp
 /// <summary>Treats a non-sparse list as a read-only sparse list with no empty
 /// spaces.</summary>
 public static ListSourceAsSparse <T> AsSparse <T>(this IListSource <T> list)
 {
     return(new ListSourceAsSparse <T>(list));
 }
コード例 #36
0
ファイル: Vector.cs プロジェクト: pirzada/sinapse
 public Vector(IListSource values)
     : this(values.GetList())
 {
 }
コード例 #37
0
ファイル: EcsTriviaInjector.cs プロジェクト: dadhi/ecsharp
 public EcsTriviaInjector(IListSource <Token> sortedTrivia, ISourceFile sourceFile, int newlineTypeInt, string mlCommentPrefix, string mlCommentSuffix, string slCommentPrefix, bool topLevelIsBlock)
     : base(sortedTrivia, sourceFile, newlineTypeInt, mlCommentPrefix, mlCommentSuffix, slCommentPrefix, topLevelIsBlock)
 {
 }
コード例 #38
0
ファイル: DesignTimeData.cs プロジェクト: Profit0004/mono
		public static IEnumerable GetDataMember (IListSource dataSource, string dataMember)
		{
			throw new NotImplementedException ();
		}
コード例 #39
0
 public static SelectNegListSources <T> NegLists <T>(this IListSource <T> source)
 {
     return(new SelectNegListSources <T>(source));
 }
コード例 #40
0
ファイル: SampleVector.cs プロジェクト: pirzada/sinapse
 public SampleVector(IListSource values)
     : base(values)
 {
 }
コード例 #41
0
 // Resolves the "ambiguity" between IListSource[i] and IList[i].
 protected static T At <T>(IListSource <T> list, int i)
 {
     return(list[i]);
 }
コード例 #42
0
ファイル: EcsLanguageService.cs プロジェクト: qwertie/ecsharp
		public IListSource<LNode> Parse(IListSource<Token> input, ISourceFile file, IMessageSink msgs, ParsingMode inputType = null)
		{
			// For efficiency we'd prefer to re-use our _parser object, but
			// when parsing lazily, we can't re-use it because another parsing 
			// operation could start before this one is finished. To force 
			// greedy parsing, we can call ParseStmtsGreedy(), but the caller may 
			// prefer lazy parsing, especially if the input is large. As a 
			// compromise I'll check if the source file is larger than a 
			// certain arbitrary size. Also, ParseExprs() is always greedy 
			// so we can always re-use _parser in that case.
			char _ = '\0';
			if (file.Text.TryGet(255, ref _) || inputType == ParsingMode.FormalArguments || 
				inputType == ParsingMode.Types || inputType == ParsingMode.Expressions)
			{
				EcsParser parser = _parser;
				if (parser == null)
					_parser = parser = new EcsParser(input, file, msgs);
				else {
					parser.ErrorSink = msgs ?? MessageSink.Default;
					parser.Reset(input, file);
				}
				if (inputType == ParsingMode.Expressions)
					return parser.ParseExprs(false, allowUnassignedVarDecl: false);
				else if (inputType == ParsingMode.FormalArguments)
					return parser.ParseExprs(false, allowUnassignedVarDecl: true);
				else if (inputType == ParsingMode.Types)
					return LNode.List(parser.DataType());
				else
					return parser.ParseStmtsGreedy();
			}
			else
			{
				var parser = new EcsParser(input, file, msgs);
				return parser.ParseStmtsLazy().Buffered();
			}
		}
コード例 #43
0
ファイル: DataSourceHelper.cs プロジェクト: dox0/DotNet471RS3
        internal static IEnumerable GetResolvedDataSource(Object dataSource, String dataMember)
        {
            if (dataSource == null)
            {
                return(null);
            }

            IListSource listSource = dataSource as IListSource;

            if (listSource != null)
            {
                IList memberList = listSource.GetList();

                if (listSource.ContainsListCollection == false)
                {
                    // The returned list is itself the list we need to bind to.
                    // (Ignore DataMember parameter.)
                    return((IEnumerable)memberList);
                }

                if ((memberList != null) && (memberList is ITypedList))
                {
                    ITypedList typedMemberList = (ITypedList)memberList;

                    PropertyDescriptorCollection propDescs =
                        typedMemberList.GetItemProperties(new PropertyDescriptor[0]);
                    if ((propDescs != null) && (propDescs.Count != 0))
                    {
                        PropertyDescriptor listProperty = null;

                        if ((dataMember == null) || (dataMember.Length == 0))
                        {
                            listProperty = propDescs[0];
                        }
                        else
                        {
                            listProperty = propDescs.Find(dataMember, true);
                        }

                        if (listProperty != null)
                        {
                            Object listRow = memberList[0];
                            Object list    = listProperty.GetValue(listRow);

                            if ((list != null) && (list is IEnumerable))
                            {
                                return((IEnumerable)list);
                            }
                        }

                        throw new ArgumentException(
                                  SR.GetString(SR.DataSourceHelper_MissingDataMember,
                                               dataMember));
                    }
                    else
                    {
                        throw new ArgumentException(
                                  SR.GetString(SR.DataSourceHelper_DataSourceWithoutDataMember,
                                               "List DataSource"));
                    }
                }
            }

            if (dataSource is IEnumerable)
            {
                return((IEnumerable)dataSource);
            }

            return(null);
        }
コード例 #44
0
 internal ListSourceDataSourceItem(string dataSourceName, IListSource runtimeListSource)
     : base(dataSourceName, null)
 {
     this._runtimeListSource = runtimeListSource;
 }