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


C# Story.Attribute_Add方法代码示例

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


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

示例1: EnsureAttributeExists

 private static Attribute EnsureAttributeExists(Attribute attrib, Story destination)
 {
     var attDest = destination.Attribute_FindByName(attrib.Name);
     if (attDest == null)
     {
         attDest = destination.Attribute_Add(attrib.Name, attrib.Type);
         foreach (var lab in attrib.Labels)
         {
             attDest.Labels_Add(lab.Text, lab.Color);
         }
     }
     return attDest;
 }
开发者ID:Rusty,项目名称:RiskBowTieNWR,代码行数:13,代码来源:RiskModel.cs

示例2: LoadPanelData

        private static void LoadPanelData(Item item, Story story, string category, string[] attributes, double[] widths)
        {
            if (attributes.Length+2 != widths.Length)
            {
                throw new Exception("attributes and widths must match");
            }

            var sortby = story.Attribute_FindByName("SortOrder");
            
            // add attributes so it won't blow up below
            foreach (var attribute in attributes)
            {
                if (story.Attribute_FindByName(attribute) == null)
                    story.Attribute_Add(attribute, Attribute.AttributeType.List);
            }

            var table1 = new HTMLTable(attributes.Length + 2);
            int col = 0;
            table1.SetValue(0, col++, "#");
            table1.SetValue(0, col++, "Name");
            foreach (var attribute in attributes)
            {
                table1.SetValue(0, col++, attribute);
            }

            int row = 1;
            foreach (var item2 in story.Items.OrderBy(i => i.GetAttributeValueAsDouble(sortby)))
            {
                if (item2.Category.Name == category)
                {
                    col = 0;
                    table1.SetValue(row, col++, item2.GetAttributeValueAsDouble(sortby).ToString());
                    table1.SetValue(row, col++, item2.Name);
                    foreach (var attribute in attributes)
                    {
                        //Debug.WriteLine($"Attrubute = '{attribute}'");
                        var att = story.Attribute_FindByName(attribute);
                        //Debug.WriteLine($"Attrubute.Name = '{att.Name}'");
                        var text = item2.GetAttributeValueAsTextWithPrefixAndSuffix(att);
                        //Debug.WriteLine($"Text = '{text}'");
                        string color = item2.GetAttributeValueAsColorText(att);
                        table1.SetValue(row, col++, text, color);
                    }
                    row++;
                }
            }

            // set the col width
            for (int c=0;c<widths.Length; c++)
            {
                table1.SetColWidth(c, widths[c]);
            }

            var panel = item.Panel_FindByTitle(category);
            if (panel == null)
                panel = item.Panel_Add(category, Panel.PanelType.RichText);
            panel.Data = table1.GetHTML;

        }
开发者ID:Rusty,项目名称:RiskBowTieNWR,代码行数:59,代码来源:RiskModel.cs

示例3: EnsureStoryHasRightStructure

 public static void EnsureStoryHasRightStructure(Story story, Logger log)
 {
     // make sure all categories we need exist
     foreach (var c in _categoryNames)
     {
         if (story.Category_FindByName(c) == null) // catagory does not exist
         {
             log.Log($"Adding Category '{c}'");
             story.Category_AddNew(c);
         }
     }
     // make sure all attributes we need exist
     foreach (var a in _textFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Text Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Text);
         }
     }
     foreach (var a in _dateFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Date Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Date);
         }
     }
     foreach (var a in _numberFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding Number Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.Numeric);
         }
     }
     foreach (var a in _listFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding List Attribute '{a}'");
             story.Attribute_Add(a, Attribute.AttributeType.List);
         }
     }
     // reserved list attributes need VL,L,M,H,VH values
     foreach (var a in _listRiskFields)
     {
         if (story.Attribute_FindByName(a) == null)
         {
             log.Log($"Adding List Attribute '{a}'");
             var att = story.Attribute_Add(a, Attribute.AttributeType.List);
             foreach (var l in _riskLabels)
             {
                 log.Log($"Adding List Label '{l}'");
                 att.Labels_Add(l);
             }
         }
     }
 }
开发者ID:Rusty,项目名称:RiskBowTieNWR,代码行数:59,代码来源:RiskModel.cs


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