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


C# IItem类代码示例

本文整理汇总了C#中IItem的典型用法代码示例。如果您正苦于以下问题:C# IItem类的具体用法?C# IItem怎么用?C# IItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Configure

        /// <summary>
        /// Configures the files included in the template for VSIX packaging,
        /// and returns the Uri for the template.
        /// </summary>
        public IVsTemplate Configure(IItem templateItem, string displayName, string description, string path)
        {
            Guard.NotNull(() => templateItem, templateItem);

            // Calculate the new Identifier
            var unicySeed = Guid.NewGuid().ToString(@"N");
            var unicyIdentifier = unicySeed.Substring(unicySeed.Length - MaxUnicyLength);
            var remainingNamedLength = MaxTemplateIdLength - MaxUnicyLength - 1;
            var namedIdentifier = path.Substring(path.Length <= remainingNamedLength ? 0 : (path.Length - remainingNamedLength));
            var templateId = string.Format(CultureInfo.InvariantCulture, @"{0}-{1}", unicyIdentifier, namedIdentifier);

            // Update the vstemplate
            var template = VsTemplateFile.Read(templateItem.PhysicalPath);
            template.SetTemplateId(templateId);
            template.SetDefaultName(SanitizeName(displayName));
            template.SetName(displayName);
            template.SetDescription(description);
            VsHelper.CheckOut(template.PhysicalPath);
            VsTemplateFile.Write(template);

            UpdateDirectoryProperties(templateItem);

            // Set VS attributes on the vstemplate file
            if (template.Type == VsTemplateType.Item)
            {
                templateItem.Data.ItemType = @"ItemTemplate";
            }
            else
            {
                templateItem.Data.ItemType = @"ProjectTemplate";
            }

            return template;
        }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:38,代码来源:VsTemplateConfigurator.cs

示例2: Add

 public void Add(IItem item)
 {
     if (!itens.Contains(item)) {
         item.ApplyEffect(player);
         this.itens.Add(item);
     }
 }
开发者ID:pennajessica,项目名称:GodChallenge,代码行数:7,代码来源:Inventario.cs

示例3: Rent

 public Rent(IItem item, DateTime rentDate, DateTime deadline)
 {
     this.Item = item;
     this.RentDate = rentDate;
     this.Deadline = deadline;
     this.RentState = RentState.Pending;
 }
开发者ID:borko9696,项目名称:SoftwareUniversity,代码行数:7,代码来源:Rent.cs

示例4: InitializeContext

            public void InitializeContext()
            {
                this.textTemplateFile = this.solution.Find<IItem>().First();

                this.store.TransactionManager.DoWithinTransaction(() =>
                {
                    var patternModel = this.store.ElementFactory.CreateElement<PatternModelSchema>();
                    var pattern = patternModel.Create<PatternSchema>();
                    var view = pattern.CreateViewSchema();
                    var parent = view.CreateElementSchema();
                    this.element = parent.CreateAutomationSettingsSchema() as AutomationSettingsSchema;
                    this.settings = element.AddExtension<CommandSettings>();

                    this.settings.TypeId = typeof(GenerateModelingCodeCommand).Name;
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings { Name = Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TargetFileName) });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings { Name = Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TargetPath) });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings { Name = Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TemplateAuthoringUri) });
                    ((ICommandSettings)this.settings).Properties.Add(new PropertyBindingSettings { Name = Reflector<GenerateModelingCodeCommand>.GetPropertyName(u => u.TemplateUri) });

                });

                this.serviceProvider = new Mock<IServiceProvider>();
                this.uriService = new Mock<IUriReferenceService>();
                this.serviceProvider.Setup(sp => sp.GetService(typeof(IUriReferenceService))).Returns(this.uriService.Object);
                this.validation = new GenerateModelingCodeCommandValidation
                {
                    serviceProvider = this.serviceProvider.Object,
                };

                this.validationContext = new ValidationContext(ValidationCategories.Custom, this.settings);
            }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:31,代码来源:GenerateModelingCodeCommandValidationSpec.cs

