Example #1
0
 protected internal TagBase(string name, TagOptions options, object[] content) : this(name, options)
 {
     if (content?.Length > 0)
     {
         TagChildren.Replace(content);
     }
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     wasTagged       = false;
     wasBothResolved = false;
     myTag           = TagOptions.LabelMine; // THIS IS A HACK, but a necessary default
     click           = null;
 }
Example #3
0
        internal static string Open(
            string name,
            AttributeList attributes,
            TagOptions options)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return("");
            }

            options = TagOptions.UseOrCreate(options);

            // if we have a data-list of attributes, add to object
            if (attributes.Options == null)
            {
                attributes.Options = options.Attribute;
            }
            var attributeText = attributes?.ToString() ?? "";

            // ensure attributes have space in front
            if (!string.IsNullOrEmpty(attributeText) && attributeText[0] != ' ')
            {
                attributeText = " " + attributeText;
            }

            var selfClose = options.Close && options.SelfClose ? "/" : "";

            return($"<{name}{attributeText}{selfClose}>");
        }
Example #4
0
 public Tag(string name, object content, TagOptions options = null)
     : this(name, options)
 {
     if (content != null)
     {
         TagChildren.Replace(content);
     }
 }
Example #5
0
 /// <summary>
 /// Clone the options for situations where the options must be changed
 /// but only in a copy
 /// </summary>
 /// <param name="original"></param>
 /// <returns></returns>
 internal static TagOptions CloneOrCreate(TagOptions original) =>
 original != null
         ? new TagOptions(original.Attribute)
 {
     Close     = original.Close,
     SelfClose = original.SelfClose
 }
         : new TagOptions();
Example #6
0
 protected internal TagBase(string name, object content, TagOptions options = null)
     : this(name, options)
 {
     if (content != null)
     {
         TagChildren.Replace(content);
     }
 }
        private void btnAddTag_Click(object sender, RoutedEventArgs e)
        {
            var newTag = new Tag();

            var tagOptions = new TagOptions(newTag);

            NavigationService.Navigate(tagOptions, newTag);
        }
Example #8
0
        public void ShouldAddTags()
        {
            TagOptions tagOptions = new TagOptions();

            TagHolder th = new TagHolder(tagOptions);

            th.Tags.Should().HaveCount(0);
            th.Add("TagName");
            th.Tags.Should().HaveCount(1);
        }
Example #9
0
        public void ShouldFindInName()
        {
            TagOptions tagOptions = new TagOptions();

            tagOptions.TagNotStoredInFileName = true;

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("This is a file name [TAG tagB]");

            th.Tags.Should().HaveCount(0);
        }
Example #10
0
        public void ShouldNotAddSameTagTwice()
        {
            TagOptions tagOptions = new TagOptions();

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("My My My");

            th.Tags.Should().HaveCount(1);

            th.Tags[0].Name.Should().Be("My");
        }
Example #11
0
 protected internal TagBase(string name = null, TagOptions options = null)
 {
     TagOptions = options;
     if (name?.Contains("<") ?? false)
     {
         TagOverride = name;
     }
     else
     {
         TagName = name;
     }
 }
Example #12
0
 public Tag(string name = null, TagOptions options = null)
 {
     TagOptions = options;
     if (name?.Contains("<") ?? false)
     {
         TagOverride = name;
     }
     else
     {
         TagName = name;
     }
 }
Example #13
0
        public void Tag(Sentence sentence, TagOptions options)
        {
            Init();

            var tokens = posSeg.Cut(sentence.Text).ToList();

            for (int i = 0; i < sentence.Words.Count; i++)
            {
                sentence.Words[i].Pos = tokens[i].Flag;
                sentence.Words[i].Tag = tokens[i].Flag;
            }
        }
 public TagHeaders(TagOptions options)
 {
     if (options == null)
     {
         throw new Exception("Options can not be null");
     }
     if ((options.Folder ?? options.File) == null)
     {
         throw new Exception("Either Folder or File option should have been set");
     }
     Options = options;
 }
