本文整理汇总了C#中Result类的典型用法代码示例。如果您正苦于以下问题:C# Result类的具体用法?C# Result怎么用?C# Result使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于命名空间,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
/// <summary>
/// Build the index
/// </summary>
public virtual void Build(MetricDB db, int bsize, Random rand)
{
this.DB = db;
var n = this.DB.Count;
// randomized has very good performance, even compared with more "intelligent" strategies
var dseq = new DynamicSequentialOrdered ();
dseq.Build (db, rand);
this.NODES = new List<Node> (n / bsize + 1);
var L = new List<ItemPair> (n);
while (dseq.Count > 0) {
if (this.NODES.Count % 100 == 0) {
Console.WriteLine ("XXX {0}, bucketSize: {1}, remain {2}/{3}, db: {4}, date-time: {5}",
this, bsize, dseq.Count, db.Count, Path.GetFileName(db.Name), DateTime.Now);
}
var refID = dseq.GetAnyItem ();
dseq.Remove (refID);
L.Clear ();
dseq.ComputeDistances (this.DB[refID], L);
var near = new Result(bsize);
var far = new Result (1);
dseq.AppendKExtremes (near, far, L);
var node = new Node (refID);
this.NODES.Add (node);
dseq.Remove (near);
foreach (var p in near) {
node.Add(p.ObjID, p.Dist);
}
}
}
示例2: SetSessionByCategoryList
public static Result SetSessionByCategoryList()
{
CategoryBO oCategoryBO = new CategoryBO();
Result oResult = new Result();
List<Category> oListCategory = new List<Category>();
try
{
oResult = oCategoryBO.CategoryGetFromDatabaseForSetSession();
if (oResult.ResultIsSuccess)
{
oListCategory = (List<Category>)oResult.ResultObject;
Utils.SetSession(SessionManager.csStoredCategory, oListCategory);
}
}
catch (Exception oEx)
{
oResult.ResultIsSuccess = false;
oResult.ResultException = oEx;
oResult.ResultMessage = "Exception occured during Set Session By CategoryList.";
}
return oResult;
}
示例3: Run
public Result Run(int itemCount, long dllSize)
{
var result = new Result()
{
TestName = Name,
DTOCount = itemCount,
DLLSize = dllSize
};
var startDate = DateTime.Now;
var stream = new MemoryStream();
var testData = SampleDTO.GenerateSamples(itemCount);
var endDate = DateTime.Now;
result.SetupTime = (endDate - startDate).TotalMilliseconds;
startDate = DateTime.Now;
SerializerUtility.Serialize(stream, testData);
endDate = DateTime.Now;
result.SerializeTime = (endDate - startDate).TotalMilliseconds;
result.SerializedByteCount = stream.ToArray().Length;
stream.Seek(0, SeekOrigin.Begin);
startDate = DateTime.Now;
var deData = SerializerUtility.Deserialize<SampleDTO>(stream);
endDate = DateTime.Now;
result.DeserializeTime = (endDate - startDate).TotalMilliseconds;
return result;
}
示例4: GetResult
/// <summary>
/// Get the variable value.
/// </summary>
/// <returns></returns>
public Result GetResult()
{
Result result = new Result( 1 );
result.Add( new object[]{Value} );
return result;
}
示例5: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (requestCode == 111 && resultCode == Result.Ok) {
Console.WriteLine (data.Data);
}
base.OnActivityResult (requestCode, resultCode, data);
}
示例6: ResultMarker
public ResultMarker (Result result) : base (
GetColor (result),
IsOneLine (result)? (result.Region.BeginColumn) : 0,
IsOneLine (result)? (result.Region.EndColumn) : 0)
{
this.result = result;
}
示例7: GetStatusCode
/// <summary>
/// �w��REST API�̌Ăяo����s��
/// </summary>
public int GetStatusCode(string extend, ref Result result)
{
result.Initialize();
result.url = baseurl;
HttpWebRequest webreq = null;
try
{
webreq = (HttpWebRequest)WebRequest.Create(result.url);
}
catch (SystemException e)
{
result.data = e.Message;
result.returnCode = -1;
return result.returnCode;
}
//���\�b�h��POST��w��
webreq.Timeout = timeoutLimit;
webreq.Method = "GET";
if (extend != null && extend.Length > 0)
{
webreq.Method = "POST";
webreq.ContentLength = extend.Length;
System.IO.Stream reqStream = webreq.GetRequestStream();
reqStream.Write(Encoding.UTF8.GetBytes(extend), 0, extend.Length);
reqStream.Close();
}
HttpWebResponse webres = null;
try
{
webres = (HttpWebResponse)webreq.GetResponse();
Stream st = webres.GetResponseStream();
Encoding enc = Encoding.GetEncoding("utf-8");
StreamReader sr = new StreamReader(st, enc);
result.data = sr.ReadToEnd();
sr.Close();
result.returnCode = (int)webres.StatusCode;
}
catch (System.Net.WebException ex)
{
if (ex.Status == System.Net.WebExceptionStatus.ProtocolError)
{
HttpWebResponse errres = (HttpWebResponse)ex.Response;
result.returnCode = (int)errres.StatusCode;
}
else
{
// �������z�X�g���Ȃǂ�����ł��Ȃ����
result.returnCode = -1;
}
result.data = ex.Message;
}
finally
{
if (webres != null)
{
webres.Close();
}
}
return result.returnCode;
}
示例8: Invoke
public Yield Invoke(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response)
{
// NOTE (steveb): we convert 'xri://@name/path?params' into 'http://xri.net/@name/path?params'
// prepend segments with authority
List<string> segments = new List<string>();
segments.Add(uri.Authority);
if(uri.Segments != null) {
segments.AddRange(uri.Segments);
}
// build new plug
List<PlugHandler> preHandlers = (plug.PreHandlers != null) ? new List<PlugHandler>(plug.PreHandlers) : null;
List<PlugHandler> postHandlers = (plug.PostHandlers != null) ? new List<PlugHandler>(plug.PostHandlers) : null;
Plug xri = new Plug(new XUri("http", null, null, "xri.net", 80, segments.ToArray(), uri.TrailingSlash, uri.Params, uri.Fragment), plug.Timeout, request.Headers, preHandlers, postHandlers, plug.Credentials, plug.CookieJar, plug.MaxAutoRedirects);
// add 'Accept' header for 'application/xrds+xml' mime-type
if((xri.Headers == null) || (xri.Headers.Accept == null)) {
xri = xri.WithHeader(DreamHeaders.ACCEPT, MimeType.RenderAcceptHeader(MimeType.XRDS));
}
// BUGBUGBUG (steveb): this will probably fail in some cases since we may exit this coroutine before the call has completed!
xri.InvokeEx(verb, request, response);
yield break;
}
示例9: UpdateAccount
public Result UpdateAccount(Account account, bool deleteAccount)
{
IList<Account> accounts = GetAccounts().ToList();
var result = new Result()
{
Activity = deleteAccount ? "Delete Account" : "Update Account"
};
if (accounts.Count > 0 && accounts.All(x => x != null))
{
if (deleteAccount)
{
accounts.Remove(accounts.FirstOrDefault(x => x.UserName == account.UserName));
}
else
{
accounts.Remove(accounts.FirstOrDefault(x => x.UserName == account.UserName));
accounts.Add(account);
result.Account = account;
}
using (TextWriter writer = new StreamWriter(_FileName))
{
_Serializer.Serialize(writer, accounts.ToArray());
}
result.IsSuccessful = true;
}
else
{
result.IsSuccessful = false;
result.Reason = "Xml did not return any accounts.";
}
return result;
}
示例10: GetData
public void GetData(IRequest request)
{
int numberToDisplay = 5;
Sage.SalesLogix.Security.SLXUserService slxUserService = ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>() as Sage.SalesLogix.Security.SLXUserService;
string currentUserId = slxUserService.GetUser().Id.ToString();
IRepository<IOpportunity> oRep = EntityFactory.GetRepository<IOpportunity>();
IExpressionFactory ep = ((IQueryable)oRep).GetExpressionFactory();
ICriteria countCrit = GetOpenOppCrit(oRep, ep, currentUserId);
countCrit.SetProjection(((IQueryable)oRep).GetProjectionsFactory().RowCount());
int totalCount = Convert.ToInt32(countCrit.UniqueResult());
ICriteria crit = GetOpenOppCrit(oRep, ep, currentUserId);
crit.AddOrder(ep.Asc("EstimatedClose"));
crit.SetMaxResults(numberToDisplay);
IList<IOpportunity> opps = crit.List<IOpportunity>();
numberToDisplay = (totalCount < numberToDisplay) ? totalCount : numberToDisplay;
var result = new Result();
result.items = new List<OpportunityRepresentation>();
result.columns = new string[] { "id", "description", "estClose", "potential", "probability", "stage", "nextStep", "nextActivityId", "nextActivityName", "daysInStage", "daysSinceLastActivity" };
for (int i = 0; i < numberToDisplay; i++)
{
result.items.Add(OpportunityRepresentation.from(opps[i]));
}
string groupId = GetPluginIdFromFamilyAndName("Opportunity", "My Open Opps");
int groupCount = totalCount;
result.openOppGroup = groupId;
result.openOppCount = groupCount;
result.numberToDisplay = numberToDisplay;
request.Response.ContentType = MediaType.JSON;
request.Response.Html = JavaScriptConvert.SerializeObject(result);
}
示例11: AdminWindow_OnBeforeDisplayAdminWindowOverlay
void AdminWindow_OnBeforeDisplayAdminWindowOverlay(Result result)
{
if(WebAuthentication.IsLoggedIn)
if(WebAuthentication.VerifyAccess(PermissionType.AdministrativeAccess))
return;
result.SetFailed("access denied");
}
示例12: ParseResult
private Result ParseResult(string line)
{
string[] parts = line.Split(new[] { ',' }, StringSplitOptions.None);
if (parts.Length != 12)
{
throw new InvalidOperationException("CSV file has invalid format. Please delete CSV first.");
}
var result = new Result();
result.Name = parts[0];
result.Version = parts[1];
result.SingletonTime = long.Parse(parts[2]);
result.TransientTime = long.Parse(parts[3]);
result.CombinedTime = long.Parse(parts[4]);
result.ComplexTime = long.Parse(parts[5]);
result.PropertyInjectionTime = parts[6] == "0" ? (long?)null : long.Parse(parts[6]);
result.GenericTime = parts[7] == "0" ? (long?)null : long.Parse(parts[7]);
result.MultipleImport = parts[8] == "0" ? (long?)null : long.Parse(parts[8]);
result.ConditionalTime = parts[9] == "0" ? (long?)null : long.Parse(parts[9]);
result.ChildContainerTime = parts[10] == "0" ? (long?)null : long.Parse(parts[10]);
result.InterceptionTime = parts[11] == "0" ? (long?)null : long.Parse(parts[11]);
return result;
}
示例13: OnSpecificationEnd
public void OnSpecificationEnd(SpecificationInfo specification, Result result)
{
var formatter = resultFormatterFactory.GetResultFormatterFor(result);
testListener.WriteLine(formatter.FormatResult(specification), Category.Output);
var testResult = new TestResult();
testResult.Name = specification.Name;
if (result.Passed)
testResult.State = TestState.Passed;
else if (result.Status == Status.Ignored)
{
testResult.State = TestState.Ignored;
testResult.Message = "Ignored";
}
else if (result.Status == Status.NotImplemented)
{
testResult.State = TestState.Ignored;
testResult.Message = "Not Implemented";
}
else
{
testResult.State = TestState.Failed;
if (result.Exception != null)
testResult.StackTrace = result.Exception.ToString();
}
testResults.Add(testResult);
}
示例14: ResultPage
public ResultPage(Result r)
{
InitializeComponent();
currentResult = r;
timer.Tick += new EventHandler(hideSaved);
timer.Interval = new TimeSpan(0, 0, 1);
}
示例15: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
Console.WriteLine(requestCode);
Console.WriteLine(resultCode);
}