本文整理汇总了C#中Parameters类的典型用法代码示例。如果您正苦于以下问题:C# Parameters类的具体用法?C# Parameters怎么用?C# Parameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameters类属于命名空间,在下文中一共展示了Parameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public static List<byte[]> Serialize(Parameters parameters,
int chunkSize)
{
if(chunkSize != int.MaxValue && chunkSize % 4 != 0)
{
throw new System.ArgumentException();
}
List<byte[]> stringCache = new List<byte[]>();
int numberOfBytes = serializationSize(parameters, stringCache);
// allocate all buffers
List<byte[]> buffers = new List<byte[]>();
while (numberOfBytes > 0)
{
int sizeOfBuffer = Math.Min(numberOfBytes, chunkSize);
buffers.Add(new byte[sizeOfBuffer]);
numberOfBytes -= sizeOfBuffer;
}
// fill all buffers with data
BuffersState bufState = new BuffersState();
bufState.buffers = buffers;
bufState.bufferIndex = 0;
bufState.byteIndex = 0;
serialize(bufState, parameters, stringCache);
return buffers;
}
示例2: Execute
public override void Execute()
{
List<ControllableUnit> teamAList = BattleComposition.Instance.GetAllTeamAUnits();
List<ControllableUnit> teamBList = BattleComposition.Instance.GetAllTeamBUnits();
foreach(ControllableUnit unit in teamAList) {
Vector3 unitScreenPos = Camera.main.WorldToViewportPoint(unit.transform.position);
Parameters parameters = new Parameters();
parameters.PutObjectExtra(GameHUDScreen.UNIT_POSITION_KEY, unitScreenPos);
parameters.PutObjectExtra(GameHUDScreen.CONTROLLABLE_UNIT_KEY, unit);
EventBroadcaster.Instance.PostEvent(EventNames.ON_RETRIEVE_UNIT_POSITION, parameters);
}
foreach(ControllableUnit unit in teamBList) {
Vector3 unitScreenPos = Camera.main.WorldToViewportPoint(unit.transform.position);
Parameters parameters = new Parameters();
parameters.PutObjectExtra(GameHUDScreen.UNIT_POSITION_KEY, unitScreenPos);
parameters.PutObjectExtra(GameHUDScreen.CONTROLLABLE_UNIT_KEY, unit);
EventBroadcaster.Instance.PostEvent(EventNames.ON_RETRIEVE_UNIT_POSITION, parameters);
}
}
示例3: ProductFactory
public ProductFactory(Parameters parameters)
{
try
{
using (var server = new VentsCad())
{
switch (parameters.Name)
{
case "spigot":
product = new Spigot(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height);
break;
case "dumper":
var material = new string[] { parameters.Materials[0].Value, parameters.Materials[0].Thikness, parameters.Materials[0].Name, parameters.Materials[0].Code };
product = new Dumper(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Height, true, material);
break;
case "montageFrame":
product = new MontageFrame(parameters.Type.SubType, parameters.Sizes[0].Width, parameters.Sizes[0].Lenght, parameters.Sizes[0].Additional1, parameters.Materials[0]);
break;
default:
break;
}
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
}
}
示例4: RSSPub
RSSPub(string serverUrl)
{
m_Connector = new Connector();
Parameters p = new Parameters();
p.ServerUrl = serverUrl;
m_Connector.Open(p);
}
示例5: ExecuteNoneQuery
public void ExecuteNoneQuery(string procedureName, Parameters parameters)
{
try
{
DbProviderFactory factory = DbProviderFactories.GetFactory(DataSource.ProviderName);
using (DbConnection conn = factory.CreateConnection())
using (DbCommand command = factory.CreateCommand())
{
conn.ConnectionString = DataSource.ConnectionString;
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = procedureName;
InsertCommandParameters(command, parameters);
conn.Open();
command.ExecuteNonQuery();
}
}
catch (SqlException exception)
{
throw new DataException(string.Format("Error executing procedure: {0}", procedureName), exception);
}
catch (Exception exception)
{
throw new DataException(string.Format("Error executing procedure: {0}", procedureName), exception);
}
}
示例6: CountBatteryLife
public override void CountBatteryLife(Parameters pParameters)
{
var realCapacity = Tools.AdjustBatteryCapacitanceToTemperature(pParameters.BatteryCapacitance, pParameters.SleepCurrent); // in mAh
var avarageCurrent = Tools.GetAvaregeCurrent(pParameters.SleepTime, pParameters.TxTime, pParameters.RxTime, pParameters.SleepCurrent / 1e3, pParameters.TxCurrent, pParameters.RxCurrent); // in mA
pParameters.BatteryLife = (realCapacity / (Math.Pow(avarageCurrent, Tools.PeukertNumber) * 60)); // days
}
示例7: GetSongList
/// <summary>
/// 根据频道和歌曲,得到歌曲列表
/// </summary>
/// <param name="channel"></param>
/// <param name="song"></param>
/// <param name="type">n-New</param>
/// <returns></returns>
public Models.SongList GetSongList(Models.Channel channel, Models.Song song, string type = "n")
{
Parameters parameters = new Parameters();
parameters["from"] = "mainsite";
parameters["context"] = channel.Context;
parameters["sid"] = song != null ? song.SongID : null;
parameters["channel"] = channel.ID.ToString();
parameters["type"] = type;
Random rnd = new Random();
var number = rnd.NextDouble();
parameters["r"] = number.ToString();
string url = ConnectionBase.ConstructUrlWithParameters("http://douban.fm/j/mine/playlist", parameters);
//获取列表
string json = new ConnectionBase().Get(url, @"application/json, text/javascript, */*; q=0.01", @"http://douban.fm");
var songList = Framework.Common.Helpers.JsonHelper.Deserialize<Models.SongList>(json);
//将小图更换为大图
foreach (var s in songList.Songs)
{
s.Picture = new Uri(s.Picture.ToString().Replace("/mpic/", "/lpic/").Replace("//otho.", "//img3."));
}
//去广告
songList.Songs.RemoveAll(s => s.IsAd);
return songList;
}
示例8: ToParameters
public Parameters ToParameters() {
var parameters = new Parameters(new DefaultFactory(new TestLogger()));
foreach (var p in _params) {
parameters.Add(p.Key, p.Value);
}
return parameters;
}
示例9: AddNewUser
public bool AddNewUser(Core.User user)
{
try
{
Parameters parameters = new Parameters();
parameters.Add("@FirstName", user.FirstName);
parameters.Add("@UserName", user.UserName);
parameters.Add("@Pass", user.Password);
parameters.Add("@RoleId", user.RoleId);
parameters.Add("@IsActive", user.IsActiveUser);
if (string.IsNullOrWhiteSpace(user.LastName))
parameters.Add("@LastName", DBNull.Value);
else
parameters.Add("@LastName", user.LastName);
if (string.IsNullOrWhiteSpace(user.NICNumber))
parameters.Add("@NICNumber", DBNull.Value);
else
parameters.Add("@NICNumber", user.NICNumber);
ExecuteNoneQuery("proc_AddNewUser", parameters);
return true;
}
catch (Exception)
{
throw;
}
}
示例10: Run
/// <summary>
/// Runs the specified parameters.
/// </summary>
/// <param name="parameters">The parameters.</param>
/// <returns></returns>
public int Run(Parameters parameters)
{
var exitCode = (int)ExitCode.GeneralError;
var commandType = new BoundCommandFactory().GetCommandType(parameters,
() => GetType().Assembly.GetTypes()
.Where(type => type.Namespace != null && type.Namespace.StartsWith("Aws.Commands"))
.Where(type => type.Name == "Options"));
if (commandType != null)
{
exitCode = Run(commandType, parameters);
}
else
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write("{0:yyyy-MM-dd HH:mm:ss} : ", DateTime.UtcNow);
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Unknown command arguments: ");
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(Arguments);
Console.ResetColor();
}
return exitCode;
}
示例11: Main
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
if (args.Length != 2)
{
Console.WriteLine("Wrong number of arguments. Got {0} instead.", args.Length);
return;
}
MyHandler myH = new MyHandler();
Parameters p = new Parameters();
p.ServerUrl = args[0];
Connector c = new Connector();
if (c.Open(p))
{
Message m = new Message();
m.Set("do_method", "notify");
m.Set("kn_to", args[1]);
m.Set("kn_payload", "Hello");
m.Set("nickname", "dotnet");
m.Set("kn_response_format", "simple");
c.Publish(m, myH);
c.Close();
}
}
示例12: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
Random2 rand = new Random2();
double std = param.GetParam<double>("Standard deviation").Value;
int[] inds = param.GetParam<int[]>("Columns").Value;
List<int> mainInds = new List<int>();
List<int> numInds = new List<int>();
foreach (int ind in inds){
if (ind < mdata.ColumnCount){
mainInds.Add(ind);
} else{
numInds.Add(ind - mdata.ColumnCount);
}
}
foreach (int j in mainInds){
for (int i = 0; i < mdata.RowCount; i++){
mdata.Values.Set(i, j, mdata.Values.Get(i, j) + (float) rand.NextGaussian(0, std));
}
}
foreach (int j in numInds){
for (int i = 0; i < mdata.RowCount; i++){
mdata.NumericColumns[j][i] += (float) rand.NextGaussian(0, std);
}
}
}
示例13: FamilyPictureDir
public FamilyPictureDir(Guid id)
{
this.id = id;
dd = DocX.Create("ttt.docx");
pa = new Parameters()
{
PageHeight = 8.5,
PageWidth = 5.5,
MarginLeft = .5,
MarginRight = .3,
MarginTop = .5,
MarginBottom = .3,
FontSizeName = 18.0,
FontSize = 14,
};
pa.CellWidth = pa.PageWidth - pa.MarginLeft - pa.MarginRight;
pa.RowHeight = pa.PageHeight - pa.MarginTop - pa.MarginBottom;
pa.MaxPicHeight = pa.RowHeight * .4;
dd.PageHeight = Pixels(pa.PageHeight);
dd.PageWidth = Pixels(pa.PageWidth);
dd.MarginLeft = Pixels(pa.MarginLeft);
dd.MarginRight = Pixels(pa.MarginRight);
dd.MarginTop = Pixels(pa.MarginTop);
dd.MarginBottom = Pixels(pa.MarginBottom);
}
示例14: BaiduMusicSearch
/// <summary>
/// 搜索百度音乐
/// </summary>
/// <param name="keyword">关键词</param>
private static void BaiduMusicSearch(string keyword)
{
Parameters parameters = new Parameters();
parameters["key"] = keyword;
string url = ConnectionBase.ConstructUrlWithParameters("http://music.baidu.com/search", parameters);
UrlHelper.OpenLink(url);
}
示例15: Process
public void Process(string[] args)
{
var parameters = new Parameters { Log = Log };
parameters.WriteHeader();
try
{
parameters.Parse(args);
}
catch (Exception e)
{
Output.WriteErrorLine(Log, e.Message);
PrintUsage(parameters);
return;
}
if (args.Length == 0 || parameters.Help)
{
PrintUsage(parameters);
return;
}
ProcessSchema(parameters);
if (parameters.Readline)
{
// '-readLineAtExit' flag: useful when running from Visual Studio
Console.ReadKey();
}
}