コード例 #1
0
 public static unsafe void Add <TElement>(this IAdd <TElement> collection, TElement *elements, Int32 length) where TElement : unmanaged
 {
     for (Int32 i = 0; i < length; i++)
     {
         collection.Add(elements[i]);
     }
 }
コード例 #2
0
 public static void AddAll <T>(this IAdd <T> collection, IEnumerable <T> items)
 {
     foreach (var item in items)
     {
         collection.Add(item);
     }
 }
コード例 #3
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement>(this IAdd <TElement> collection, ReadOnlySpan <TElement> elements)
 {
     for (Int32 i = 0; i < elements.Length; i++)
     {
         collection.Add(elements[i]);
     }
 }
コード例 #4
0
 public static int ExecuteNonQuery <T>(this IAdd <T> message) where T : class, new()
 {
     using (var context = DataContext.CreateForMessage(message))
     {
         return(ExecuteNonQuery <T>(message, context));
     }
 }
コード例 #5
0
        /// <summary>
        /// Метод добавляет клиента в банка (физ. лицо или юр.лицо)
        /// </summary>
        /// <param name="add_window"></param>
        public static void AddClient(IAdd add_window)
        {
            switch (MW.clientType())
            {
            case "PHYS":
                add_window.ITitle          = "Добавление нового физ.лица";
                add_window.nameText        = "Имя";
                add_window.lastNameText    = "Фамилия";
                add_window.dateText        = "Дата рождения";
                add_window.third_string_on = true;
                break;

            case "COMPANY":
                add_window.ITitle          = "Добавление нового юр.лица";
                add_window.nameText        = "Название";
                add_window.lastNameText    = "-";
                add_window.dateText        = "Дата создания";
                add_window.third_string_on = !true;
                break;

            default:
                MessageBox.Show("Не выбран тип клиент с которым следует работать");
                return;
            }

            if (add_window.IShowDialog)
            {
                MW.ClientSource = model.ClientsCreator(add_window.dateString, add_window.fullNameString, MW.clientType(), MW.ParentID);
            }
            else
            {
                MessageBox.Show("Новый клиент не создан");
            }
        }
コード例 #6
0
ファイル: Les2SyntaxForVs.cs プロジェクト: sizzles/ecsharp
 public MyLesParser(IListSource <Token> tokens, TextSnapshotAsSourceFile file,
                    IMessageSink messageSink, IAdd <ITagSpan <ClassificationTag> > results)
     : base(tokens, file, messageSink)
 {
     _file    = file;
     _results = results;
 }
コード例 #7
0
 public OperationController(IAdd add, IMult mult, IDiv div, ISub sub, ILogger <OperationController> logger)
 {
     _add    = add;
     _mult   = mult;
     _div    = div;
     _sub    = sub;
     _logger = logger;
 }
コード例 #8
0
ファイル: LinkedListTest.cs プロジェクト: riezebosch/minor
 void VulLijstMetHonden(IAdd <Hond> list)
 {
     list.Add(new Hond {
         Aaibaarheid = 9
     });
     list.Add(new Hond {
         Aaibaarheid = 12
     });
 }
コード例 #9
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement>(this IAdd <TElement> collection, Collections.Generic.IEnumerable <TElement>?elements)
 {
     if (elements is not null)
     {
         foreach (TElement element in elements)
         {
             collection.Add(element);
         }
     }
 }
コード例 #10
0
        public void Create_ForAddIsNull_Throws()
        {
            _add = null;

            Action action = () => CreateSut();

            action.Should()
            .Throw <ArgumentNullException>()
            .WithParameter("add");
        }
コード例 #11
0
 /// <summary>
 /// Adds the elements to this collection, one by one.
 /// </summary>
 /// <typeparam name="TElement">The type of the elements in the collection.</typeparam>
 /// <typeparam name="TEnumerator">The type of the enumerator of the <paramref name="elements"/>.</typeparam>
 /// <param name="collection">This collection.</param>
 /// <param name="elements">The elements to add.</param>
 /// <remarks>
 /// The behavior of this operation is type dependent, and no particular location in the collection should be assumed. It is further possible the type the element is added to is not a collection.
 /// </remarks>
 public static void Add <TElement, TEnumerator>(this IAdd <TElement> collection, IGetEnumerator <TElement, TEnumerator>?elements) where TEnumerator : notnull, ICurrent <TElement>, IMoveNext
 {
     if (elements is not null)
     {
         foreach (TElement element in elements)
         {
             collection.Add(element);
         }
     }
 }
コード例 #12
0
        public virtual void Add(IAdd item)//添加组件
        {
            AbstractComponent component = item as AbstractComponent;

            if (component != null)
            {
                component.Owner = this;
                ChildComponents.Add(item);
            }
        }
