當前位置: 首頁>>代碼示例>>C#>>正文


C# ContentObject.GetType方法代碼示例

本文整理匯總了C#中vwarDAL.ContentObject.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# ContentObject.GetType方法的具體用法?C# ContentObject.GetType怎麽用?C# ContentObject.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vwarDAL.ContentObject的用法示例。


在下文中一共展示了ContentObject.GetType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateContentObject

        /// <summary>
        /// 
        /// </summary>
        /// <param name="co"></param>
        public void UpdateContentObject(ContentObject co)
        {
            System.Data.Odbc.OdbcConnection conn = GetConnection();
            {

                int id = 0;
                using (var command = conn.CreateCommand())
                {
                    command.CommandText = "{CALL UpdateContentObject(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); }";
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    var properties = co.GetType().GetProperties();
                    foreach (var prop in properties)
                    {
                        if (prop.PropertyType == typeof(String) && prop.GetValue(co, null) == null)
                        {
                            prop.SetValue(co, String.Empty, null);
                        }
                    }
                    FillCommandFromContentObject(co, command);
                    id = int.Parse(command.ExecuteScalar().ToString());

                }
                SaveKeywords(conn, co, id);

            }
        }
開發者ID:adlnet,項目名稱:3D-Repository,代碼行數:30,代碼來源:MySqlMetadataStore.cs

示例2: GetContentObjectById

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="updateViews"></param>
        /// <param name="getReviews"></param>
        /// <param name="revision"></param>
        /// <returns></returns>
        public ContentObject GetContentObjectById(string pid, bool updateViews, bool getReviews = true, int revision = -1)
        {
            if (String.IsNullOrEmpty(pid))
            {
                return null;
            }
            List<ContentObject> results = new List<ContentObject>();
            ContentObject resultCO = null;
            if (false)//(_Memory.ContainsKey(co.PID))
            {
                //co = _Memory[co.PID];
            }
            else
            {
                System.Data.Odbc.OdbcConnection conn = GetConnection();
                {

                    using (var command = conn.CreateCommand())
                    {
                        command.CommandText = "{CALL GetContentObject(?);}";
                        command.CommandType = System.Data.CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("targetpid", pid);
                        //command.Parameters.AddWithValue("pid", pid);
                        using (var result = command.ExecuteReader())
                        {
                            int NumberOfRows = 0;
                            while (result.Read())
                            {
                                NumberOfRows++;
                                var co = new ContentObject()
                                {
                                    PID = pid,
                                    Reviews = new List<Review>()
                                };

                                var properties = co.GetType().GetProperties();
                                foreach (var prop in properties)
                                {
                                    if (prop.PropertyType == typeof(String) && prop.GetValue(co, null) == null)
                                    {
                                        prop.SetValue(co, String.Empty, null);
                                    }
                                }

                                FillContentObjectFromResultSet(co, result);
                                LoadTextureReferences(co, conn);
                                LoadMissingTextures(co, conn);
                                LoadSupportingFiles(co, conn);
                                LoadReviews(co, conn);
                                co.Keywords = LoadKeywords(conn, co.PID);

                                results.Add(co);
                            }
                            ContentObject highest = null;
                            if (results.Count > 0)
                            {
                                if (revision == -1)
                                {
                                    highest = (from r in results
                                               orderby r.Revision descending
                                               select r).First();
                                }
                                else
                                {

                                    highest = (from r in results
                                               where r.Revision == revision
                                               select r).First();

                                }
                                resultCO = highest;
                            }
                            else
                                return null;
                        }

                    }
                }
            }
            if (updateViews)
            {
                System.Data.Odbc.OdbcConnection secondConnection = GetConnection();
                {

                    using (var command = secondConnection.CreateCommand())
                    {
                        command.CommandText = "{CALL IncrementViews(?)}";
                        command.CommandType = System.Data.CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("targetpid", pid);
                        command.ExecuteNonQuery();
                    }
//.........這裏部分代碼省略.........
開發者ID:adlnet,項目名稱:3D-Repository,代碼行數:101,代碼來源:MySqlMetadataStore.cs


注:本文中的vwarDAL.ContentObject.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。