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


C# Resource.GetType方法代码示例

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


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

示例1: Format

        public static JToken Format(this MediaTypeFormatter formatter, Resource resource)
        {
            var content = new StringContent(String.Empty);
            var type = resource.GetType();

            using (var stream = new MemoryStream())
            {
                formatter.WriteToStreamAsync(type, resource, stream, content, null);
                stream.Seek(0, SeekOrigin.Begin);
                var serialisedResult = new StreamReader(stream).ReadToEnd();
                return JToken.Parse(serialisedResult);
            }
        }
开发者ID:hyperfriendly,项目名称:Hyperfriendly.WebApi,代码行数:13,代码来源:MediaTypeFormatterExtensions.cs

示例2: LoadTopListForResource

 public TopList LoadTopListForResource(Resource res)
 {
     TopList t = new TopList(this);
     if (res.GetType() == typeof(Artist))
     {
         DataSet topTracks = MakeDataSet("SELECT TOP 5 * FROM track, artist, release WHERE track.artist = artist.id AND track.album = release.id AND artist.identifier = '" + res.Identifier + "' ORDER BY track.popularity DESC");
         t.TopTracks = new TrackCollection(this, t, new List<Track>());
         t.TopAlbums = new ReleaseCollection(this,  new List<Release>());
         foreach (DataRow row in topTracks.Tables[0].Rows)
         {
             Track _track = TrackFromDataRow(row);
             t.TopTracks.Add(_track);
         }
         if (topTracks.Tables[0].Rows.Count == 0)
             return null;
         return t;
     }
     if (res.GetType() == typeof(Country))
     {
         DataSet topTracks = MakeDataSet("SELECT TOP 5  * FROM track, artist, release WHERE track.artist = artist.id AND track.album = release.id ORDER BY track.popularity DESC");
         t.TopTracks = new TrackCollection(this, t, new List<Track>());
         t.TopAlbums = new ReleaseCollection(this,  new List<Release>());
         foreach (DataRow row in topTracks.Tables[0].Rows)
         {
             Track _track = TrackFromDataRow(row);
             t.TopTracks.Add(_track);
         }
         DataSet topAlbums= MakeDataSet("SELECT TOP 100 * FROM artist, release WHERE release.artist = artist.id ORDER BY release.popularity DESC");
         foreach (DataRow row in topTracks.Tables[0].Rows)
         {
             Release _album = ReleaseFromDataRow(row);
             t.TopAlbums.Add(_album);
         }
         if (topAlbums.Tables[0].Rows.Count == 0)
             return null;
         return t;
     }
     return null;
 }
开发者ID:krikelin,项目名称:BungaSpotify-2009,代码行数:39,代码来源:DummyService.cs

示例3: SetObjectToInspect

        /// <summary>
        /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
        private void SetObjectToInspect(String resourcePath)
        {
            activeResource = ProjectLibrary.Load<Resource>(resourcePath);

            if (activeResource == null)
                return;

            currentType = InspectorType.Resource;

            inspectorScrollArea = new GUIScrollArea();
            GUI.AddElement(inspectorScrollArea);
            inspectorLayout = inspectorScrollArea.Layout;

            GUIPanel titlePanel = inspectorLayout.AddPanel();
            titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);

            GUILayoutY titleLayout = titlePanel.AddLayoutY();
            titleLayout.SetPosition(PADDING, PADDING);

            string name = Path.GetFileNameWithoutExtension(resourcePath);
            string type = activeResource.GetType().Name;

            LocString title = new LocEdString(name + " (" + type + ")");
            GUILabel titleLabel = new GUILabel(title);

            titleLayout.AddFlexibleSpace();
            GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();
            titleLabelLayout.AddElement(titleLabel);
            titleLayout.AddFlexibleSpace();

            GUIPanel titleBgPanel = titlePanel.AddPanel(1);

            GUITexture titleBg = new GUITexture(null, EditorStyles.InspectorTitleBg);
            titleBgPanel.AddElement(titleBg);

            inspectorLayout.AddSpace(COMPONENT_SPACING);

            inspectorResource = new InspectorResource();
            inspectorResource.panel = inspectorLayout.AddPanel();

            var persistentProperties = persistentData.GetProperties(activeResource.UUID);

            inspectorResource.inspector = InspectorUtility.GetInspector(activeResource.GetType());
            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResource, persistentProperties);

            inspectorLayout.AddFlexibleSpace();
        }
开发者ID:Ruu,项目名称:BansheeEngine,代码行数:51,代码来源:InspectorWindow.cs


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