Example #15
0
        public void ShouldFindNoWhenTagInBoxsAndNoBoxes()
        {
            TagOptions tagOptions = new TagOptions();

            tagOptions.TagInBoxs = true;

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("This is a file name");

            th.Tags.Should().HaveCount(0);
            th.Tags.Should().BeEmpty();
        }
Example #16
0
        public void ShouldCreateNameFromTags()
        {
            TagOptions tagOptions = new TagOptions();

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("My First Tags");

            th.Tags.Should().HaveCount(3);
            string name = th.CreateNameFromTags();

            name.Should().Be("My First Tags");
        }
Example #17
0
        public void ShouldSplitString(string name)
        {
            TagOptions tagOptions = new TagOptions();

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName(name);

            th.Tags.Should().HaveCount(3);

            th.Tags[0].Name.Should().Be("My");
            th.Tags[1].Name.Should().Be("First");
            th.Tags[2].Name.Should().Be("Tags");
        }
Example #18
0
        public void ShouldFindTagsInBoxes()
        {
            TagOptions tagOptions = new TagOptions();

            tagOptions.TagInBoxs = true;

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("This is a file name [TAG tagB]");

            th.Tags.Should().HaveCount(2);
            th.Tags[0].Name.Should().Be("TAG");
            th.Tags[1].Name.Should().Be("tagB");
        }
        public void ShouldAddTagToGlobal()
        {
            GlobalTagStore gts = ServiceLocator.Instance.GetService <GlobalTagStore>();

            gts.ClearTags();

            TagOptions tagOptions = new TagOptions();

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("TasgA TagB");

            gts.Tags.Should().HaveCount(2);
        }
Example #20
0
        public void ShouldKeepFirstPartOfName()
        {
            TagOptions tagOptions = new TagOptions();

            tagOptions.KeepFirstPartOfName = true;

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("PIC00001 With Tags");

            th.Tags.Should().HaveCount(2);
            string name = th.CreateNameFromTags();

            name.Should().Be("PIC00001 With Tags");
        }
Example #21
0
        public Icon(string path, string rel = null, int size = SizeUndefined, string type = null)
        {
            // override empty attributes
            TagOptions = new TagOptions(new AttributeOptions {
                KeepEmpty = false
            })
            {
                Close = false
            };

            Rel(rel ?? RelIcon);
            Sizes(size == SizeUndefined ? "" : $"{size}x{size}");
            Type(type ?? Mime.DetectImageMime(path));
            Href(path);
        }
Example #22
0
        public void ShouldSplitPipedString()
        {
            TagOptions tagOptions = new TagOptions();

            tagOptions.Seperator = '|';

            TagHolder th = new TagHolder(tagOptions);

            th.SplitName("My|First|Tags");

            th.Tags.Should().HaveCount(3);

            th.Tags[0].Name.Should().Be("My");
            th.Tags[1].Name.Should().Be("First");
            th.Tags[2].Name.Should().Be("Tags");
        }
Example #23
0
        public void ShouldCreateTagFromPipe()
        {
            TagOptions tago = new TagOptions();

            tago.Seperator = '|';
            TagOptionsService tos = new TagOptionsService(tago);

            ServiceLocator.Instance.InjectService <TagOptionsService>(tos);
            SoundItemData sid = new SoundItemData();

            sid.Name = "Tag|Tag2|Tag2|TagB";

            sid.Tags.Should().HaveCount(3);
            sid.Tags[0].Name.Should().Be("Tag");
            sid.Tags[1].Name.Should().Be("Tag2");
            sid.Tags[2].Name.Should().Be("TagB");
        }
