TagTool.Cache.TagCache.AllocateTag C# (CSharp) Méthode

AllocateTag() public méthode

Allocates a new tag at the end of the tag list without updating the file. The tag's group will be null until it is assigned data. You can give the tag data by using one of the overwrite functions.
public AllocateTag ( ) : TagInstance
Résultat TagTool.TagGroups.TagInstance
        public TagInstance AllocateTag()
        {
            return AllocateTag(TagGroup.Null);
        }

Same methods

TagCache::AllocateTag ( TagGroup type ) : TagInstance

Usage Example

Exemple #1
0
        public bool TryAllocateTag(out CachedTagInstance result, Type type, string name = null)
        {
            result = null;

            try
            {
                var structure = TagStructure.GetTagStructureInfo(type, Version).Structure;

                if (structure == null)
                {
                    Console.WriteLine($"TagStructure attribute not found for type \"{type.Name}\".");
                    return(false);
                }

                var groupTag = new Tag(structure.Tag);

                if (!TagGroup.Instances.ContainsKey(groupTag))
                {
                    Console.WriteLine($"TagGroup not found for type \"{type.Name}\" ({structure.Tag}).");
                    return(false);
                }

                result = TagCache.AllocateTag(TagGroup.Instances[groupTag], name);

                if (result == null)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e.GetType().Name}: {e.Message}");
                return(false);
            }

            return(true);
        }