当前位置: 首页>>代码示例>>C#>>正文


C# XDoc.WithXslTransform方法代码示例

本文整理汇总了C#中XDoc.WithXslTransform方法的典型用法代码示例。如果您正苦于以下问题:C# XDoc.WithXslTransform方法的具体用法?C# XDoc.WithXslTransform怎么用?C# XDoc.WithXslTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XDoc的用法示例。


在下文中一共展示了XDoc.WithXslTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetServices

 internal Yield GetServices(DreamContext context, DreamMessage request, Result<DreamMessage> response)
 {
     XDoc result = new XDoc("services");
     result.WithXslTransform(context.AsPublicUri(context.Env.Self).At("resources", "services.xslt").Path);
     lock(_services) {
         result.Attr("count", _services.Count);
         foreach(KeyValuePair<string, ServiceEntry> entry in _services) {
             result.Start("service");
             result.Elem("path", entry.Key);
             result.Elem("uri", entry.Value.Uri);
             if(entry.Value.Owner != null) {
                 result.Elem("uri.owner", entry.Value.Owner);
             }
             if(entry.Value.SID != null) {
                 result.Elem("sid", entry.Value.SID);
             }
             result.Elem("type", entry.Value.Service.GetType().FullName);
             result.End();
         }
     }
     response.Return(DreamMessage.Ok(result));
     yield break;
 }
开发者ID:maximmass,项目名称:DReAM,代码行数:23,代码来源:DreamHostService.cs

示例2: GetDefaultErrorResponse

 private static XDoc GetDefaultErrorResponse(DreamStatus status, string title, string message) {
     XDoc result = new XDoc("error");
     DreamContext context = DreamContext.CurrentOrNull;
     if((context != null) && (context.Env.Self != null)) {
         result.WithXslTransform(context.AsPublicUri(context.Env.Self).At("resources", "error.xslt").Path);
     }
     result.Elem("status", (int)status).Elem("title", title).Elem("message", message);
     if(context != null) {
         result.Elem("uri", context.Uri);
     }
     return result;
 }
开发者ID:bjorg,项目名称:DReAM,代码行数:12,代码来源:dreammessage.cs

示例3: GetStatus

        private Yield GetStatus(DreamContext context, DreamMessage request, Result<DreamMessage> response)
        {
            DateTime now = DateTime.UtcNow;
            XDoc result = new XDoc("status");
            result.WithXslTransform(context.AsPublicUri(context.Env.Self).At("resources", "status.xslt").Path);
            XUri self = Self.Uri.With("apikey", context.GetParam("apikey", null));

            // host information
            double age = Math.Max((now - _created).TotalSeconds, 1);
            result.Start("host").Attr("created", _created).Attr("age", age).Attr("requests", _requestCounter).Attr("rate", _requestCounter / age);
            result.Elem("uri.local", _localMachineUri.ToString());
            result.Elem("uri.public", _publicUri);

            // host/aliases
            result.Start("aliases").Attr("count", _aliases.Count).Attr("href", self.At("status", "aliases")).End();

            // connections
            result.Start("connections").Attr("count", _connectionCounter).Attr("limit", _connectionLimit).End();

            // activities
            lock(_activities) {
                result.Start("activities").Attr("count", _activities.Count).Attr("href", self.At("status", "activities"));
                foreach(Tuplet<DateTime, string> description in _activities.Values) {
                    result.Start("description").Attr("created", description.Item1).Attr("age", (now - description.Item1).TotalSeconds).Value(description.Item2).End();
                }
                result.End();
            }

            // infos
            lock(_infos) {
                result.Start("infos").Attr("count", _infos.Count);
                foreach(KeyValuePair<string, Tuplet<int, string>> entry in _infos) {
                    result.Start("info").Attr("source", entry.Key).Attr("hits", entry.Value.Item1).Attr("rate", entry.Value.Item1 / age).Value(entry.Value.Item2).End();
                }
                result.End();
            }

            // host/services information
            result.Start("services").Attr("count", _services.Count).Attr("href", self.At("services")).End();

            // host/features
            result.Start("features").Attr("href", self.At("status", "features")).End();

            // host/cache
            long size = 0;
            int count = 0;
            lock(_responseCache) {
                foreach(Dictionary<object, DreamMessage> cache in _responseCache.Values) {
                    count += cache.Count;
                    foreach(DreamMessage message in cache.Values) {
                        size += message.ToBytes().LongLength;
                    }
                }
            }
            result.Start("cache").Attr("count", count).Attr("size", size).Attr("hits", _responseCacheHits).Attr("misses", _responseCacheMisses).End();

            // end host information
            result.End();

            // system information
            result.Start("system");

            // system/memory information
            result.Elem("memory.used", GC.GetTotalMemory(false));

            // system/thread information
            int workerThreads;
            int completionThreads;
            int dispatcherThreads;
            Async.GetAvailableThreads(out workerThreads, out completionThreads, out dispatcherThreads);
            int maxWorkerThreads;
            int maxCompletionThreads;
            int maxDispatcherThreads;
            Async.GetMaxThreads(out maxWorkerThreads, out maxCompletionThreads, out maxDispatcherThreads);
            result.Elem("workerthreads.max", maxWorkerThreads);
            result.Elem("workerthreads.used", maxWorkerThreads - workerThreads);
            result.Elem("completionthreads.max", maxCompletionThreads);
            result.Elem("completionthreads.used", maxCompletionThreads - completionThreads);
            result.Elem("dispatcherthreads.max", maxDispatcherThreads);
            result.Elem("dispatcherthreads.used", maxDispatcherThreads - dispatcherThreads);

            // timer information
            var taskTimerStats = TaskTimerFactory.GetStatistics();
            result.Start("timers.queued").Attr("href", self.At("status", "timers")).Value(taskTimerStats.QueuedTimers).End();
            result.Start("timers.pending").Attr("href", self.At("status", "timers")).Value(taskTimerStats.PendingTimers).End();
            result.Elem("timers.counter", taskTimerStats.Counter);
            result.Elem("timers.last", taskTimerStats.Last);

            // rendez-vous events
            result.Start("async").Attr("count", RendezVousEvent.PendingCounter + AResult.PendingCounter);
            lock(RendezVousEvent.Pending) {
                foreach(var entry in RendezVousEvent.Pending.Values) {
                    result.Start("details");
                    if(entry.Key != null) {
                        var dc = entry.Key.GetState<DreamContext>();
                        if(dc != null) {
                            result.Elem("verb", dc.Verb);
                            result.Elem("uri", dc.Uri);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:maximmass,项目名称:DReAM,代码行数:101,代码来源:DreamHostService.cs


注:本文中的XDoc.WithXslTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。