本文整理汇总了C#中Response.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Response.GetType方法的具体用法?C# Response.GetType怎么用?C# Response.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EventHandler
private void EventHandler(Exception ex, Response response)
{
if (!(response is EventResponse))
{
_logger.Error("Unexpected response type for event: " + response.GetType().Name);
return;
}
if (CassandraEventResponse != null)
{
CassandraEventResponse(this, ((EventResponse) response).CassandraEventArgs);
}
}
示例2: GetRequestTypeFor
public Type GetRequestTypeFor(Response response)
{
if (response == null) throw new ArgumentNullException("response");
return responseRequestMappings[response.GetType()];
}
示例3: addresponse
int addresponse(Response r)
{
int id = _NEXTRESPONSEID;
try
{
// set the id
r.ID = id;
// ensure it has a full name
if (r.FullName == string.Empty)
r.FullName = r.GetType().ToString();
// get local response index
int idx = _reslist.Count;
// bind events
bindresponseevents(r);
// show it to user
_resnames.Items.Add(r.FullName);
// add it to trade list
lock (_reslist)
{
_reslist.Add(r);
}
// prepare log entry for it
_indlog.Add(null);
// save id to local relationship
_rid2local.Add(r.ID, idx);
// setup place for it's symbols
_rsym.Add(id, string.Empty);
// map name to response
_disp2real.Add(idx);
// save id
_NEXTRESPONSEID++;
// reset response
_reslist[idx].Reset();
// send it current positions
foreach (Position p in _pt)
_reslist[idx].GotPosition(p);
// update everything
IndexBaskets();
// show we added response
status(r.FullName + getsyms(idx));
}
catch (Exception)
{
return -1;
}
return id;
}
示例4: GetRowSet
/// <summary>
/// Validates that the result contains a RowSet and returns it.
/// </summary>
/// <exception cref="NullReferenceException" />
/// <exception cref="DriverInternalError" />
public static IEnumerable<Row> GetRowSet(Response response)
{
if (response == null)
{
throw new NullReferenceException("Response can not be null");
}
if (!(response is ResultResponse))
{
throw new DriverInternalError("Expected rows, obtained " + response.GetType().FullName);
}
var result = (ResultResponse) response;
if (!(result.Output is OutputRows))
{
throw new DriverInternalError("Expected rows output, obtained " + result.Output.GetType().FullName);
}
return ((OutputRows) result.Output).RowSet;
}
示例5: OneShotLocation_Click
private async void OneShotLocation_Click(object sender, RoutedEventArgs e)
{
string latitude, longitude;
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if ((bool)localSettings.Values["LocationConsent"] != true)
{
// The user has opted out of Location.
return;
}
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 50;
try
{
Geoposition geoposition = await geolocator.GetGeopositionAsync(
maximumAge: TimeSpan.FromMinutes(5),
timeout: TimeSpan.FromSeconds(10)
);
string bingMapsKey = "AqzuDl7U8coCVlvDrG30M2lwryW2N-tPnuQaIVjH4p9DFCnxD32Xgkt6ll9Selr7";
latitude = geoposition.Coordinate.Latitude.ToString("0.00");
longitude = geoposition.Coordinate.Longitude.ToString("0.00");
double Radius = 3; // km
string accessID = "f22876ec257b474b82fe2ffcb8393150";
string dataEntityName = "NavteqNA";
string dataSource = "NavteqPOIs";
string requestUrl = string.Format("http://spatial.virtualearth.net/REST/v1/data/{0}/{1}/{2}?spatialFilter=nearby({3},{4},{5})&$filter=EntityTypeID eq '5800'&$select=EntityID,DisplayName,AddressLine,PostalCode,Phone,__Distance&$format=json&$top=10&key={6}", accessID, dataEntityName, dataSource, latitude, longitude, Radius, bingMapsKey);
string json = await getData(requestUrl);
Response childlist = new Response();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
DataContractJsonSerializer ser = new DataContractJsonSerializer(childlist.GetType());
childlist = ser.ReadObject(ms) as Response;
string teststring = "";
foreach (var d in childlist.results)
{
foreach (var s in d.metadata)
{
teststring = teststring + "" + s.DisplayName + "\t" + s.EntityID + "\n";
}
}
ms.Dispose();
// results = json.ToString();
LatitudeTextBlock.Text = teststring;
}
catch (Exception ex)
{
if ((uint)ex.HResult == 0x80004004)
{
// the application does not have the right capability or the location master switch is off
StatusTextBlock.Text = "location is disabled in phone settings.";
}
//else
{
// something else happened acquring the location
StatusTextBlock.Text = "Some error occured.";
}
}
}
示例6: SerializeResponse
private string SerializeResponse(Response response)
{
//TODO handle multiple input/output types
response.Time = Functions.ConvertToUnixTimestamp(DateTime.Now);
String responseString;
switch (response.Request.ContentType)
{
case ContentType.Xml:
var x = new XmlSerializer(response.GetType());
using (var writer = new StringWriter())
{
x.Serialize(writer, response);
responseString = writer.ToString();
}
break;
//case ContentType.Json:
default:
responseString = JsonConvert.SerializeObject(response, Formatting.None, SerializerSettings);
break;
}
return responseString;
}