示例5: AddComponent

        public void AddComponent(IItem equipment)
        {
            //If this item is stackable, then rather than adding it to the
            //collection, will just increase the stacked number
            if (equipment.IsStackable)
            {
                bool found = false;

                //Loop through each item in the collection
                foreach (IItem item in Components.Keys)
                {
                    //If we find a match
                    if (item == equipment)
                    {
                        //Increase the value of the stack
                        //but don't add it to the collection
                        Components[item]++;
                        found = true;
                        break;
                    }
                }

                //If we did not find an existing item, add it to the
                //collecton
                if (!found)
                    Components.Add(equipment, 1);
            }
                //if it's not stackable, then add this single item to
                //the collection.
            else
                Components.Add(equipment, 1);
        }
开发者ID:ramseur,项目名称:MudDesigner,代码行数:32,代码来源:StarterBag.cs

示例6: Hold

    public void Hold(IItem holdable)
    {
        if (holdable == null)
        {
            return;
        }

        if (currentHeldObject != null)
        {
            Drop(holdable);
        }

        currentHeldObject = holdable;

        CollisionIgnoreManager collisionIgnore = holdable.gameObject.GetComponent<CollisionIgnoreManager>();
        if (collisionIgnore)
        {
            collisionIgnore.otherGameObject = anchorRigidbody.transform.parent.gameObject;
            collisionIgnore.Ignore();
        }

        //holdable.gameObject.transform.SetParent(transform, false);
        holdable.gameObject.transform.position = transform.position;
        holdable.gameObject.transform.rotation = transform.rotation;

        FixedJoint joint = gameObject.AddComponent<FixedJoint>();
        joint.connectedBody = holdable.gameObject.GetComponent<Rigidbody>();

        holdable.OnHold(this);
    }
开发者ID:KurtLoeffler,项目名称:Retrograde,代码行数:30,代码来源:Hand.cs

示例7: EquipItem

        public bool EquipItem(IItem item, IInventory inventory) {
            bool result = false;

            IWeapon weaponItem = item as IWeapon;
            if (weaponItem != null && weaponItem.IsWieldable) {
                //can't equip a wieldable weapon
            }
            else {
                if (!equipped.ContainsKey(item.WornOn)) {
                    equipped.Add(item.WornOn, item);
                    if (inventory.inventory.Any(i => i.Id == item.Id)) {//in case we are adding it from a load and not moving it from the inventory
                        inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory
                    }
                    result = true;
                }
                else if (item.WornOn == Wearable.WIELD_LEFT || item.WornOn == Wearable.WIELD_RIGHT) { //this item can go in the free hand
                    Wearable freeHand = Wearable.WIELD_LEFT; //we default to right hand for weapons
                    if (equipped.ContainsKey(freeHand)) freeHand = Wearable.WIELD_RIGHT; //maybe this perosn is left handed
                    if (!equipped.ContainsKey(freeHand)) { //ok let's equip this
                        item.WornOn = freeHand;
                        item.Save();
                        equipped.Add(freeHand, item);
                        if (inventory.inventory.Any(i => i.Id == item.Id)) {//in case we are adding it from a load and not moving it from the inventory
                            inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory
                        }
                        result = true;
                    }
                }
            }

            return result;
        }
开发者ID:jandar78,项目名称:Novus,代码行数:32,代码来源:Equipment.cs

示例8: Initialize

 public void Initialize()
 {
     this.item1 = this.solution.Find<IItem>().First();
     this.item2 = this.solution.Find<IItem>().Last();
     this.serviceProvider = new Mock<IServiceProvider>();
     this.serviceProvider.Setup(s => s.GetService(typeof(IUriReferenceService))).Returns(UriReferenceServiceFactory.CreateService(new[] { new SolutionUriProvider() }));
 }