Example #24
0
        public async Task <Response <TagList> > ReadTagBySlugAsync(string slug, TagOptions options = null)
        {
            var requestUri = new StringBuilder();

            requestUri.Append($"/ghost/api/v3/content/tags/slug/{slug}/?key={_apiKey}");

            if (options != null)
            {
                requestUri.Append(options.Include != Include.None
                    ? $"&include={options.Include.GetDescriptions()}"
                    : string.Empty);
                requestUri.Append(options.Fields != TagFields.None
                    ? $"&fields={options.Fields.GetDescriptions()}"
                    : string.Empty);
            }

            return(await GetRequestAsync <TagList>(requestUri));
        }
Example #25
0
        public async Task <Response <TagList> > BrowseTagsAsync(TagOptions options = null)
        {
            var requestUri = new StringBuilder();

            requestUri.Append($"/ghost/api/v3/content/tags/?key={_apiKey}");

            if (options != null)
            {
                requestUri.Append(options.Include != Include.None
                    ? $"&include={options.Include.GetDescriptions()}"
                    : string.Empty);
                requestUri.Append(options.Fields != TagFields.None
                    ? $"&fields={options.Fields.GetDescriptions()}"
                    : string.Empty);

                requestUri.Append(options.Page != string.Empty ? $"&page={options.Page}" : string.Empty);
                requestUri.Append(options.Limit != string.Empty ? $"&limit={options.Limit}" : string.Empty);
                requestUri.Append(options.Filter != string.Empty ? $"&filter={options.Filter}" : string.Empty);
                requestUri.Append(options.Order != string.Empty ? $"&order={options.Order}" : string.Empty);
            }

            return(await GetRequestAsync <TagList>(requestUri));
        }
Example #26
0
        /// <summary>
        /// Generate an html tag as a string for further processing
        /// </summary>
        internal static string Tag(string name,
                                   AttributeList attributes,
                                   string content,
                                   TagOptions options)
        {
            // default case, no content or no options, get default options or create new
            if (string.IsNullOrEmpty(content) || options == null)
            {
                options = TagOptions.UseOrCreate(options);
            }
            else
            {
                // special case: we have content AND options, so we must ensure that it will close correctly
                options           = TagOptions.CloneOrCreate(options);
                options.SelfClose = false;
                options.Close     = true;
            }

            var open = Open(name, attributes, options);

            return($"{open}{content}"
                   + (options.Close && !options.SelfClose ? Close(name) : ""));
        }
Example #27
0
        private static int HandleTag(IJournalrService service, TagOptions opts)
        {
            var success = false;

            if (opts.Id == null)
            {
                success = service.TagEntry(opts.Count, opts.Tags.Split(',').ToList());
            }
            else
            {
                success = service.TagEntry(opts.Id, opts.Tags.Split(',').ToList());
            }

            if (success)
            {
                Console.WriteLine("Tagged");
            }
            else
            {
                Console.WriteLine("Tag failed");
            }

            return(0);
        }
Example #28
0
        /// <summary>
        /// 标签操作
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="tag">标签名</param>
        /// <param name="method">方法名</param>
        /// <param name="result"></param>
        /// <param name="message"></param>
        private void TagOperation(string userId, string tag, string method, ref string result, ref string message)
        {
            BaiduPush Bpush = new BaiduPush("POST");
            TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
            uint unixTime = (uint)ts.TotalSeconds;
            string apiKey = SysFunction.GetConfigValue("ApiKey");

            TagOptions tOpts = new TagOptions(method, apiKey, userId, tag, unixTime);

            message = Bpush.SetTag(tOpts);
            result = "0";
        }
Example #29
0
 /// <summary>
 /// Check if options were already provided, or create new default options
 /// </summary>
 /// <param name="original"></param>
 /// <returns></returns>
 internal static TagOptions UseOrCreate(TagOptions original) => original ?? new TagOptions();
Example #30
0
 protected internal TagCustom(string name = null, TagOptions options = null)
     : base(name, options)
 {
 }
Example #31
0
 protected internal TagCustom(string name, TagOptions options, object[] content)
     : base(name, options, content)
 {
 }