本文整理汇总了C#中Payload类的典型用法代码示例。如果您正苦于以下问题:C# Payload类的具体用法?C# Payload怎么用?C# Payload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Payload类属于命名空间,在下文中一共展示了Payload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public Payload<Resource> Delete(Resource obj)
{
// create payload
var payload = new Payload<Resource>();
// todo: check security
// validate
var rules = new ValidationRules();
rules.ValidateHasId(obj);
// assign errors from validation (if applicable)
payload.AssignValidationErrors(rules.Errors);
// check if valid
if (rules.IsValid)
{
// db delete (inactive)
using (var queries = new ResourceQueries())
{
queries.Delete(ref obj);
}
payload.Data = obj;
}
// todo: next steps in workflow
// return payload
return payload;
}
示例2: Fill
public void Fill(ref Payload payload)
{
Head = payload.Head;
Calculator = payload.Calculator;
_length = payload.Length;
_position = payload.Position;
}
示例3: Request
public Request(RequestLine requestLine, NameValueCollection headers, Payload payload)
{
RequestLine = requestLine;
Headers = headers;
Payload = payload;
ContentType = String.Empty; // TODO: perhaps this belongs with payload
}
示例4: Comment
public Payload<Comment> Comment(Comment obj)
{
// create payload
var payload = new Payload<Comment>();
// Prep obj
obj.Created = DateTime.Now;
// validate
var rules = new ValidationRules();
rules.Validate(obj);
// check if valid
if (rules.IsValid)
{
// db save
using (var queries = new CommentQueries())
{
queries.Save(ref obj);
}
payload.Data = obj;
}
// todo: next steps in workflow
// return payload
return payload;
}
示例5: CreateNewWindow
public static async Task CreateNewWindow(object qStringID, object qStringName, int minWidth, int minHeight, string page)
{
var newCoreAppView = CoreApplication.CreateNewView();
var appView = ApplicationView.GetForCurrentView();
Payload payload = new Payload();
payload.qStringID = qStringID;
payload.qStringName = qStringName;
await newCoreAppView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, async () =>
{
var window = Window.Current;
var newAppView = ApplicationView.GetForCurrentView();
#if WINDOWS_UAP
newAppView.SetPreferredMinSize(new Windows.Foundation.Size(minWidth, minHeight));
#endif
var frame = new Frame();
window.Content = frame;
frame.Navigate(typeof(VenuePage), payload);
window.Activate();
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.UseMore, appView.Id, ViewSizePreference.Default);
#if WINDOWS_UAP
var success = newAppView.TryResizeView(new Windows.Foundation.Size(minWidth, minHeight));
#endif
});
}
示例6: IsAllowed
public bool IsAllowed(Payload payload)
{
Type t2 = payload.GetType();
foreach (Type t in _Types)
if (t == t2) return true;
return false;
}
示例7: Get
public Payload<Topic> Get(string hashtag)
{
// create payload
var payload = new Payload<Topic>();
// todo: check security
// prep
// todo: add appending of # if necessary
// get from db
using (var queries = new TopicQueries())
{
payload.Data = queries.Get(hashtag);
}
// Check if null to add error
if (payload.Data == null)
{
payload.Errors.Add("00002", Resources.Errors.ERR00002);
}
// return payload
return payload;
}
示例8: testAddEmptyString
public void testAddEmptyString()
{
var payload = new Payload();
payload.Add("empty", "");
var pairs = payload.NvPairs;
Assert.IsFalse(pairs.ContainsKey("name"));
}
示例9: YMSGPacket
public YMSGPacket()
{
this._Payload = new Payload();
this.Version = 102;
this.VendorID = 0x402;
this.Status = 0x0;
}
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
using(var mysql = new MySqlConnection(ConfigurationManager.AppSettings["connectionstring"]))
{
mysql.Open();
string sql = "select * from PYLD_DTL where PYLD_TP='WORKER_BIO_SL'";
MySqlCommand command = new MySqlCommand(sql, mysql);
using(MySqlDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
Payload worker = new Payload();
worker.ID = dr["PYLD_DTL_ID"].ToString();
worker.RegistrationNumber = dr["PYLD_REF_ID"].ToString();
string req = dr["PYLD_REQ"].ToString();
var json = JObject.Parse(req);
worker.PassportNumber = json["passportNumber"].ToString();
listViewMain.Items.Add(new ListViewItem(new string[]{
worker.ID,
worker.RegistrationNumber,
worker.PassportNumber
}));
worker.Images = json;
workers.Add(worker);
}
}
}
listViewMain.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
}
示例11: SendEvent
public override void SendEvent(string channelName, Payload[] data)
{
for (int i = 0; i < data.Length; ++i)
{
Debug.WriteLine("EventLinkChannel.SendEvent[] Payload: {0} on channel {1} from {2}: {3}", data[i].PayloadType, channelName, data[i].ClientId, data[i].ToJsonString());
}
this.EventLinkClient.Publish(channelName, data);
}
示例12: InitializeList
private void InitializeList(Payload pairs)
{
Invoke((MethodInvoker) (() =>
{
PropertiesList.Items.Clear();
foreach (var pair in pairs)
PropertiesList.Items.Add(String.Format(pair.ToString()));
}));
}
示例13: fields_with_no_value_are_ignored_for_better_or_worse
public void fields_with_no_value_are_ignored_for_better_or_worse()
{
var instance = new FormUrlEncoded();
var payload = new Payload { { "name", null }, { "name_1", "value_1"} };
using (var result = instance.Format(payload)) {
Assert.AreEqual("name_1=value_1", ToText(result), "Expected the field to have been skipped");
}
}
示例14: Serialize
public static string Serialize(Payload payload)
{
if (payload is UrlPayload)
{
var p = (UrlPayload)payload;
return JsonConvert.SerializeObject(p);
}
return string.Empty;
}
示例15: it_url_encodes_each_field
public void it_url_encodes_each_field()
{
var instance = new FormUrlEncoded();
var payload = new Payload { { "Full name", "Phil Murphy" } };
using (var result = instance.Format(payload)) {
Assert.AreEqual("Full%20name=Phil%20Murphy", ToText(result), "Expected the fi8eld to have been written");
}
}