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


C# Data.Add方法代码示例

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


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

示例1: Process

        //Chris Han add DeviceId to Json
        public async Task<DataSet> Process(DataSet dataset, CancellationToken ct, string DeviceId)
        {
#if AggravatedSerialization
            //Serialize the whole dataset as single json string
            var json = await Task.Factory.StartNew(
                new Func<object, string>(JsonConvert.SerializeObject),
                dataset,
                ct);

            var data = new Data();
            data.Add("stringContent", json);

            var output = new DataSet();
            output.Add(data);
            return output;

#else
            //Serialize each data as one json string
            foreach (var data in dataset)
            {
                data["DeviceId"] = DeviceId;//Chris han add DeviceId to Json
                var json = await Task.Factory.StartNew(
                    new Func<object, string>(JsonConvert.SerializeObject),
                    data,
                    ct);

                data.Add("stringContent", json);
            }

            return dataset;
#endif
        }
开发者ID:chris-han,项目名称:MTC-Beijing-Azure-IoT-Workshop,代码行数:33,代码来源:JsonSerializer.cs

示例2: Read

        public override Data Read()
        {
            _t += _delta;

            var output = new Data();
            output.Add("Temp", (Math.Sin(_t) * _k + _b) * _rand.Next(Fluctuating));
            output.Add("Volt", 200 + 20 * _rand.Next(Fluctuating)); //200 +- 20 V
            return output;
        }
开发者ID:chris-han,项目名称:MTC-Beijing-Azure-IoT-Workshop,代码行数:9,代码来源:Sine.cs

示例3: Read

 public override Data Read()
 {
     var output = new Data();
     output.Add("voltdrop", _rand.Next(VoltdropBoundary));
     output.Add("powerdraw", _rand.Next(PowerdrawBoundary));
     output.Add("dutycycle", _rand.Next(DutycycleBoundary));
     output.Add("vibration", _rand.Next(VibrationBoundary));
     output.Add("temperature", _rand.Next(TemperaturBoundary));
     return output;
 }
开发者ID:chris-han,项目名称:MTC-Beijing-Azure-IoT-Workshop,代码行数:10,代码来源:VendingMachine.cs

示例4: Sample

        public Data Sample(int n)
        {
            var data = new Data();

            var currentVector = parameters.Current; 
            var currentProbability = probability(currentVector); 

            for(int i=0; i<n; i++)
            {
                var proposedVector = parameters.ProposeNewVector();
                var proposedProbability = probability(proposedVector);

                var pMove = Min(1.0, proposedProbability / currentProbability);
                var shouldMove = rng.RandomNumber() < pMove; 

                if(shouldMove)
                {
                    currentVector = parameters.UpdateToProposedValue();
                    currentProbability = probability(currentVector); 
                }

                data.Add(currentVector); 
            }

            return data; 
        }
开发者ID:daebwae,项目名称:Marvin,代码行数:26,代码来源:Metropolis.cs

示例5: Read

        public async Task<DataSet> Read(CancellationToken ct)
        {
            var output = new DataSet();

            using (var stream = new MemoryStream())
            {
                while (true)
                {
                    var status = await _transport.ReceiveCommand(stream, ct);
                    if (status != HttpStatusCode.OK)
                    {
                        break;
                    }

                    var data = new Data();
                    data.Add("bytesContent", stream.ToArray());

                    output.Add(data);
                }
            }

            return output;
        }
开发者ID:chris-han,项目名称:MTC-Beijing-Azure-IoT-Workshop,代码行数:23,代码来源:CloudGateway.cs

示例6: ToData

        /// <summary>
        /// Convert <see cref="SorentoLib.User"/> to <see cref="SorentoLib.Data"/>.
        /// </summary>
        private Data ToData(bool Internal)
        {
            Data result = new Data ();
            result.Add ("id", this._id);
            result.Add ("createtimestamp", this._createtimestamp);
            result.Add ("updatetimestamp", this._updatetimestamp);
            result.Add ("usergroupids", this._usergroupids);
            result.Add ("username", this._username);
            result.Add ("realname", this._realname);
            result.Add ("email", this._email);

            if (Internal)
                result.Add ("password", this._password);

            result.Add ("status", SNDK.Convert.EnumToString (this._status));

            return result;
        }
开发者ID:sundowndk,项目名称:sXUL,代码行数:21,代码来源:Config.cs

示例7: ToData

 public Data ToData()
 {
     Data result = new Data ();
     result.Add ("id", this._id);
     result.Add ("createtimestamp", this._createtimestamp);
     result.Add ("updatetimestamp", this._updatetimestamp);
     result.Add ("name", this._name);
     result.Add ("ownerid", this._ownerid);
     result.Add ("data", this._data);
     return result;
 }
开发者ID:sundowndk,项目名称:sXUL,代码行数:11,代码来源:Event.cs

示例8: ToData

 public Data ToData()
 {
     Data result = new Data ();
     result.Add ("id", this._id);
     result.Add ("createtimestamp", this._createtimestamp);
     result.Add ("updatetimestamp", this._updatetimestamp);
     return result;
 }
开发者ID:sundowndk,项目名称:sXUL,代码行数:8,代码来源:EventListener.cs

示例9: Read

        public override Data Read()
        {
            double value = _temperature;

            if (_up)
            {
                double delta = _temperature * _multiplier;
                _temperature += delta;
                _multiplier /= UpDecayMult;

                //Turn on "cooling" if over-heat and "cooling failure" was not raised
                if (++_runningSteps >= _stepThreshold || _temperature >= Boundary.Max)
                {
                    _up = false;
                }
            }
            else
            {
                double delta = _temperature * DownDecayMult;
                _temperature -= delta;
                if (_temperature <= Boundary.Min)
                {
                    _temperature = Boundary.Min;

                    //Turn off "cooling" if fully cool-down after waiting for a random period
                    if (_rand.TestProb(HeatingProb))
                    {
                        _up = true;
                        _temperature = Boundary.Min * (1 + InitMult);
                        _multiplier = InitMult * UpDecayMult;
                        _runningSteps = 0;
                        _stepThreshold = _rand.TestProb(CoolingFailureProb) ? int.MaxValue : StepsThreshold;
                    }
                }
            }

            var output = new Data();

            if (_rand.TestProb(SensorFailureProb))
            {
                output.Add("Anomaly", true);
                output.Add("Temperature", _rand.Next(SensorFailureBoundary));
            }
            else
            {
                output.Add("Anomaly", _stepThreshold == int.MaxValue && _temperature > Boundary.Min);
                output.Add("Temperature", value * _rand.Next(Fluctuating));
            }

            return output;
        }
开发者ID:chris-han,项目名称:MTC-Beijing-Azure-IoT-Workshop,代码行数:51,代码来源:PeriodicMotorTemperature.cs


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