コード例 #13
0
 internal void RefreshTable(string path, IAdd data, DataGrid grid)
 {
     using (var textTab = File.OpenText(path))
     {
         while (!textTab.EndOfStream)
         {
             grid.Items.Add(data.Create(textTab.ReadLine().Split(';')));
         }
     }
 }
コード例 #14
0
        public override void Add(IAdd item)
        {
            base.Add(item);
            IPathAndName pathItem = item as IPathAndName;

            if (pathItem != null)
            {
                pathItem.Path = this.Path + "_" + pathItem.Name;
            }
        }
コード例 #15
0
        public Calculator([NotNull] IAdd add,
                          [NotNull] ISubtract subtract)
        {
            Guard.ArgumentNotNull(add,
                                  nameof(add));
            Guard.ArgumentNotNull(subtract,
                                  nameof(subtract));

            _add      = add;
            _subtract = subtract;
        }
コード例 #16
0
        public static IAdd AddItems(IAdd addCollection, string[] input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                Console.Write(addCollection.Add(input[i]) + " ");
            }

            Console.WriteLine();

            return(addCollection);
        }
コード例 #17
0
ファイル: Profiling.cs プロジェクト: chrinide/bohrium
        //Static initialization of the lambda function + creation of the class instance
        static Profiling()
        {
            ParameterExpression paramA = Expression.Parameter(typeof(T), "a"),
                                paramB = Expression.Parameter(typeof(T), "b");

            BinaryExpression body = Expression.Add(paramA, paramB);

            dynamic_lambda_add = Expression.Lambda <Func <T, T, T> >(body, paramA, paramB).Compile();

            virtual_add = new vAdd();
        }
コード例 #18
0
ファイル: AddFormPresenter.cs プロジェクト: IskraKate/.net-db
        public AddFormPresenter(IAdd add)
        {
            _model = Model.GetModel;
            _add   = add;

            _add.AddEvent           += FillAddFormEvent;
            _add.BuyersUpdateEvent  += BuyersOnUpdate;
            _add.SellersUpdateEvent += SellersOnUpdate;
            _add.FridgesUdateEvent  += FridgesOnUpdate;
            _add.AddCheckEvent      += _add_AddCheck;
        }
コード例 #19
0
ファイル: StartUp.cs プロジェクト: vesy53/SoftUni
        private static void AddInCollections(
            IAdd collection,
            string[] input)
        {
            foreach (string element in input)
            {
                Console.Write(
                    $"{collection.AddElement(element)} ");
            }

            Console.WriteLine();
        }
コード例 #20
0
        public void Add_ForNumbers_Adds(Calculator sut,
                                        [Freeze] IAdd add)
        {
            add.Execute(1,
                        2)
            .Returns(3);

            sut.Add(1,
                    2)
            .Should()
            .Be(3);
        }
コード例 #21
0
        public static int ExecuteNonQuery <T>(this IAdd <T> message, DataContext context) where T : class, new()
        {
            // Step 1. Create new entity
            T entity = new T();

            // Step 2. Map from message
            entity.InjectFrom <CommonValueInjection>(message);

            // Step 3. Add entity
            context.Set <T>().Add(entity);

            return(context.SaveChanges());
        }
コード例 #22
0
        public void Create_ForAddIsNull_Throws(Lazy <Calculator> sut,
                                               [BeNull] IAdd add)
        {
            // ReSharper disable once UnusedVariable
            Action action = () =>
            {
                var actual = sut.Value;
            };

            action.Should()
            .Throw <ArgumentNullException>()
            .WithParameter("add");
        }
