当前位置: 首页>>代码示例>>C#>>正文


C# Function.Clear方法代码示例

本文整理汇总了C#中System.Function.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Function.Clear方法的具体用法?C# Function.Clear怎么用?C# Function.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Function的用法示例。


在下文中一共展示了Function.Clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClearFunctionThatIsBoundToDecorator

        public void ClearFunctionThatIsBoundToDecorator()
        {
            IFunction function = new Function("time series");

            function.Arguments.Add(new Variable<DateTime>("time"));
            function.Components.Add(new Variable<double>("water_discharge"));

            // set initial values
            DateTime time1 = DateTime.Now;
            DateTime time2 = time1.AddMinutes(1);
            DateTime time3 = time2.AddMinutes(1);
            function[time1] = 0.0;
            function[time2] = 1.0;
            function[time3] = 2.0;

            ILineChartSeries lineChartSeries = ChartSeriesFactory.CreateLineSeries();

            lineChartSeries.XValuesDataMember = function.Arguments[0].DisplayName;
            lineChartSeries.YValuesDataMember = function.Components[0].DisplayName;

            var control = new Control();
            WindowsFormsTestHelper.Show(control);

            var functionBindingList = new FunctionBindingList(function) { SynchronizeInvoke = control };
            lineChartSeries.DataSource = functionBindingList;
            
            function.Clear();

            while(functionBindingList.IsProcessing)
            {
                Application.DoEvents();
            }

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:TeeChartSeriesDecoratorTest.cs

示例2: UpdateGridValues

 /// <summary>
 /// Fills gridvalues function with profiledata based on profileline over the grid
 /// </summary>
 /// <param name="function"></param>
 /// <param name="grid"></param>
 /// <param name="polyline"></param>
 public static void UpdateGridValues(Function function, IRegularGridCoverage grid, ILineString polyline)
 {
     function.Clear();
     double offset = 0;
     double step = polyline.Length / 100;
     foreach (ICoordinate coordinate in GetGridProfileCoordinates(polyline, step))
     {
         function[offset] = grid.Evaluate(coordinate);
         offset += step;
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:RegularGridCoverageHelper.cs

示例3: CheckFunctionValuesChangedConsistency

 public void CheckFunctionValuesChangedConsistency()
 {
     //assert we only get a FunctionValuesChanged event when the function is consistent.
     IFunction func = new Function();
     IVariable x = new Variable<int>("x");
     IVariable y = new Variable<int>("y");
     func.Arguments.Add(x);
     func.Components.Add(y);
     func[0] = 2;
     func.Store.FunctionValuesChanged += delegate
                                             {
                                                 Assert.IsTrue(func.Components[0].Values.Count == func.Arguments[0].Values.Count);
                                             };
     func.Clear();
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:MemoryFunctionStoreTest.cs

示例4: Clear

        public void Clear()
        {
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");

            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Components.Add(y);

            f.SetValues(new[] {100.0, 200.0, 300.0}, new VariableValueFilter<double>(x, new[] {1.0, 2.0, 3.0}));

            IList values = f.GetValues();
            Assert.AreEqual(3, values.Count);

            f.Clear();
            Assert.AreEqual(0, values.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:FunctionTest.cs

示例5: AddManyFunctionValuesWithBindingListShouldBeFast

        public void AddManyFunctionValuesWithBindingListShouldBeFast()
        {
            var f = new Function
                        {
                            Arguments = {new Variable<double>("x")}, 
                            Components = {new Variable<double>("y")}
                        };

            var values = Enumerable.Range(0, 1000).Select(i => (double)i);

            // first time is slower so we add/clear values a few times first
            f.SetValues(values, new VariableValueFilter<double>(f.Arguments[0], values));
            f.Clear();
            f.SetValues(values, new VariableValueFilter<double>(f.Arguments[0], values));
            f.Clear();

            // measure overhead (add values to function)
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            AddValuesWithoutBindingList(f, values);
            stopwatch.Stop();

            var overhead = stopwatch.ElapsedMilliseconds;
            log.DebugFormat("Added 1000 values to function in {0} ms", overhead);

            f.Clear();

            // add values with FunctionBindingList
            new FunctionBindingList(f);

            stopwatch.Reset();
            stopwatch.Start();
            AddValuesWithBindingList(f, values);
            stopwatch.Stop();

            log.DebugFormat("Added 1000 values to function wrapped with a binding list in {0} ms, {1}x slower", stopwatch.ElapsedMilliseconds, (stopwatch.ElapsedMilliseconds / (double)overhead));

            (stopwatch.ElapsedMilliseconds - overhead)
                .Should("Updating binding list should be fast").Be.LessThan(50);

            (stopwatch.ElapsedMilliseconds / (double)overhead)
                .Should("Setting values to function with function binding list should be almost as fast as without it")
                    .Be.LessThan(4);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:44,代码来源:FunctionBindingListTest.cs

示例6: ClearSourceFunctionShouldClearFilteredBindingList

        public void ClearSourceFunctionShouldClearFilteredBindingList()
        {
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x")},
                Components = { new Variable<int>("f") }
            };

            function[1] = 1;
            function[2] = 4;

            var filteredFunction = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 1 }));

            IFunctionBindingList functionBindingList = new FunctionBindingList { Function = filteredFunction };

            functionBindingList.Count
                .Should().Be.EqualTo(1);

            function.Clear();

            functionBindingList.Count
                .Should().Be.EqualTo(0);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:23,代码来源:FunctionBindingListTest.cs

示例7: ClearSourceFunctionShouldClearBindingList

        public void ClearSourceFunctionShouldClearBindingList()
        {
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x") },
                Components = { new Variable<int>("f") }
            };

            function[1] = 1;
            function[2] = 4;

            var functionBindingList = new FunctionBindingList {Function = function};

            functionBindingList.Count
                .Should().Be.EqualTo(2);

            function.Clear();

            // wait until binding list is actually cleared.
            WaitUntilLastOperationIsFinished(functionBindingList);

            functionBindingList.Count
                .Should().Be.EqualTo(0);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:FunctionBindingListTest.cs

示例8: ClearFunction_ShouldNotClearAttributes

        public void ClearFunction_ShouldNotClearAttributes()
        {
            // setup
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");
            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Components.Add(y);
            string kie = "kie";
            string expected = "veljoe";
            f.Attributes[kie] = expected;
            f.Components[0].Attributes[kie] = expected;

            f.SetValues(new[] { 100.0, 200.0, 300.0 }, new VariableValueFilter<double>(x, new[] { 1.0, 2.0, 3.0 }));

            // call
            f.Clear();

            // check
            Assert.AreEqual(0, f.GetValues().Count);
            var funcVal = f.Attributes[kie];
            Assert.AreEqual(expected,funcVal);
            var val = f.Components[0].Attributes[kie];
            Assert.AreEqual(expected,val);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FunctionTest.cs

示例9: UpdateProfileFunctionValues

        /// <summary>
        /// Fills gridvalues function with profiledata based on profileline over the grid
        /// </summary>
        /// <param name="function"></param>
        /// <param name="coverage"></param>
        /// <param name="polyline"></param>
        /// <param name="resolution">Defines the sample resolution along <paramref name="polyline"/> (each resolution step a sample).
        /// Null will cause 101 samples to be take along the line uniformly.</param>
        /// <exception cref="ArgumentException">When <paramref name="resolution"/> is 0.0 or less.</exception> 
        public static void UpdateProfileFunctionValues(Function function, ICoverage coverage, ILineString polyline, DateTime? time, double? resolution = null)
        {
            // when coverage is empty (has no times), we cannot call Evaluate below...
            if (time != null && time.Equals(default(DateTime))) return;

            function.Clear();
            double offset = 0;
            double step = resolution ?? polyline.Length / 100;
            var gridProfileCoordinates = GetGridProfileCoordinates(polyline, step).ToArray();
            foreach (ICoordinate coordinate in gridProfileCoordinates)
            {
                var value = time != null ? coverage.Evaluate(coordinate, time.Value) : coverage.Evaluate(coordinate);
                if (value == null)
                {
                    offset += step;
                    continue;
                }
                function[offset] = value;
                offset += step;
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:30,代码来源:CoverageProfile.cs


注:本文中的System.Function.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。