本文整理汇总了C#中ITabContext类的典型用法代码示例。如果您正苦于以下问题:C# ITabContext类的具体用法?C# ITabContext怎么用?C# ITabContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITabContext类属于命名空间,在下文中一共展示了ITabContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public override object GetData(ITabContext context)
{
return new
{
MessageQueues = MessageQueue.GetQueueStats()
};
}
示例2: GetData
public override object GetData(ITabContext context)
{
var getInvocationsRequest = new GetInvocationsRequest();
var getInvocationsResult = _getInvocationsHandler.Handle(getInvocationsRequest);
var data = FormatInvocations(getInvocationsResult.Invocations);
return data;
}
示例3: GetData
/// <summary>
/// The context should contain the reference to any mongo connections, and the relevant profile document selection we need to extract from those connections.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public object GetData(ITabContext context)
{
var cutOff = DateTime.UtcNow - TimeSpan.FromSeconds(15);
var results = new List<MongoProfileModel>();
foreach (var server in MongoServer.GetAllServers())
{
foreach (var database in server.GetDatabaseNames())
{
var db = server.GetDatabase(database);
if (db.CollectionExists("system.profile"))
{
var query =
from e in db.GetCollection("system.profile").FindAllAs<SystemProfileInfo>()
where e.Namespace != database + ".system.profile" && e.Timestamp > cutOff
select new MongoProfileModel(e);
// skip one to miss the namespace query above
foreach (var d in query.OrderByDescending(x => x.Timestamp).Skip(1).Take(10))
{
results.Add(d);
}
}
}
}
return results;
}
示例4: GetData
public override object GetData(ITabContext context)
{
try
{
var portalSettings = PortalSettings.Current;
int totalRecords = 0;
LogInfoArray logs = new LogController().GetLog(portalSettings.PortalId, 15, 0, ref totalRecords);
if (logs.Count == 0)
return null;
var data = new List<object[]> {new object[] {"Created Date", "Log Type", "UserName", "Content"}};
for (int i = 0; i < logs.Count; i++)
{
var log = logs.GetItem(i);
var logProperties = new List<object[]> {new object[] {"Property", "Value"}};
for (int j = 0; j < log.LogProperties.Count; j++)
{
var logDetail = (LogDetailInfo)log.LogProperties[j];
logProperties.Add(new object[] { logDetail.PropertyName, logDetail.PropertyValue });
}
data.Add(new object[] {log.LogCreateDate, log.LogTypeKey, log.LogUserName, logProperties});
}
return data;
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return "There was an error loading the data for this tab";
}
}
示例5: HandleNullFindViewMessageCollection
public void HandleNullFindViewMessageCollection(Metadata sut, ITabContext context)
{
context.TabStore.Setup(ds => ds.Get(typeof(ViewEngine.FindViews.Message).FullName)).Returns<List<ViewEngine.FindViews.Message>>(null);
context.TabStore.Setup(ds => ds.Get(typeof(View.Render.Message).FullName)).Returns(new List<View.Render.Message>());
Assert.DoesNotThrow(() => sut.GetData(context));
}
示例6: GetData
public override object GetData(ITabContext context)
{
var getHubsRequest = new GetHubsRequest();
var getHubsResult = _getHubsHandler.Handle(getHubsRequest);
var data = FormatHubs(getHubsResult.Hubs);
return data;
}
示例7: GetData
public override object GetData(ITabContext context)
{
var cacheModel = new CacheModel();
cacheModel.Configuration.EffectivePercentagePhysicalMemoryLimit = HttpRuntime.Cache.EffectivePercentagePhysicalMemoryLimit;
cacheModel.Configuration.EffectivePrivateBytesLimit = HttpRuntime.Cache.EffectivePrivateBytesLimit;
var list = HttpRuntime.Cache.Cast<DictionaryEntry>().ToList();
foreach (var item in list)
{
try
{
var cacheEntry = MethodInfoCacheGet.Invoke(HttpRuntime.Cache, new object[] { item.Key, 1 });
var cacheItemModel = new CacheItemModel();
cacheItemModel.Key = item.Key.ToString();
cacheItemModel.Value = Serialization.GetValueSafe(item.Value);
cacheItemModel.CreatedOn = GetCacheProperty(ProcessInfoUtcCreated, cacheEntry) as DateTime?;
cacheItemModel.ExpiresOn = GetCacheProperty(ProcessInfoUtcExpires, cacheEntry) as DateTime?;
cacheItemModel.SlidingExpiration = GetCacheProperty(ProcessInfoSlidingExpiration, cacheEntry) as TimeSpan?;
cacheModel.CacheItems.Add(cacheItemModel);
}
catch (Exception)
{
return false;
}
}
return cacheModel;
}
示例8: GetData
public override object GetData(ITabContext context)
{
var plugin = Plugin.Create("No", "Started", "Duration", "Command", "Parameters");
var requestContext = context.GetRequestContext<HttpContextBase>();
List<LogItem> items = LogItemHandler.GetLogList(requestContext);
if (items == null)
return plugin;
var count = 0;
foreach (var item in items)
{
plugin.AddRow()
.Column(count++)
.Column(String.Format("{0:#,0}", item.Time.Subtract(requestContext.Timestamp).TotalMilliseconds))
.Column(item.Duration.HasValue ? String.Format("{0:#,0}", item.Duration.Value.TotalMilliseconds) : null)
.Column(item.Command)
.Column(item.Params.Count > 0
? new[] { new object[] { "Name", "Type", "Value" } }.Concat(item.Params.Select(p => new object[]
{
p.Name,
p.Type,
p.Value,
}))
: null);
}
return plugin;
}
示例9: GetData
public override object GetData(ITabContext context)
{
var glimpseResult = new List<object[]>();
var filepath = LoadCode("glimpse.csx");
if (!File.Exists(filepath))
{
glimpseResult.Add(new[] { "Script result", "No code found" });
return glimpseResult;
}
var code = File.ReadAllText(filepath);
glimpseResult.Add(new object[] {"Executed code", code});
var host = new ScriptCsHost();
host.Root.Executor.Initialize(new[] { "System.Web" }, new[] { new GlimpseContextScriptPack(context), });
host.Root.Executor.AddReferenceAndImportNamespaces(new[] { typeof(ITabContext), typeof(AspNetTab), typeof(ScriptCsTab), typeof(IScriptExecutor) });
var result = host.Root.Executor.ExecuteScript(code, new string[0]);
host.Root.Executor.Terminate();
if (result.CompileExceptionInfo != null) glimpseResult.Add(new object[] { "Compilation exception", result.CompileExceptionInfo.SourceException.Message });;
if (result.ExecuteExceptionInfo != null) glimpseResult.Add(new object[] { "Execution exception", result.ExecuteExceptionInfo.SourceException.Message }); ;
glimpseResult.Insert(0, new[] { "Script result", result.ReturnValue });
return glimpseResult;
}
示例10: GetData
public override object GetData(ITabContext context)
{
var plugin = Plugin.Create("Level", "Timestamp", "Message", "Properties");
foreach (var item in context.GetMessages<LogEventItem>())
{
var properties = item.LogEvent.Properties
.Select(pv => new { Name = pv.Key, Value = GlimpsePropertyFormatter.Simplify(pv.Value) })
.ToList();
if (item.LogEvent.Exception != null)
properties.Add(new { Name = "Exception", Value = (object)item.LogEvent.Exception });
properties = properties.OrderBy(p => p.Name).ToList();
var row = plugin.AddRow();
row.Column(item.LogEvent.Level.ToString());
row.Column(item.LogEvent.Timestamp.ToString("HH:mm:ss.fff", item.FormatProvider));
row.Column(item.LogEvent.RenderMessage(item.FormatProvider)).Strong();
row.Column(properties);
ApplyRowLevelStyle(item.LogEvent.Level, row);
}
return plugin;
}
示例11: GetData
public override object GetData(ITabContext context)
{
var timelineMessages = context.GetMessages<ITimelineMessage>()
.Where(m => m.EventName.StartsWith("WAZStorage:")).Cast<WindowsAzureStorageTimelineMessage>();
var model = new StorageModel();
if (timelineMessages != null)
{
model.Statistics.TotalStorageTx = timelineMessages.Count();
model.Statistics.TotalBlobTx = timelineMessages.Count(m => m.EventName.StartsWith("WAZStorage:Blob"));
model.Statistics.TotalTableTx = timelineMessages.Count(m => m.EventName.StartsWith("WAZStorage:Table"));
model.Statistics.TotalQueueTx = timelineMessages.Count(m => m.EventName.StartsWith("WAZStorage:Queue"));
model.Statistics.TotalTrafficToStorage = timelineMessages.Sum(m => m.RequestSize).ToBytesHuman();
model.Statistics.TotalTrafficFromStorage = timelineMessages.Sum(m => m.ResponseSize).ToBytesHuman();
model.Statistics.PricePerTenThousandPageViews = string.Format("${0}", model.Statistics.TotalStorageTx * 1000 * 0.0000001 + timelineMessages.Sum(m => m.ResponseSize) * 10000 * (0.12 / 1024 / 1024 / 1024));
model.Requests = FlattenRequests(timelineMessages);
model.Warnings = AnalyzeMessagesForWarnings(timelineMessages);
return model;
}
return "No storage transactions have been utilized for this request.";
}
示例12: GetData
public override object GetData(ITabContext context)
{
TabSection plugin = Plugin.Create("No", "Started", "Duration", "Method", "Index", "Document", "Query");
var requestContext = context.GetRequestContext<HttpContextBase>();
List<RequestItem> items = RequestHandler.GetLogList(requestContext);
if (items ==null|| !items.Any())
return null;
int count = 0;
foreach (RequestItem item in items)
{
plugin.AddRow()
.Column(count++)
.Column(String.Format("{0:#,0}", item.Time.Subtract(requestContext.Timestamp).TotalMilliseconds))
.Column(item.Duration.HasValue
? String.Format("{0:#,0}", item.Duration.Value.TotalMilliseconds)
: null)
.Column(item.Method)
.Column(item.Index)
.Column(item.Document)
.Column(item.Query);
}
return plugin;
}
示例13: HandleNullViewRenderMessageCollection
public void HandleNullViewRenderMessageCollection(Views sut, ITabContext context)
{
context.TabStore.Setup(ds => ds.Get(typeof(IList<ViewEngine.FindViews.Message>).AssemblyQualifiedName)).Returns(new List<ViewEngine.FindViews.Message>());
context.TabStore.Setup(ds => ds.Get(typeof(IList<View.Render.Message>).AssemblyQualifiedName)).Returns<List<View.Render.Message>>(null);
Assert.DoesNotThrow(() => sut.GetData(context));
}
示例14: GetData
public override object GetData(ITabContext context)
{
try
{
var sitecoreData = _sitecoreRequest.GetData();
if (!sitecoreData.HasData()) return null;
var itemSummary = new ItemSummary(sitecoreData).Create();
if (string.IsNullOrEmpty(itemSummary)) return null;
var plugin = Plugin.Create("Item", itemSummary);
var itemSection = new ItemSection(sitecoreData).Create();
var contextSection = new ContextSection(sitecoreData).Create();
var serverSection = new ServerSection(sitecoreData).Create();
if (itemSection != null)
plugin.AddRow().Column("Item").Column(itemSection).Selected();
if (contextSection != null)
plugin.AddRow().Column("Context").Column(contextSection).Quiet();
if (serverSection != null)
plugin.AddRow().Column("Server").Column(serverSection);
return plugin;
}
catch (Exception ex)
{
return new { Exception = ex };
}
}
示例15: MatchConstraintMessageToRoute
public void MatchConstraintMessageToRoute(Routes tab, ITabContext context, System.Web.Routing.IRouteConstraint constraint)
{
var route = new System.Web.Routing.Route("url", new System.Web.Routing.RouteValueDictionary { { "Test", "Other" } }, new System.Web.Routing.RouteValueDictionary { { "Test", constraint } }, new System.Web.Routing.RouteValueDictionary { { "Data", "Tokens" } }, new System.Web.Routing.PageRouteHandler("~/Path"));
System.Web.Routing.RouteTable.Routes.Clear();
System.Web.Routing.RouteTable.Routes.Add(route);
var routeMessage = new RouteBase.GetRouteData.Message(route.GetHashCode(), new System.Web.Routing.RouteData(), "routeName")
.AsSourceMessage(route.GetType(), null)
.AsTimedMessage(new TimerResult { Duration = TimeSpan.FromMilliseconds(19) });
var constraintMessage = new RouteBase.ProcessConstraint.Message(new RouteBase.ProcessConstraint.Arguments(new object[] { (HttpContextBase)null, constraint, "test", (System.Web.Routing.RouteValueDictionary)null, System.Web.Routing.RouteDirection.IncomingRequest }), route.GetHashCode(), true)
.AsTimedMessage(new TimerResult { Duration = TimeSpan.FromMilliseconds(25) })
.AsSourceMessage(route.GetType(), null);
context.TabStore.Setup(mb => mb.Contains(typeof(IList<RouteBase.ProcessConstraint.Message>).AssemblyQualifiedName)).Returns(true).Verifiable();
context.TabStore.Setup(mb => mb.Contains(typeof(IList<RouteBase.GetRouteData.Message>).AssemblyQualifiedName)).Returns(true).Verifiable();
context.TabStore.Setup(mb => mb.Get(typeof(IList<RouteBase.ProcessConstraint.Message>).AssemblyQualifiedName)).Returns(new List<RouteBase.ProcessConstraint.Message> { constraintMessage }).Verifiable();
context.TabStore.Setup(mb => mb.Get(typeof(IList<RouteBase.GetRouteData.Message>).AssemblyQualifiedName)).Returns(new List<RouteBase.GetRouteData.Message> { routeMessage }).Verifiable();
var model = tab.GetData(context) as List<RouteModel>;
var itemModel = model[0];
Assert.NotNull(model);
Assert.Equal(1, model.Count);
Assert.NotNull(itemModel.Constraints);
Assert.True(itemModel.IsMatch);
Assert.Equal("Test", ((List<RouteConstraintModel>)itemModel.Constraints)[0].ParameterName);
Assert.Equal(true, ((List<RouteConstraintModel>)itemModel.Constraints)[0].IsMatch);
Assert.NotNull(itemModel.DataTokens);
Assert.Equal("Tokens", itemModel.DataTokens["Data"]);
Assert.NotNull(itemModel.RouteData);
Assert.Equal("Other", ((List<RouteDataItemModel>)itemModel.RouteData)[0].DefaultValue);
}