开发者ID:StevenVanDijk,项目名称:NuPattern,代码行数:7,代码来源:PackUriProviderSpec.cs

示例9: GetField

        /// <summary>
        /// This method will eventually defer to the ISitecoreRepository to render the field value.
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string GetField(string fieldName, IItem item, Dictionary<string, string> parameters)
        {
            if (item != null)
            {
                if (!String.IsNullOrEmpty(fieldName))
                {
                    // Get the ISitecoreRepository to check if the field actually exists.
                    if (_sitecoreRepository.FieldExists(fieldName, item))
                    {
                        // Helper to return field parameters for this particular field (the dictionary contains all fields + their parameters)
                        string fieldParameters = GetFieldParameters(fieldName, parameters);

                        if (!String.IsNullOrEmpty(fieldParameters))
                        {
                            // Get field value from Sitecore, having already checked for null/empty, and whether or not the field actually exists.
                            return _sitecoreRepository.GetFieldValue(fieldName, item, fieldParameters);
                        }
                        else
                        {
                            return _sitecoreRepository.GetFieldValue(fieldName, item);
                        }
                    }
                }
            }

            return String.Empty;
        }
开发者ID:JawadS,项目名称:sample-sitecore-mvc,代码行数:33,代码来源:LocationDomain.cs

示例10: Perform

		public override IItem[] Perform (IItem[] items, IItem[] modifierItems)
		{
				foreach (RipItem item in items ) {
					Util.Environment.Open (item.URL);
				}
			return null;
		}
开发者ID:mordaroso,项目名称:movierok.do,代码行数:7,代码来源:RemoteAction.cs

示例11: Run

        public static void Run(IItem[] items)
        {
            var book = items[0];

            // 1. serialize a single book to a JSON string
            Console.WriteLine(JsonConvert.SerializeObject(book));

            // 2. ... with nicer formatting
            Console.WriteLine(JsonConvert.SerializeObject(book, Formatting.Indented));

            // 3. serialize all items
            // ... include type, so we can deserialize sub-classes to interface type
            var settings = new JsonSerializerSettings() { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto };
            Console.WriteLine(JsonConvert.SerializeObject(items, settings));

            // 4. store json string to file "items.json" on your Desktop
            var text = JsonConvert.SerializeObject(items, settings);
            var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var filename = Path.Combine(desktop, "items.json");
            File.WriteAllText(filename, text);

            // 5. deserialize items from "items.json"
            // ... and print Description and Price of deserialized items
            var textFromFile = File.ReadAllText(filename);
            var itemsFromFile = JsonConvert.DeserializeObject<IItem[]>(textFromFile, settings);
            var currency = Currency.EUR;
            foreach (var x in itemsFromFile) Console.WriteLine($"{x.Description.Truncate(50),-50} {x.Price.ConvertTo(currency).Amount,8:0.00} {currency}");
        }
开发者ID:rkerschbaumer,项目名称:oom,代码行数:28,代码来源:SerializationExample.cs

