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


C# IDataItem.GetType方法代码示例

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


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

示例1: CommentsCount

        public static MvcHtmlString CommentsCount(this HtmlHelper helper, string navigateUrl, IDataItem item)
        {
            if (item == null)
                return MvcHtmlString.Empty;

            var contentItem = item as Content;
            bool? allowComments = contentItem != null ? contentItem.AllowComments : null;
            var threadKey = ControlUtilities.GetLocalizedKey(item.Id, null, CommentsBehaviorUtilities.GetLocalizedKeySuffix(item.GetType().FullName));
            var itemTypeFullName = item.GetType().FullName;

            return CommentsHelpers.CommentsCount(helper, navigateUrl, threadKey, itemTypeFullName, allowComments);
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:12,代码来源:CommentsHelpers.cs

示例2: ProcessMessageAction

        /// <summary>
        /// put this item in the correct tables
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        protected override bool ProcessMessageAction(string packet, IDataItem item)
        {
            try
            {
                //get the mod field
                long mod = (long)Convert.ChangeType(item.GetType().GetField(Table.ModField).GetValue(item), typeof(long));
                long bucket = mod % ComputeNode.GlobalBucketCount;
                
                //send the packet along
                Catalog.Buckets[bucket].BucketDataTables[Table.TableName].AddOrUpdate(item.PrimaryKey, item);
                Catalog.CatalogDataTables[Table.TableName].AddOrUpdate(item.PrimaryKey, item);

                return true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            return false;
        }
开发者ID:yonglehou,项目名称:Bermuda,代码行数:26,代码来源:NetSaturator.cs

示例3: ProcessMessageAction

        /// <summary>
        /// send this packet along to the correct bermuda node to be saved
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        protected override bool ProcessMessageAction(string packet, IDataItem item)
        {
            try
            {
                //get the mod field
                long mod = (long)Convert.ChangeType(item.GetType().GetField(Table.ModField).GetValue(item), typeof(long));
                long bucket = mod % ComputeNode.GlobalBucketCount;
                long instance = bucket % AddressMap.Count;
                string address = AddressMap[instance];

                //send the packet along
                Client.Send(packet, address);

                return true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            return false;
        }
开发者ID:yonglehou,项目名称:Bermuda,代码行数:27,代码来源:NetGateway.cs

示例4: ProcessRow

        /// <summary>
        /// process a row
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="item"></param>
        /// <param name="table_metadata"></param>
        private void ProcessRow(IDataReader dr, IDataItem item, IReferenceDataTable table, bool update_last_update)
        {
            //get the data
            List<Tuple<string,object>> data = new List<Tuple<string,object>>();
            for (int x = 0; x < dr.FieldCount; x++)
            {
                //get the column metadata
                string column_name = dr.GetName(x);
                IColumnMetadata col = null;
                if(table.TableMetadata.ColumnsMetadata.ContainsKey(column_name))
                    col = table.TableMetadata.ColumnsMetadata[column_name];

                if (col != null)
                {
                    //get the value
                    object value = dr[x];
                    data.Add(new Tuple<string, object>(column_name, value));

                    try
                    {
                        //check if the column is a collection
                        if (col.ColumnType == typeof(List<Tuple<List<long>, long>>))
                        {
                            string string_value = value.ToString();
                            List<Tuple<List<long>, long>> list = new List<Tuple<List<long>, long>>();
                            
                            //get the relationship for this field
                            var rel = table.Catalog.CatalogMetadata.Relationships.Values.FirstOrDefault(r => r.ParentChildCollection == column_name);

                            //check if null
                            if (!dr.IsDBNull(x))
                            {
                                foreach (var s in string_value.Split(','))
                                {
                                    string[] tuple = s.Split('|');
                                    if (tuple.Length == 2)
                                    {
                                        long item1;
                                        long item2;
                                        if (Int64.TryParse(tuple[0], out item1))
                                        {
                                            if (Int64.TryParse(tuple[1], out item2))
                                            {
                                                if (rel != null && rel.DistinctRelationship)
                                                {
                                                    var existing = list.FirstOrDefault(t => t.Item2 == item2);
                                                    if (existing == null)
                                                    {
                                                        List<long> sub_list = new List<long>();
                                                        sub_list.Add(item1);
                                                        list.Add(new Tuple<List<long>, long>(sub_list, item2));
                                                    }
                                                    else
                                                    {
                                                        existing.Item1.Add(item1);
                                                    }
                                                }
                                                else
                                                {
                                                    List<long> sub_list = new List<long>();
                                                    sub_list.Add(item1);
                                                    list.Add(new Tuple<List<long>, long>(sub_list, item2));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            //List<long> list = string_value.Split(',').Select(t => TryParseInt64(t))
                            //                                  .Where(i => i.HasValue)
                            //                                  .Select(i => i.Value)
                            //                                  .ToList();
                            item.GetType().GetField(col.FieldMapping).SetValue(item, list);
                        }
                        else
                        {
                            //check if null
                            if (!dr.IsDBNull(x))
                            {
                                //set the value with reflection
                                item.GetType().GetField(col.FieldMapping).SetValue(item, value);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Trace.WriteLine(ex.ToString());
                    }
                        
                    //update the last update value
                    if (column_name == table.TableMetadata.SaturationUpdateField && update_last_update)
                        table.UpdateLastValue(value);
                }
            }
//.........这里部分代码省略.........
开发者ID:yonglehou,项目名称:Bermuda,代码行数:101,代码来源:DatabaseSaturator.cs

示例5: DeleteItem

        /// <summary>
        /// delete an item given its catalog table
        /// </summary>
        /// <param name="item"></param>
        /// <param name="table"></param>
        public void DeleteItem(IDataItem item, bool HardDelete)
        {
            //the table to call delete item with
            IReferenceDataTable delete_table = null;

            //check if this is a reference table
            if (TableMetadata.ReferenceTable)
            {
                //get the reference table
                delete_table = (IReferenceDataTable)this;
            }
            else
            {
                //get the mod field
                IColumnMetadata column = TableMetadata.ColumnsMetadata[TableMetadata.ModField];

                //get the value to mode
                object obj = item.GetType().GetField(column.FieldMapping).GetValue(item);
                Int64 id = Convert.ToInt64(obj);

                //mod to get the bucket index
                Int64 bucket = id % TableMetadata.CatalogMetadata.Catalog.ComputeNode.GlobalBucketCount;

                //get the bucket table
                delete_table = TableMetadata.CatalogMetadata.Catalog.Buckets[bucket].BucketDataTables[TableMetadata.TableName];
            }
            //call delete
            if (delete_table != null)
                DeleteItem(item, delete_table, HardDelete);
        }
开发者ID:yonglehou,项目名称:Bermuda,代码行数:35,代码来源:DataTable.cs

示例6: AddItem

        /// <summary>
        /// add data item to the table
        /// </summary>
        /// <param name="item"></param>
        public bool AddItem(IDataItem item)
        {
            object obj;
            bool bRet = false;

            //check if table type to handle relations
            if (this is RelationshipDataTable)
            {
                //parse the table's relationships
                RelationshipDataTable rel_table = this as RelationshipDataTable;

                //get the fields
                long parent_id = Convert.ToInt64(item.GetType().GetField(rel_table.RelationshipMetadata.ParentRelationshipField).GetValue(item));
                long child_id = Convert.ToInt64(item.GetType().GetField(rel_table.RelationshipMetadata.ChildRelationshipField).GetValue(item));

                //lock the resource
                lock (rel_table.RelationshipParentLookup)
                {
                    //add the relation
                    //if (ReferenceEquals(AddOrUpdate(item.PrimaryKey, item), item))
                    {
                        //look for the parent item
                        IBucketDataTable bucket_table = rel_table.Bucket.BucketDataTables[rel_table.RelationshipMetadata.ParentTable.TableName];
                        IDataItem parent_item;
                        if (bucket_table.TryGetValue(parent_id, bucket_table.TableMetadata.DataType, out obj))
                        {
                            //add to the parent item
                            parent_item = (IDataItem)obj;
                            //List<long> list = (List<long>)parent_item.GetType().GetField(rel_table.RelationshipMetadata.ParentChildCollection).GetValue(parent_item);
                            List<Tuple<List<long>, long>> list = (List<Tuple<List<long>, long>>)parent_item.GetType().GetField(rel_table.RelationshipMetadata.ParentChildCollection).GetValue(parent_item);
                            lock (parent_item)
                            {
                                try
                                {
                                    //check the list to init
                                    if(list == null)
                                        list = new List<Tuple<List<long>, long>>();
                                    
                                    //check for no items
                                    if (list.Count == 0)
                                    {
                                        List<long> sub_list = new List<long>();
                                        sub_list.Add(item.PrimaryKey);
                                        list.Add(new Tuple<List<long>,long>(sub_list, child_id));
                                        bRet = true;
                                    }
                                    else
                                    {
                                        //get the sub list
                                        var tuple = list.FirstOrDefault(t => t.Item2 == child_id);
                                        if (tuple == null)
                                        {
                                            List<long> sub_list = new List<long>();
                                            sub_list.Add(item.PrimaryKey);
                                            list.Add(new Tuple<List<long>, long>(sub_list, child_id));
                                            bRet = true;
                                        }
                                        else
                                        {
                                            //is this a distinct relationship
                                            if (rel_table.RelationshipMetadata.DistinctRelationship)
                                            {
                                                //check if item is already added
                                                if (!tuple.Item1.Contains(item.PrimaryKey))
                                                {
                                                    tuple.Item1.Add(item.PrimaryKey);
                                                    bRet = true;
                                                }
                                            }
                                            else
                                            {
                                                if (!list.Any(t => t.Item1.Contains(item.PrimaryKey)))
                                                {
                                                    List<long> sub_list = new List<long>();
                                                    sub_list.Add(item.PrimaryKey);
                                                    list.Add(new Tuple<List<long>, long>(sub_list, child_id));
                                                    bRet = true;
                                                }
                                            }
                                        }
                                    }
                                    //check if should update the field
                                    if(bRet)
                                        parent_item.GetType().GetField(rel_table.RelationshipMetadata.ParentChildCollection).SetValue(parent_item, list);


                                    //if (!list.Any(t => t.Item2 == child_id))
                                    //{
                                    //    List<long> sub_list = new List<long>();
                                    //    sub_list.Add(item.PrimaryKey);
                                    //    list.Add(new Tuple<List<long>, long>(sub_list, child_id));
                                    //    if (rel_table.RelationshipMetadata.DistinctRelationship)
                                    //        parent_item.GetType().GetField(rel_table.RelationshipMetadata.ParentChildCollection).SetValue(parent_item, list);
                                    //    bRet = true;
                                    //}
                                }
//.........这里部分代码省略.........
开发者ID:yonglehou,项目名称:Bermuda,代码行数:101,代码来源:DataTable.cs

示例7: CreateItemViewModelInstance

 /// <summary>
 /// Creates an instance of the item view model by given data item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 protected ItemViewModel CreateItemViewModelInstance(IDataItem item)
 {
     if (item.GetType() == typeof(SitefinityProfile))
     {
         return new SitefinityProfileItemViewModel(item);
     }
     else
     {
         return new ItemViewModel(item);
     }
 }
开发者ID:rhullah,项目名称:feather-widgets,代码行数:16,代码来源:UsersListModel.cs

示例8: GetDataSourceName

        private static string GetDataSourceName(IDataItem item)
        {
            string dataSourceName = null;

            if (item != null && item is DynamicContent)
            {
                var moduleProvider = ModuleBuilderManager.GetManager().Provider;
                var itemType = item.GetType().FullName;

                var dynamicContentType = moduleProvider.GetDynamicModules()
                    .Where(m => m.Status == DynamicModuleStatus.Active)
                    .Join(moduleProvider.GetDynamicModuleTypes().Where(t => string.Concat(t.TypeNamespace, ".", t.TypeName) == itemType), m => m.Id, t => t.ParentModuleId, (m, t) => t)
                    .FirstOrDefault();

                if (dynamicContentType != null)
                {
                    dataSourceName = dynamicContentType.ModuleName;
                }
            }
            else if (item != null)
            {
                Type managerType;
                if (ManagerBase.TryGetMappedManagerType(item.GetType(), out managerType))
                {
                    dataSourceName = managerType.FullName;
                }
            }

            return dataSourceName;
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:30,代码来源:CommentsHelpers.cs

示例9: GetCommentsList

        private static MvcHtmlString GetCommentsList(HtmlHelper helper, IDataItem item, string title)
        {
            if (SystemManager.GetModule("Comments") == null || item == null)
            {
                return MvcHtmlString.Empty;
            }

            var itemTypeFullName = item.GetType().FullName;
            var itemProviderName = item.GetProviderName();

            var itemThreadKey = ControlUtilities.GetLocalizedKey(item.Id, null, CommentsBehaviorUtilities.GetLocalizedKeySuffix(itemTypeFullName));
            var itemGroupKey = ControlUtilities.GetUniqueProviderKey(GetDataSourceName(item), itemProviderName);

            var routeDictionary = new System.Web.Routing.RouteValueDictionary()
            {
                { "AllowComments", GetAllowComments(item) },
                { "ThreadKey", itemThreadKey },
                { "ThreadTitle", title },
                { "ThreadType", itemTypeFullName },
                { "GroupKey", itemGroupKey },
                { "DataSource", itemProviderName }
            };

            var controllerName = itemThreadKey.EndsWith(ReviewsSuffix, StringComparison.Ordinal) ? CommentsHelpers.ReviewsControllerName : CommentsHelpers.CommentsControllerName;

            MvcHtmlString result;
            try
            {
                result = helper.Action(CommentsHelpers.IndexActionName, controllerName, routeDictionary);
            }
            catch (HttpException)
            {
                result = MvcHtmlString.Empty;
            }
            catch (NullReferenceException)
            {
                //// Telerik.Sitefinity.Mvc.SitefinityMvcRoute GetOrderedParameters() on line 116 controllerType.GetMethods() throws null reference exception (controllerType is null).
                result = MvcHtmlString.Empty;
            }

            return result;
        }
开发者ID:RifasRazick,项目名称:feather,代码行数:42,代码来源:CommentsHelpers.cs


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