コード例 #23
0
        void RunDictionarySizeBenchmarks(IAdd <EzDataPoint> graph, string id, string yAxis, bool perItem)
        {
            _graphConfiguration[id] = plotModel => {
                AddStandardAxes(plotModel, yAxis, 0, yMaximum: perItem ? 100 : (int?)null);
                if (perItem)
                {
                    plotModel.LegendPosition = LegendPosition.TopRight;
                }
            };
            int limit = perItem ? 9999 : 133;

            for (int size = 1; size <= limit; size += Math.Max(1, size / 8))
            {
                double factor = perItem ? 1.0 / size : 1.0;

                var dict  = FillDictionary(new Dictionary <long, long>(), size, false);
                var dictR = FillDictionary(new Dictionary <long, long>(), size, true);
                //graph.Add(new EzDataPoint { GraphId = id, Series = "Dictionary<long,long> (sequential fill)", Parameter = size, Value = CountSizeInBytes(dict, 16) * factor });
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "Dictionary<long,long>", Parameter = size, Value = CountSizeInBytes(dictR, 16) * factor
                });

                var sdictR = FillDictionary(new SortedDictionary <long, long>(), size, true);
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "SortedDictionary<long,long>", Parameter = size, Value = CountSizeInBytes(sdictR, 16) * factor
                });

                if (TestALists)
                {
                    var bdict  = FillDictionary(new BDictionary <long, long>(), size, false);
                    var bdictR = FillDictionary(new BDictionary <long, long>(), size, true);
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "BDictionary<long,long> (sequential fill)", Parameter = size, Value = bdict.CountSizeInBytes(16, 8) * factor });
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "BDictionary<long,long> (random fill)", Parameter = size, Value = bdictR.CountSizeInBytes(16, 8) * factor
                    });
                }

                if (TestOther)
                {
                    var map  = FillDictionary(new MMap <long, long>(), size, false);
                    var mapR = FillDictionary(new MMap <long, long>(), size, true);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "MMap<long,long> (sequential fill)", Parameter = size, Value = map.CountMemory(16) * factor
                    });
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "MMap<long,long> (random fill)", Parameter = size, Value = mapR.CountMemory(16) * factor
                    });
                }
            }
        }
コード例 #24
0
        void RunListSizeBenchmarks(IAdd <EzDataPoint> graph, string id, string yAxis, bool perItem)
        {
            _graphConfiguration[id] = plotModel => {
                AddStandardAxes(plotModel, yAxis, 0, yMaximum: perItem ? 60 : (int?)null);
                if (perItem)
                {
                    plotModel.LegendPosition = LegendPosition.TopRight;
                }
            };
            int limit = perItem ? 9999 : 133;

            for (int size = 1; size <= limit; size += Math.Max(1, size / 8))
            {
                double factor = perItem ? 1.0 / size : 1.0;

                var list  = AddAtEnd(new List <long>(), size);
                var lList = AddAtEnd(new LinkedList <long>(), size);
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "List<long>", Parameter = size, Value = CountSizeInBytes(list, 8) * factor
                });
                graph.Add(new EzDataPoint {
                    GraphId = id, Series = "LinkedList<long>", Parameter = size, Value = CountSizeInBytes(lList, 8) * factor
                });

                if (TestALists)
                {
                    var alist  = AddAtEnd(new AList <long>(), size);
                    var alistR = AddAtRandom(new AList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "AList<long> (sequential fill)", Parameter = size, Value = alist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "AList<long> (random fill)", Parameter = size, Value = alistR.CountSizeInBytes(8) * factor });
                    var salist  = AddAtEnd(new SparseAList <long>(), size);
                    var salistR = AddAtRandom(new SparseAList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "SparseAList<long> (sequential fill)", Parameter = size, Value = salist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "SparseAList<long> (random fill)", Parameter = size, Value = salistR.CountSizeInBytes(8) * factor });
                }
                if (TestOther)
                {
                    var ialist  = AddAtEnd(new IndexedAList <long>(), size);
                    var ialistR = AddAtRandom(new IndexedAList <long>(), size);
                    graph.Add(new EzDataPoint {
                        GraphId = id, Series = "IndexedAList<long> (sequential fill)", Parameter = size, Value = ialist.CountSizeInBytes(8) * factor
                    });
                    //graph.Add(new EzDataPoint { GraphId = id, Series = "IndexedAList<long> (random fill)", Parameter = size, Value = ialistR.CountSizeInBytes(8) * factor });
                }
            }
        }
コード例 #25
0
        static void Main(string[] args)
        {
            Test t = new Test(3);

            t.Add();
            Console.WriteLine(t.n);
            Console.Beep();

            IAdd iadd = t;

            iadd.Add();
            Console.WriteLine(t.n);


            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(a);
        }
コード例 #26
0
ファイル: DBUtil.cs プロジェクト: chrimc62/EntityMatch
        public static void BuildFromDatabase(string server, string db, string table, string column, IAdd t)
        {
            DuplicateDetector.Clear();
            t.BeginUpdate();
            SqlConnection connection = new SqlConnection(Util.GetConnectionString(server, db));
            connection.Open();
            string q = TrieQuery(db, table, column);
            SqlCommand sqlcmd = new SqlCommand(q, connection);
            sqlcmd.CommandTimeout = 0;

            int count = 0;
            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    count++;
                    if (count == 10)
                    {
                        Console.Write("");
                        //break;
                    }
                    string s = reader.GetString(0);
                    if (DuplicateDetector.ContainsKey(s))
                    {
                        if (count % 10000 == 0)
                        {
                            Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                        }
                        continue;
                    }
                    DuplicateDetector.Add(s, true);
                    t.Add(s);
                    if (count % 10000 == 0)
                    {
                        Console.WriteLine("{1}: Inserted {0} records", count, DateTime.Now);
                    }
                }
            }
            connection.Close();
            t.EndUpdate();
        }