示例12: AddItemToBuilder

 public void AddItemToBuilder(IItem item, string name, SolutionMessage.Builder builder) {
   IStringConvertibleValue value = (item as IStringConvertibleValue);
   if (value != null) {
     SolutionMessage.Types.StringVariable.Builder var = SolutionMessage.Types.StringVariable.CreateBuilder();
     var.SetName(name).SetData(value.GetValue());
     builder.AddStringVars(var.Build());
   } else {
     IStringConvertibleArray array = (item as IStringConvertibleArray);
     if (array != null) {
       SolutionMessage.Types.StringArrayVariable.Builder var = SolutionMessage.Types.StringArrayVariable.CreateBuilder();
       var.SetName(name).SetLength(array.Length);
       for (int i = 0; i < array.Length; i++)
         var.AddData(array.GetValue(i));
       builder.AddStringArrayVars(var.Build());
     } else {
       IStringConvertibleMatrix matrix = (item as IStringConvertibleMatrix);
       if (matrix != null) {
         SolutionMessage.Types.StringArrayVariable.Builder var = SolutionMessage.Types.StringArrayVariable.CreateBuilder();
         var.SetName(name).SetLength(matrix.Columns);
         for (int i = 0; i < matrix.Rows; i++)
           for (int j = 0; j < matrix.Columns; j++)
             var.AddData(matrix.GetValue(i, j));
         builder.AddStringArrayVars(var.Build());
       } else {
         throw new ArgumentException(ItemName + ": Item is not of a supported type.", "item");
       }
     }
   }
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:29,代码来源:StringConverter.cs

示例13: Template

        public Template(IItem item, IList<IItem> items)
        {
            Assert.IsTrue(new ID(item.TemplateID).Equals(Sitecore.TemplateIDs.Template), "item must be template");

            _item = item;
            _items = items;
        }
开发者ID:herskinduk,项目名称:Usergroup.Serialization,代码行数:7,代码来源:Template.cs

示例14: ItemClick

        public override void ItemClick(IItem item)
        {
            try
            {
                if (item != null)
                {
                    var model = item.Model;
                    var obj = (WcfService.Dto.ReportJobDto)model;
                    var tipo = UtilityValidation.GetStringND(obj.Tipo);
                    var viewModel = (ReportJob.ReportJobViewModel)ViewModel;
                    ISpace space = null;
                    if (tipo == Tipi.TipoReport.Fornitore.ToString())
                        space = viewModel.GetModel<ReportJobFornitoreModel>(model);
                    else if (tipo == Tipi.TipoReport.Fornitori.ToString())
                        space = viewModel.GetModel<ReportJobFornitoriModel>(model);
                    else if (tipo == Tipi.TipoReport.Committente.ToString())
                        space = viewModel.GetModel<ReportJobCommittenteModel>(model);
                    else if (tipo == Tipi.TipoReport.Committenti.ToString())
                        space = viewModel.GetModel<ReportJobCommittentiModel>(model);

                    AddSpace(space);
                }
            }
            catch (Exception ex)
            {
                UtilityError.Write(ex);
            } 
        }
开发者ID:es-dev,项目名称:cantieri,代码行数:28,代码来源:ReportJobItem.cs

示例15: Apply

    public static ItemArray<IItem> Apply(IItem initiator, IItem guide, IntValue k, PercentValue n) {
      if (!(initiator is RealVector) || !(guide is RealVector))
        throw new ArgumentException("Cannot relink path because one of the provided solutions or both have the wrong type.");
      if (n.Value <= 0.0)
        throw new ArgumentException("RelinkingAccuracy must be greater than 0.");

      RealVector v1 = initiator.Clone() as RealVector;
      RealVector v2 = guide as RealVector;

      if (v1.Length != v2.Length)
        throw new ArgumentException("The solutions are of different length.");

      IList<RealVector> solutions = new List<RealVector>();
      for (int i = 0; i < k.Value; i++) {
        RealVector solution = v1.Clone() as RealVector;
        for (int j = 0; j < solution.Length; j++)
          solution[j] = v1[j] + 1 / (k.Value - i) * (v2[j] - v1[j]);
        solutions.Add(solution);
      }

      IList<IItem> selection = new List<IItem>();
      if (solutions.Count > 0) {
        int noSol = (int)(solutions.Count * n.Value);
        if (noSol <= 0) noSol++;
        double stepSize = (double)solutions.Count / (double)noSol;
        for (int i = 0; i < noSol; i++)
          selection.Add(solutions.ElementAt((int)((i + 1) * stepSize - stepSize * 0.5)));
      }

      return new ItemArray<IItem>(selection);
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:31,代码来源:SingleObjectiveTestFunctionPathRelinker.cs


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