コード例 #27
0
        public void Run(EzChartForm graph = null, Predicate <EzDataPoint> where = null)
        {
            Benchmarker b = new Benchmarker(1);

            _graph = graph;
            _where = null;

                        #if !DotNet35
            graph.InitDefaultModel = (id, model) =>
            {
                model.LegendPosition = LegendPosition.TopLeft;
                model.PlotMargins    = new OxyThickness(double.NaN, double.NaN, 12, double.NaN);              // avoid cutting off "1000000" (NaN=autodetect)
                model.Axes.Add(new LogarithmicAxis {
                    Position           = AxisPosition.Bottom,
                    Title              = "List size",
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot
                });
                int X = id.ToString().StartsWith("Scan by") ? StdIterations * 100 : StdIterations;
                model.Axes.Add(new LinearAxis {
                    Position           = AxisPosition.Left,
                    Title              = string.Format("Milliseconds to perform {0:n0} iterations", X),
                    MajorGridlineStyle = LineStyle.Solid,
                    MinorGridlineStyle = LineStyle.Dot,
                    Minimum            = -1,
                });
            };
                        #endif

            Run(b, 30);
            Run(b, 100);
            Run(b, 300);
            Run(b, 1000);
            Run(b, 3000);
            Run(b, 10000);
            Run(b, 30000);
            Run(b, 100000);
            Run(b, 300000);
            Run(b, 1000000);
            //Run(b, 3000000);
        }
コード例 #28
0
        public void Run(EzChartForm graph = null, Predicate <EzDataPoint> where = null)
        {
            Benchmarker b = new Benchmarker(1);

            _graph = graph;
            _where = null;

            graph.InitDefaultModel = (id, plotModel) =>
            {
                plotModel.LegendPosition = LegendPosition.TopLeft;
                plotModel.PlotMargins    = new OxyThickness(double.NaN, double.NaN, 12, double.NaN);              // avoid cutting off "1000000" (NaN=autodetect)
                if (_graphConfiguration.TryGetValue(id, out var action))
                {
                    action(plotModel);
                }
                else
                {
                    AddStandardAxes(plotModel, string.Format("Milliseconds to perform {0:n0} iterations", StdIterations), yMinimum: 0);
                }
            };

            _r = new Random(_seed);
            RunListSizeBenchmarks(_graph, "Bytes used per list item", "Bytes used per 8-byte item", true);
            RunListSizeBenchmarks(_graph, "Bytes used per list", "Total heap bytes", false);
            RunDictionarySizeBenchmarks(_graph, "Bytes per dictionary pair", "Bytes used per 16-byte item", true);
            RunDictionarySizeBenchmarks(_graph, "Bytes per dictionary", "Total heap bytes", false);

            Run(b, 30);
            Run(b, 100);
            Run(b, 300);
            Run(b, 1000);
            Run(b, 3000);
            Run(b, 10000);
            Run(b, 30000);
            Run(b, 100000);
            Run(b, 300000);
            Run(b, 1000000);
            //Run(b, 3000000);
        }
コード例 #29
0
 /// <inheritdoc/>
 protected internal override void Neglect(ReadOnlySpan <Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd <Capture> trace)
 {
     exception = null;
     for (Int32 i = 0; i < Count; i++)
     {
         Pattern.Neglect(source, ref location, out exception, trace);
         if (exception is not null)
         {
             return;
         }
     }
 }
コード例 #30
0
 public void TestInitialize()
 {
     _add      = Substitute.For <IAdd>();
     _subtract = Substitute.For <ISubtract>();
 }
コード例 #31
0
ファイル: Concatenator.cs プロジェクト: Entomy/LibLangly
 /// <inheritdoc/>
 protected internal override void Neglect(ReadOnlySpan <Char> source, ref Int32 location, [AllowNull, MaybeNull] out Exception exception, [AllowNull] IAdd <Capture> trace)
 {
     Left.Neglect(source, ref location, out exception, trace);
     if (exception is null)
     {
         return;
     }
     Right.Neglect(source, ref location, out exception, trace);
 }
コード例 #32
0
ファイル: Mapper.cs プロジェクト: Zananok/Harmonize
 private Message PerformMapping(IAdd source)
 {
     return Mapping.Map<IAdd, Add>(source);
 }
コード例 #33
0
ファイル: Calculator.cs プロジェクト: jrjohn/Grace
		public Calculator(IAdd add)
		{
			this.add = add;
		}
コード例 #34
0
ファイル: Program.cs プロジェクト: ngnono/DotNetFramework
 public Test(IAdd add)
 {
     this.add = add;
 }