示例#1
0
            public TagHelperExecutionContext Rent(
                string tagName,
                TagMode tagMode,
                IDictionary <object, object> items,
                string uniqueId,
                Func <Task> executeChildContentAsync)
            {
                TagHelperExecutionContext tagHelperExecutionContext;

                if (_nextIndex == _executionContexts.Count)
                {
                    tagHelperExecutionContext = new TagHelperExecutionContext(
                        tagName,
                        tagMode,
                        items,
                        uniqueId,
                        executeChildContentAsync,
                        _startTagHelperWritingScope,
                        _endTagHelperWritingScope);

                    _executionContexts.Add(tagHelperExecutionContext);
                }
                else
                {
                    tagHelperExecutionContext = _executionContexts[_nextIndex];
                    tagHelperExecutionContext.Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);
                }

                _nextIndex++;

                return(tagHelperExecutionContext);
            }
示例#2
0
        /// <summary>
        /// Starts a <see cref="TagHelperExecutionContext"/> scope.
        /// </summary>
        /// <param name="tagName">The HTML tag name that the scope is associated with.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        /// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
        public TagHelperExecutionContext Begin(
            [NotNull] string tagName,
            TagMode tagMode,
            [NotNull] string uniqueId,
            [NotNull] Func<Task> executeChildContentAsync,
            [NotNull] Action startTagHelperWritingScope,
            [NotNull] Func<TagHelperContent> endTagHelperWritingScope)
        {
            IDictionary<object, object> items;

            // If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
            if (_executionScopes.Count > 0)
            {
                items = new CopyOnWriteDictionary<object, object>(
                    _executionScopes.Peek().Items,
                    comparer: EqualityComparer<object>.Default);
            }
            else
            {
                items = new Dictionary<object, object>();
            }

            var executionContext = new TagHelperExecutionContext(
                tagName,
                tagMode,
                items,
                uniqueId,
                executeChildContentAsync,
                startTagHelperWritingScope,
                endTagHelperWritingScope);

            _executionScopes.Push(executionContext);

            return executionContext;
        }
        /// <summary>
        /// Starts a <see cref="TagHelperExecutionContext"/> scope.
        /// </summary>
        /// <param name="tagName">The HTML tag name that the scope is associated with.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        /// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
        public TagHelperExecutionContext Begin(
            string tagName,
            TagMode tagMode,
            string uniqueId,
            Func<Task> executeChildContentAsync,
            Action startTagHelperWritingScope,
            Func<TagHelperContent> endTagHelperWritingScope)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException(nameof(tagName));
            }

            if (uniqueId == null)
            {
                throw new ArgumentNullException(nameof(uniqueId));
            }

            if (executeChildContentAsync == null)
            {
                throw new ArgumentNullException(nameof(executeChildContentAsync));
            }

            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            IDictionary<object, object> items;

            // If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
            if (_executionScopes.Count > 0)
            {
                items = new CopyOnWriteDictionary<object, object>(
                    _executionScopes.Peek().Items,
                    comparer: EqualityComparer<object>.Default);
            }
            else
            {
                items = new Dictionary<object, object>();
            }

            var executionContext = new TagHelperExecutionContext(
                tagName,
                tagMode,
                items,
                uniqueId,
                executeChildContentAsync,
                startTagHelperWritingScope,
                endTagHelperWritingScope);

            _executionScopes.Push(executionContext);

            return executionContext;
        }
        //参考 https://stackoverflow.com/questions/25457886/c-sharp-revit-api-createindependenttag-method-failing-to-add-tag-to-ceilings-e
        public IndependentTag CreateOneFloorIndependentTag(Document document, Floor floor, string labelName)
        {
            Autodesk.Revit.DB.View view = document.ActiveView;

            TagMode        tagMode = TagMode.TM_ADDBY_CATEGORY;
            TagOrientation tagOri  = TagOrientation.Horizontal;

            //Revit elements can be located by a point(most family instance),a line(walls, line based components)
            //or sketch(celling, floors etc);
            //Simply answer is to find the boundling of box of the floor and calculate the center of the
            //if the floor is a large L shape or something the boundling box center may not be over the floor at all
            //need some other algorithm to find the center point;

            //calculate the center of mark
            XYZ centerPoint = CalculateCenterOfMark(floor, view);

            IndependentTag newTag = document.Create.NewTag(view, floor, false, tagMode, tagOri, centerPoint);

            if (null == newTag)
            {
                throw new Exception("Create IndependentTag Failed!");
            }
            //NewTag.tagText is read-only, so use the othter parameters to set the tag text;
            SetTagText(floor, labelName);
            return(newTag);
        }
        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="items">The collection of items used to communicate with other
        /// <see cref="ITagHelper"/>s</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">
        /// A delegate used to start a writing scope in a Razor page and optionally override the page's
        /// <see cref="HtmlEncoder"/> within that scope.
        /// </param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            string tagName,
            TagMode tagMode,
            IDictionary<object, object> items,
            string uniqueId,
            Func<Task> executeChildContentAsync,
            Action<HtmlEncoder> startTagHelperWritingScope,
            Func<TagHelperContent> endTagHelperWritingScope)
        {
            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            _tagHelpers = new List<ITagHelper>();
            _allAttributes = new TagHelperAttributeList();

            Context = new TagHelperContext(_allAttributes, items, uniqueId);
            Output = new TagHelperOutput(tagName, new TagHelperAttributeList(), GetChildContentAsync)
            {
                TagMode = tagMode
            };

            Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);

            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope = endTagHelperWritingScope;
        }
示例#6
0
 public PhotoSearchOptions(string userId, string tags, TagMode tagMode, string text)
 {
     this.UserId = userId;
       this.Tags = tags;
       this.TagMode = tagMode;
       this.Text = text;
 }
示例#7
0
 /// <summary>
 /// Create an instance of the <see cref="PhotoSearchOptions"/> for a given user ID and tag list,
 /// with the selected tag mode, and containing the selected text.
 /// </summary>
 /// <param name="userId">The ID of the User to search for.</param>
 /// <param name="tags">The tags (comma delimited) to search for.</param>
 /// <param name="tagMode">The <see cref="TagMode"/> to use to search.</param>
 /// <param name="text">The text to search for in photo title and descriptions.</param>
 public PhotoSearchOptions(string userId, string tags, TagMode tagMode, string text)
 {
     UserId  = userId;
     Tags    = tags;
     TagMode = tagMode;
     Text    = text;
 }
        //ToDo: genericize this, so that it allows common settings for all tags, then unique settings as needed per tag
        public static List <IndependentTag> CreateTags(View view, FamilySymbol tagSymbol)
        {
            if (tagSymbol == null || tagSymbol.Category == null)
            {
                return(null);
            }

            Document _doc = view.Document;

            List <FamilyInstance> _reshores = new FilteredElementCollector(_doc).OfClass(typeof(FamilyInstance)).OfType <FamilyInstance>().ToList();

            TagMode _tagMode = tagSymbol.Category.Id.IntegerValue == (int)BuiltInCategory.OST_MultiCategoryTags
                ? TagMode.TM_ADDBY_MULTICATEGORY
                : TagMode.TM_ADDBY_CATEGORY;

            List <IndependentTag> _tags = new List <IndependentTag>();

            foreach (FamilyInstance _reshore in _reshores)
            {
                BoundingBoxXYZ _boundingBoxXYZ = _reshore.get_BoundingBox(null);

                XYZ _tagHeadCoordinate = (_boundingBoxXYZ.Min + _boundingBoxXYZ.Max) / 2.0;

                Reference _reference = new Reference(_reshore);

                IndependentTag _tag = IndependentTag.Create(_doc, view.Id, _reference, true, _tagMode, TagOrientation.Horizontal, _tagHeadCoordinate);
                _tags.Add(_tag);
            }
            return(_tags);
        }
示例#9
0
 public MarkupTagHelperBlock(
     string tagName,
     TagMode tagMode,
     IList <TagHelperAttributeNode> attributes)
     : this(tagName, tagMode, attributes, new SyntaxTreeNode[0])
 {
 }
示例#10
0
        /// <summary>
        /// Starts a <see cref="TagHelperExecutionContext"/> scope.
        /// </summary>
        /// <param name="tagName">The HTML tag name that the scope is associated with.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        /// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
        public TagHelperExecutionContext Begin(
            string tagName,
            TagMode tagMode,
            string uniqueId,
            Func <Task> executeChildContentAsync,
            Action startTagHelperWritingScope,
            Func <TagHelperContent> endTagHelperWritingScope)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException(nameof(tagName));
            }

            if (uniqueId == null)
            {
                throw new ArgumentNullException(nameof(uniqueId));
            }

            if (executeChildContentAsync == null)
            {
                throw new ArgumentNullException(nameof(executeChildContentAsync));
            }

            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            IDictionary <object, object> items;

            // If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
            if (_executionScopes.Count > 0)
            {
                items = new CopyOnWriteDictionary <object, object>(
                    _executionScopes.Peek().Items,
                    comparer: EqualityComparer <object> .Default);
            }
            else
            {
                items = new Dictionary <object, object>();
            }

            var executionContext = new TagHelperExecutionContext(
                tagName,
                tagMode,
                items,
                uniqueId,
                executeChildContentAsync,
                startTagHelperWritingScope,
                endTagHelperWritingScope);

            _executionScopes.Push(executionContext);

            return(executionContext);
        }
示例#11
0
 public MarkupTagHelperBlock(
     string tagName,
     TagMode tagMode,
     IList <KeyValuePair <string, SyntaxTreeNode> > attributes)
     : this(tagName, tagMode, attributes, new SyntaxTreeNode[0])
 {
 }
 /// <summary>
 /// Create an instance of the <see cref="PhotoSearchOptions"/> for a given user ID and tag list,
 /// with the selected tag mode, and containing the selected text.
 /// </summary>
 /// <param name="userId">The ID of the User to search for.</param>
 /// <param name="tags">The tags (comma delimited) to search for.</param>
 /// <param name="tagMode">The <see cref="TagMode"/> to use to search.</param>
 /// <param name="text">The text to search for in photo title and descriptions.</param>
 public PhotoSearchOptions(string userId, string tags, TagMode tagMode, string text)
 {
     UserId = userId;
     Tags = tags;
     TagMode = tagMode;
     Text = text;
 }
示例#13
0
 /// <summary>
 /// Create an instance of the <see cref="PhotoSearchOptions"/> for a given user ID and tag list,
 /// with the selected tag mode, and containing the selected text.
 /// </summary>
 /// <param name="userId">The ID of the User to search for.</param>
 /// <param name="tags">The tags (comma delimited) to search for.</param>
 /// <param name="tagMode">The <see cref="TagMode"/> to use to search.</param>
 /// <param name="text">The text to search for in photo title and descriptions.</param>
 public PhotoSearchOptions(string userId, string tags, TagMode tagMode, string text)
 {
     this.UserId  = userId;
     this.Tags    = tags;
     this.TagMode = tagMode;
     this.Text    = text;
 }
示例#14
0
        /// <summary>
        /// Tag the beam's start and end.
        /// </summary>
        /// <param name="tagMode">Mode of tag</param>
        /// <param name="tagSymbol">Tag symbol wrapper</param>
        /// <param name="leader">Whether the tag has leader</param>
        /// <param name="tagOrientation">Orientation of tag</param>
        public void CreateTag(TagMode tagMode,
                              FamilySymbolWrapper tagSymbol, bool leader,
                              TagOrientation tagOrientation)
        {
            foreach (FamilyInstance beam in m_beamList)
            {
                //Get the start point and end point of the selected beam.
                Autodesk.Revit.DB.LocationCurve location = beam.Location as Autodesk.Revit.DB.LocationCurve;
                Autodesk.Revit.DB.Curve         curve    = location.Curve;

                Transaction t = new Transaction(m_revitDoc.Document);
                t.Start("Create new tag");
                //Create tag on the beam's start and end.
                Reference      beamRef = new Reference(beam);
                IndependentTag tag1    = IndependentTag.Create(m_revitDoc.Document,
                                                               m_view.Id, beamRef, leader, tagMode, tagOrientation, curve.GetEndPoint(0));
                IndependentTag tag2 = IndependentTag.Create(m_revitDoc.Document,
                                                            m_view.Id, beamRef, leader, tagMode, tagOrientation, curve.GetEndPoint(1));

                //Change the tag's object Type.
                tag1.ChangeTypeId(tagSymbol.FamilySymbol.Id);
                tag2.ChangeTypeId(tagSymbol.FamilySymbol.Id);
                t.Commit();
            }
        }
示例#15
0
        private void CreateNewTagForPointLoad(View activeV, XYZ loadPosition, PointLoad pl)
        {
            Transaction t = new Transaction(_doc);

            t.Start("Create tag for point load");
            TagMode        tagMode = TagMode.TM_ADDBY_CATEGORY;
            TagOrientation tagorn  = TagOrientation.Horizontal;

            IndependentTag tag     = IndependentTag.Create(_doc, activeV.Id, new Reference(pl), false, tagMode, tagorn, loadPosition);
            FamilySymbol   tagType =
                (from fs in new FilteredElementCollector(_doc)
                 .OfCategory(BuiltInCategory.OST_PointLoadTags)
                 .OfClass(typeof(FamilySymbol))
                 .Cast <FamilySymbol>()
                 where fs.Name.Equals(Default.TYPE_NAME_POINT_LOAD)
                 select fs)
                .FirstOrDefault();

            if (tagType != null)
            {
                tag.ChangeTypeId(tagType.Id);
            }
            t.Commit();
            AssociateTagToPointLoad(pl, tag);
        }
示例#16
0
        public static async Task <TagHelperOutput> ProcessAndGetOutputAsync(
            this TagHelper tagHelper,
            TagHelperAttributeList attributeList,
            TagHelperContext context,
            string tagName  = "div",
            TagMode tagMode = TagMode.SelfClosing)
        {
            var innerOutput = new TagHelperOutput(
                tagName,
                attributeList,
                (useCachedResult, encoder) => Task.Run <TagHelperContent>(() => new DefaultTagHelperContent()))
            {
                TagMode = tagMode
            };

            var innerContext = new TagHelperContext(
                attributeList,
                context.Items,
                Guid.NewGuid().ToString()
                );

            tagHelper.Init(context);

            await tagHelper.ProcessAsync(innerContext, innerOutput);

            return(innerOutput);
        }
示例#17
0
        /// <summary>
        /// Starts a <see cref="TagHelperExecutionContext"/> scope.
        /// </summary>
        /// <param name="tagName">The HTML tag name that the scope is associated with.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        /// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
        public TagHelperExecutionContext Begin(
            [NotNull] string tagName,
            TagMode tagMode,
            [NotNull] string uniqueId,
            [NotNull] Func <Task> executeChildContentAsync,
            [NotNull] Action startTagHelperWritingScope,
            [NotNull] Func <TagHelperContent> endTagHelperWritingScope)
        {
            IDictionary <object, object> items;

            // If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
            if (_executionScopes.Count > 0)
            {
                items = new CopyOnWriteDictionary <object, object>(
                    _executionScopes.Peek().Items,
                    comparer: EqualityComparer <object> .Default);
            }
            else
            {
                items = new Dictionary <object, object>();
            }

            var executionContext = new TagHelperExecutionContext(
                tagName,
                tagMode,
                items,
                uniqueId,
                executeChildContentAsync,
                startTagHelperWritingScope,
                endTagHelperWritingScope);

            _executionScopes.Push(executionContext);

            return(executionContext);
        }
示例#18
0
 public TagControl()
 {
     _isNeedData   = false;
     _enableScript = false;
     _useInnerTag  = false;
     _mode         = TagMode.Get;
 }
示例#19
0
        /// <summary>
        /// https://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html
        /// </summary>
        /// <param name="document"></param>
        /// <param name="column"></param>
        /// <param name="viewId"></param>
        /// <returns></returns>
        private IndependentTag CreateIndependentTagColumn(Document document, FamilyInstance column, ElementId viewId, double Xoffset)
        {
            View view = document.GetElement(viewId) as View;

            // define tag mode and tag orientation for new tag
            TagMode        tagMode        = TagMode.TM_ADDBY_CATEGORY;
            TagOrientation tagorientation = TagOrientation.Horizontal;

            // Add the tag to the middle of the colunm
            Reference columnRef = new Reference(column);

            BoundingBoxXYZ bbox = column.get_BoundingBox(view);

            XYZ centroid = new XYZ((bbox.Max.X + bbox.Min.X) / 2, (bbox.Max.Y + bbox.Min.Y) / 2, (bbox.Max.Z + bbox.Min.Z) / 2);

            XYZ position = centroid + new XYZ(Xoffset, 0, 0);

            IndependentTag newTag = document.Create.NewTag(view, column, false, tagMode, tagorientation, position);

            if (null == newTag)
            {
                throw new Exception("Create IndependentTag Failed.");
            }

            return(newTag);
        }
        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="items">The collection of items used to communicate with other
        /// <see cref="ITagHelper"/>s</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">
        /// A delegate used to start a writing scope in a Razor page and optionally override the page's
        /// <see cref="HtmlEncoder"/> within that scope.
        /// </param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            string tagName,
            TagMode tagMode,
            IDictionary <object, object> items,
            string uniqueId,
            Func <Task> executeChildContentAsync,
            Action <HtmlEncoder> startTagHelperWritingScope,
            Func <TagHelperContent> endTagHelperWritingScope)
        {
            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            _tagHelpers    = new List <ITagHelper>();
            _allAttributes = new TagHelperAttributeList();

            Context = new TagHelperContext(_allAttributes, items, uniqueId);
            Output  = new TagHelperOutput(tagName, new TagHelperAttributeList(), GetChildContentAsync)
            {
                TagMode = tagMode
            };

            Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);

            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope   = endTagHelperWritingScope;
        }
示例#21
0
 protected BaseTagHelper(IHtmlGenerator generator, string tagName, TagMode tagMode)
 {
     Generator = generator;
     Id        = new Random().Next(1000, 9999).ToString();
     TagName   = tagName;
     TagMode   = tagMode;
 }
        public void TagMode_ReturnsExpectedValue(TagMode tagMode)
        {
            // Arrange & Act
            var executionContext = new TagHelperExecutionContext("p", tagMode);

            // Assert
            Assert.Equal(tagMode, executionContext.TagMode);
        }
    public override void FormatNode(IntermediateNodeFormatter formatter)
    {
        formatter.WriteContent(TagName);

        formatter.WriteProperty(nameof(TagHelpers), string.Join(", ", TagHelpers.Select(t => t.DisplayName)));
        formatter.WriteProperty(nameof(TagMode), TagMode.ToString());
        formatter.WriteProperty(nameof(TagName), TagName);
    }
示例#24
0
 public MarkupTagHelperBlock(
     string tagName,
     TagMode tagMode,
     IList <TagHelperAttributeNode> attributes,
     params SyntaxTreeNode[] children)
     : base(new TagHelperBlockBuilder(tagName, tagMode, attributes, children))
 {
 }
 public void Reinitialize(
     string tagName,
     TagMode tagMode,
     IDictionary <object, object> items,
     string uniqueId,
     Func <Task> executeChildContentAsync)
 {
 }
        public void TagMode_ReturnsExpectedValue(TagMode tagMode)
        {
            // Arrange & Act
            var executionContext = new TagHelperExecutionContext("p", tagMode);

            // Assert
            Assert.Equal(tagMode, executionContext.TagMode);
        }
示例#27
0
 public TagHelperExecutionContext Begin(
     string tagName,
     TagMode tagMode,
     string uniqueId,
     Func <Task> executeChildContentAsync)
 {
     throw null;
 }
示例#28
0
        /// <summary>
        /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags.
        /// </summary>
        /// <param name="placeType">The ID for a specific place type to cluster photos by. </param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param>
        /// <param name="threshold">The minimum number of photos that a place type must have to be included.
        /// If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="tags">A list of tags. Photos with one or more of the tags listed will be returned.</param>
        /// <param name="tagMode">Either 'any' for an OR combination of tags, or 'all' for an AND combination.
        /// Defaults to 'any' if not specified.</param>
        /// <param name="machineTags"></param>
        /// <param name="machineTagMode"></param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PlacesPlacesForTagsAsync(PlaceType placeType, string woeId, string placeId, int threshold,
                                             string[] tags, TagMode tagMode, string[] machineTags,
                                             MachineTagMode machineTagMode, DateTime minUploadDate,
                                             DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate,
                                             Action <FlickrResult <PlaceCollection> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.placesForTags");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (!String.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }
            if (!String.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (tags != null && tags.Length > 0)
            {
                parameters.Add("tags", String.Join(",", tags));
            }
            if (tagMode != TagMode.None)
            {
                parameters.Add("tag_mode", UtilityMethods.TagModeToString(tagMode));
            }
            if (machineTags != null && machineTags.Length > 0)
            {
                parameters.Add("machine_tags", String.Join(",", machineTags));
            }
            if (machineTagMode != MachineTagMode.None)
            {
                parameters.Add("machine_tag_mode", UtilityMethods.MachineTagModeToString(machineTagMode));
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }

            GetResponseAsync <PlaceCollection>(parameters, callback);
        }
示例#29
0
 public TagHelperInfo(
     string tagName,
     TagMode tagMode,
     TagHelperBinding bindingResult)
 {
     TagName       = tagName;
     TagMode       = tagMode;
     BindingResult = bindingResult;
 }
示例#30
0
 /// <summary>
 /// Internal for testing purposes only.
 /// </summary>
 internal TagHelperExecutionContext(string tagName, TagMode tagMode)
     : this(tagName,
            tagMode,
            items: new Dictionary<object, object>(),
            uniqueId: string.Empty,
            executeChildContentAsync: async () => await Task.FromResult(result: true),
            startTagHelperWritingScope: () => { },
            endTagHelperWritingScope: () => new DefaultTagHelperContent())
 {
 }
 /// <summary>
 /// Internal for testing purposes only.
 /// </summary>
 internal TagHelperExecutionContext(string tagName, TagMode tagMode)
     : this(tagName,
            tagMode,
            items : new Dictionary <object, object>(),
            uniqueId : string.Empty,
            executeChildContentAsync : () => TaskCache.CompletedTask,
            startTagHelperWritingScope : _ => { },
            endTagHelperWritingScope : () => new DefaultTagHelperContent())
 {
 }
 public TagHelperExecutionContext(
     string tagName,
     TagMode tagMode,
     IDictionary <object, object> items,
     string uniqueId,
     Func <Task> executeChildContentAsync,
     Action <HtmlEncoder> startTagHelperWritingScope,
     Func <TagHelperContent> endTagHelperWritingScope)
 {
 }
示例#33
0
 /// <summary>
 /// Internal for testing purposes only.
 /// </summary>
 internal TagHelperExecutionContext(string tagName, TagMode tagMode)
     : this(tagName,
            tagMode,
            items : new Dictionary <object, object>(),
            uniqueId : string.Empty,
            executeChildContentAsync : async() => await Task.FromResult(result : true),
            startTagHelperWritingScope : () => { },
            endTagHelperWritingScope : () => new DefaultTagHelperContent())
 {
 }
        public void Begin_SetsExecutionContextTagMode(TagMode tagMode)
        {
            // Arrange
            var scopeManager = new TagHelperScopeManager();

            // Act
            var executionContext = BeginDefaultScope(scopeManager, "p", tagMode);

            // Assert
            Assert.Equal(tagMode, executionContext.TagMode);
        }
示例#35
0
 /// <summary>
 /// Instantiates a new <see cref="TagHelperChunk"/>.
 /// </summary>
 /// <param name="tagName">The tag name associated with the tag helpers HTML element.</param>
 /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
 /// <param name="attributes">The attributes associated with the tag helpers HTML element.</param>
 /// <param name="descriptors">
 /// The <see cref="TagHelperDescriptor"/>s associated with this tag helpers HTML element.
 /// </param>
 public TagHelperChunk(
     string tagName,
     TagMode tagMode,
     IList <KeyValuePair <string, Chunk> > attributes,
     IEnumerable <TagHelperDescriptor> descriptors)
 {
     TagName     = tagName;
     TagMode     = tagMode;
     Attributes  = attributes;
     Descriptors = descriptors;
 }
示例#36
0
 private static TagHelperExecutionContext BeginDefaultScope(
     TagHelperScopeManager scopeManager,
     string tagName,
     TagMode tagMode = TagMode.StartTagAndEndTag)
 {
     return(scopeManager.Begin(
                tagName,
                tagMode,
                uniqueId: string.Empty,
                executeChildContentAsync: async() => await Task.FromResult(result: true)));
 }
        public void ExecutionContext_CreateTagHelperOutput_ReturnsExpectedTagMode(TagMode tagMode)
        {
            // Arrange
            var executionContext = new TagHelperExecutionContext("p", tagMode);

            // Act
            var output = executionContext.Output;

            // Assert
            Assert.Equal(tagMode, output.TagMode);
        }
示例#38
0
 /// <summary>
 /// Instantiates a new <see cref="TagHelperChunk"/>.
 /// </summary>
 /// <param name="tagName">The tag name associated with the tag helpers HTML element.</param>
 /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
 /// <param name="attributes">The attributes associated with the tag helpers HTML element.</param>
 /// <param name="descriptors">
 /// The <see cref="TagHelperDescriptor"/>s associated with this tag helpers HTML element.
 /// </param>
 public TagHelperChunk(
     string tagName,
     TagMode tagMode,
     IList<KeyValuePair<string, Chunk>> attributes,
     IEnumerable<TagHelperDescriptor> descriptors)
 {
     TagName = tagName;
     TagMode = tagMode;
     Attributes = attributes;
     Descriptors = descriptors;
 }
        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="items">The collection of items used to communicate with other
        /// <see cref="ITagHelper"/>s</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            string tagName,
            TagMode tagMode,
            IDictionary<object, object> items,
            string uniqueId,
            Func<Task> executeChildContentAsync,
            Action startTagHelperWritingScope,
            Func<TagHelperContent> endTagHelperWritingScope)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException(nameof(tagName));
            }

            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (uniqueId == null)
            {
                throw new ArgumentNullException(nameof(uniqueId));
            }

            if (executeChildContentAsync == null)
            {
                throw new ArgumentNullException(nameof(executeChildContentAsync));
            }

            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            _tagHelpers = new List<ITagHelper>();
            _executeChildContentAsync = executeChildContentAsync;
            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope = endTagHelperWritingScope;

            TagMode = tagMode;
            HTMLAttributes = new TagHelperAttributeList();
            AllAttributes = new TagHelperAttributeList();
            TagName = tagName;
            Items = items;
            UniqueId = uniqueId;
        }
示例#40
0
 /// <summary>
 /// Instantiates a new instance of the <see cref="TagHelperBlockBuilder"/> class
 /// with the provided <paramref name="tagName"/> and derives its <see cref="Attributes"/>
 /// and <see cref="BlockBuilder.Type"/> from the <paramref name="startTag"/>.
 /// </summary>
 /// <param name="tagName">An HTML tag name.</param>
 /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
 /// <param name="start">Starting location of the <see cref="TagHelperBlock"/>.</param>
 /// <param name="attributes">Attributes of the <see cref="TagHelperBlock"/>.</param>
 /// <param name="descriptors">The <see cref="TagHelperDescriptor"/>s associated with the current HTML
 /// tag.</param>
 public TagHelperBlockBuilder(
     string tagName,
     TagMode tagMode,
     SourceLocation start,
     IList<KeyValuePair<string, SyntaxTreeNode>> attributes,
     IEnumerable<TagHelperDescriptor> descriptors)
 {
     TagName = tagName;
     TagMode = tagMode;
     Start = start;
     Descriptors = descriptors;
     Attributes = new List<KeyValuePair<string, SyntaxTreeNode>>(attributes);
     Type = BlockType.Tag;
     ChunkGenerator = new TagHelperChunkGenerator(descriptors);
 }
示例#41
0
 /// <summary>
 /// Convert a <see cref="TagMode"/> to a string used when passing to Flickr.
 /// </summary>
 /// <param name="tagMode">The tag mode to convert.</param>
 /// <returns>The string to pass to Flickr.</returns>
 public static string TagModeToString(TagMode tagMode)
 {
     switch (tagMode)
     {
         case TagMode.None:
             return String.Empty;
         case TagMode.AllTags:
             return "all";
         case TagMode.AnyTag:
             return "any";
         case TagMode.Boolean:
             return "bool";
         default:
             return String.Empty;
     }
 }
示例#42
0
        /// <summary>
        /// Starts a <see cref="TagHelperExecutionContext"/> scope.
        /// </summary>
        /// <param name="tagName">The HTML tag name that the scope is associated with.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this scope is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <returns>A <see cref="TagHelperExecutionContext"/> to use.</returns>
        public TagHelperExecutionContext Begin(
            string tagName,
            TagMode tagMode,
            string uniqueId,
            Func<Task> executeChildContentAsync)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException(nameof(tagName));
            }

            if (uniqueId == null)
            {
                throw new ArgumentNullException(nameof(uniqueId));
            }

            if (executeChildContentAsync == null)
            {
                throw new ArgumentNullException(nameof(executeChildContentAsync));
            }

            IDictionary<object, object> items;
            var parentExecutionContext = _executionContextPool.Current;

            // If we're not wrapped by another TagHelper, then there will not be a parentExecutionContext.
            if (parentExecutionContext != null)
            {
                items = new CopyOnWriteDictionary<object, object>(
                    parentExecutionContext.Items,
                    comparer: EqualityComparer<object>.Default);
            }
            else
            {
                items = new Dictionary<object, object>();
            }

            var executionContext = _executionContextPool.Rent(
                tagName,
                tagMode,
                items,
                uniqueId,
                executeChildContentAsync);

            return executionContext;
        }
示例#43
0
        // Internal for testing
        internal TagHelperBlockBuilder(
            string tagName,
            TagMode tagMode,
            IList<KeyValuePair<string, SyntaxTreeNode>> attributes,
            IEnumerable<SyntaxTreeNode> children)
        {
            TagName = tagName;
            TagMode = tagMode;
            Attributes = attributes;
            Type = BlockType.Tag;
            ChunkGenerator = new TagHelperChunkGenerator(tagHelperDescriptors: null);

            // Children is IList, no AddRange
            foreach (var child in children)
            {
                Children.Add(child);
            }
        }
示例#44
0
        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="items">The collection of items used to communicate with other
        /// <see cref="ITagHelper"/>s</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">A delegate used to start a writing scope in a Razor page.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            [NotNull] string tagName,
            TagMode tagMode,
            [NotNull] IDictionary<object, object> items,
            [NotNull] string uniqueId,
            [NotNull] Func<Task> executeChildContentAsync,
            [NotNull] Action startTagHelperWritingScope,
            [NotNull] Func<TagHelperContent> endTagHelperWritingScope)
        {
            _tagHelpers = new List<ITagHelper>();
            _executeChildContentAsync = executeChildContentAsync;
            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope = endTagHelperWritingScope;

            TagMode = tagMode;
            HTMLAttributes = new TagHelperAttributeList();
            AllAttributes = new TagHelperAttributeList();
            TagName = tagName;
            Items = items;
            UniqueId = uniqueId;
        }
示例#45
0
        public Block TagHelperBlock(
            string tagName,
            TagMode tagMode,
            SourceLocation start,
            Block startTag,
            SyntaxTreeNode[] children,
            Block endTag)
        {
            var builder = new TagHelperBlockBuilder(
                tagName,
                tagMode,
                attributes: new List<KeyValuePair<string, SyntaxTreeNode>>(),
                children: children)
            {
                Start = start,
                SourceStartTag = startTag,
                SourceEndTag = endTag
            };

            return builder.Build();
        }
示例#46
0
 /// <summary>
 /// Search for photos.
 /// </summary>
 /// <param name="tags">A comma seperated list of tags to search for.</param>
 /// <param name="tagMode">Match all tags, or any tag.</param>
 /// <param name="text">Text to search for in photo title or description.</param>
 /// <returns>A <see cref="Photos"/> instance.</returns>
 public Photos PhotosSearch(string tags, TagMode tagMode, string text)
 {
     return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
 }
示例#47
0
 /// <summary>
 /// Search for photos.
 /// </summary>
 /// <param name="userId">The ID of the user to search the photos of.</param>
 /// <param name="tags">A comma seperated list of tags to search for.</param>
 /// <param name="tagMode">Match all tags, or any tag.</param>
 /// <param name="text">Text to search for in photo title or description.</param>
 /// <param name="extras">Optional extras to return.</param>
 /// <returns>A <see cref="Photos"/> instance.</returns>
 public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, PhotoSearchExtras extras)
 {
     return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
 }
示例#48
0
        // Actual PhotoSearch function
        /// <summary>
        /// Search for photos.
        /// </summary>
        /// <param name="userId">The ID of the user to search the photos of.</param>
        /// <param name="tags">A comma seperated list of tags to search for.</param>
        /// <param name="tagMode">Match all tags, or any tag.</param>
        /// <param name="text">Text to search for in photo title or description.</param>
        /// <param name="perPage">Number of photos to return per page.</param>
        /// <param name="page">The page number to return.</param>
        /// <param name="extras">Optional extras to return.</param>
        /// <param name="minUploadDate">The minimum upload date.</param>
        /// <param name="maxUploadDate">The maxmimum upload date.</param>
        /// <param name="license">The license type to return.</param>
        /// <returns>A <see cref="Photos"/> instance.</returns>
        public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, DateTime minUploadDate, DateTime maxUploadDate, int license, int perPage, int page, PhotoSearchExtras extras)
        {
            PhotoSearchOptions options = new PhotoSearchOptions();
            options.UserId = userId;
            options.Tags = tags;
            options.TagMode = tagMode;
            options.Text = text;
            options.MinUploadDate = minUploadDate;
            options.MaxUploadDate = maxUploadDate;
            if( license > 0 ) options.AddLicense(license);
            options.PerPage = perPage;
            options.Page = page;
            options.Extras = extras;

            return PhotosSearch(options);
        }
示例#49
0
 /// <summary>
 /// Switch the mode of a particular Tag to a mode.
 /// Valid Mode are <see cref="TagMode.Seamless"/> and <see cref="TagMode.Manual"/>
 /// </summary>
 /// <param name="name">The name of the tag to switch</param>
 /// <param name="mode">The mode to switch to</param>
 /// <exception cref="ArgumentOutOfRangeException">If the TagMode Specified is not a valid TagMode</exception>
 /// <exception cref="UnhandledException">Unhandled Exception</exception>
 /// <returns>true if the mode can be switch.</returns>
 public bool SwitchMode(string name, TagMode mode)
 {
     try
     {
         switch (mode)
         {
             case TagMode.Seamless: MonitorTag(name, true);
                 break;
             case TagMode.Manual: MonitorTag(name, false);
                 break;
             default:
                 throw new ArgumentOutOfRangeException("mode");
         }
         return true;
     }
     catch (ArgumentOutOfRangeException)
     {
         throw;
     }
     catch (Exception e)
     {
         //Handle some unexpected exception so that it does not hang the UI.
         ServiceLocator.GetLogger(ServiceLocator.DEBUG_LOG).Write(e);
         throw new UnhandledException(e);
     }
 }
示例#50
0
        public async Task RunAsync_SetsTagHelperOutputTagMode(TagMode tagMode)
        {
            // Arrange
            var runner = new TagHelperRunner();
            var executionContext = new TagHelperExecutionContext("p", tagMode);
            var tagHelper = new TagHelperContextTouchingTagHelper();

            executionContext.Add(tagHelper);
            executionContext.AddTagHelperAttribute("foo", true);

            // Act
            var output = await runner.RunAsync(executionContext);

            // Assert
            Assert.Equal(tagMode, output.TagMode);
        }
示例#51
0
        private static TagHelperOutput GetTagHelperOutput(
            string tagName,
            TagHelperAttributeList attributes,
            TagMode tagMode,
            string preElement,
            string preContent,
            string content,
            string postContent,
            string postElement)
        {
            var output = new TagHelperOutput(tagName, attributes)
            {
                TagMode = tagMode
            };

            output.PreElement.AppendEncoded(preElement);
            output.PreContent.AppendEncoded(preContent);
            output.Content.AppendEncoded(content);
            output.PostContent.AppendEncoded(postContent);
            output.PostElement.AppendEncoded(postElement);

            return output;
        }
示例#52
0
 public PhotoSearchOptions(string userId, string tags, TagMode tagMode)
     : this(userId, tags, tagMode, (string) null)
 {
 }
 public PlaceCollection PlacesPlacesForTags(string woeId, IEnumerable<string> tags, TagMode tagMode, DateTime? minUploadDate, DateTime? maxUploadDate, DateTime? minTakenDate, DateTime? maxTakenDate)
 {
     return PlacesPlacesForTags(PlaceType.None, woeId, null, null, tags, tagMode, null, MachineTagMode.None, minUploadDate, maxUploadDate, minTakenDate, maxTakenDate);
 }
示例#54
0
            public TagHelperExecutionContext Rent(
                string tagName,
                TagMode tagMode,
                IDictionary<object, object> items,
                string uniqueId,
                Func<Task> executeChildContentAsync)
            {
                TagHelperExecutionContext tagHelperExecutionContext;

                if (_nextIndex == _executionContexts.Count)
                {
                    tagHelperExecutionContext = new TagHelperExecutionContext(
                        tagName,
                        tagMode,
                        items,
                        uniqueId,
                        executeChildContentAsync,
                        _startTagHelperWritingScope,
                        _endTagHelperWritingScope);

                    _executionContexts.Add(tagHelperExecutionContext);
                }
                else
                {
                    tagHelperExecutionContext = _executionContexts[_nextIndex];
                    tagHelperExecutionContext.Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);
                }

                _nextIndex++;

                return tagHelperExecutionContext;
            }
 public PlaceCollection PlacesPlacesForTags(string woeId, IEnumerable<string> tags, TagMode tagMode)
 {
     return PlacesPlacesForTags(PlaceType.None, woeId, null, null, tags, tagMode, null, MachineTagMode.None, null, null, null, null);
 }
示例#56
0
 /// <summary>
 /// Search for photos.
 /// </summary>
 /// <param name="userId">The ID of the user to search the photos of.</param>
 /// <param name="tags">A comma seperated list of tags to search for.</param>
 /// <param name="tagMode">Match all tags, or any tag.</param>
 /// <param name="text">Text to search for in photo title or description.</param>
 /// <param name="perPage">Number of photos to return per page.</param>
 /// <param name="page">The page number to return.</param>
 /// <returns>A <see cref="Photos"/> instance.</returns>
 public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, int perPage, int page)
 {
     return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, PhotoSearchExtras.All);
 }
示例#57
0
        private void RenderBeginTagHelperScope(string tagName, TagMode tagMode, IList<Chunk> children)
        {
            // Scopes/execution contexts are a runtime feature.
            if (_designTimeMode)
            {
                // Render all of the tag helper children inline for IntelliSense.
                _bodyVisitor.Accept(children);
                return;
            }

            // Call into the tag helper scope manager to start a new tag helper scope.
            // Also capture the value as the current execution context.
            _writer
                .WriteStartAssignment(ExecutionContextVariableName)
                .WriteStartInstanceMethodInvocation(
                    ScopeManagerVariableName,
                    _tagHelperContext.ScopeManagerBeginMethodName);

            // Assign a unique ID for this instance of the source HTML tag. This must be unique
            // per call site, e.g. if the tag is on the view twice, there should be two IDs.
            _writer.WriteStringLiteral(tagName)
                   .WriteParameterSeparator()
                   .Write("global::")
                   .Write(typeof(TagMode).FullName)
                   .Write(".")
                   .Write(tagMode.ToString())
                   .WriteParameterSeparator()
                   .WriteStringLiteral(GenerateUniqueId())
                   .WriteParameterSeparator();

            // We remove the target writer so TagHelper authors can retrieve content.
            var oldWriter = _context.TargetWriterName;
            _context.TargetWriterName = null;

            using (_writer.BuildAsyncLambda(endLine: false))
            {
                // Render all of the tag helper children.
                _bodyVisitor.Accept(children);
            }

            _context.TargetWriterName = oldWriter;

            _writer.WriteEndMethodInvocation();
        }
 public PlaceCollection PlacesPlacesForTags(PlaceType placeTypeId, string woeId, string placeId, int? threshold, IEnumerable<string> tags, TagMode tagMode, IEnumerable<string> machineTags, MachineTagMode machineTagMode, DateTime? minUploadDate, DateTime? maxUploadDate, DateTime? minTakenDate, DateTime? maxTakenDate)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.places.placesForTags");
     if (placeTypeId != PlaceType.None) dictionary.Add("place_type_id", placeTypeId.ToString().ToLower());
     if (woeId != null) dictionary.Add("woe_id", woeId);
     if (placeId != null) dictionary.Add("place_id", placeId);
     if (threshold != null) dictionary.Add("threshold", threshold.ToString().ToLower());
     if (tags != null) dictionary.Add("tags", tags == null ? String.Empty : String.Join(",", tags.ToArray()));
     if (tagMode != TagMode.None) dictionary.Add("tag_mode", tagMode.ToString().ToLower());
     if (machineTags != null) dictionary.Add("machine_tags", machineTags == null ? String.Empty : String.Join(",", machineTags.ToArray()));
     if (machineTagMode != MachineTagMode.None) dictionary.Add("machine_tag_mode", machineTagMode.ToString().ToLower());
     if (minUploadDate != null) dictionary.Add("min_upload_date", minUploadDate.Value.ToUnixTimestamp());
     if (maxUploadDate != null) dictionary.Add("max_upload_date", maxUploadDate.Value.ToUnixTimestamp());
     if (minTakenDate != null) dictionary.Add("min_taken_date", minTakenDate.Value.ToUnixTimestamp());
     if (maxTakenDate != null) dictionary.Add("max_taken_date", maxTakenDate.Value.ToUnixTimestamp());
     return GetResponse<PlaceCollection>(dictionary);
 }
示例#59
0
 /// <summary>
 /// Search for photos.
 /// </summary>
 /// <param name="userId">The ID of the user to search the photos of.</param>
 /// <param name="tags">An array of tags to search for.</param>
 /// <param name="tagMode">Match all tags, or any tag.</param>
 /// <param name="text">Text to search for in photo title or description.</param>
 /// <param name="minUploadDate">The minimum upload date.</param>
 /// <param name="maxUploadDate">The maxmimum upload date.</param>
 /// <param name="license">The license type to return.</param>
 /// <param name="perPage">Number of photos to return per page.</param>
 /// <param name="page">The page number to return.</param>
 /// <returns>A <see cref="Photos"/> instance.</returns>
 public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, DateTime minUploadDate, DateTime maxUploadDate, int license, int perPage, int page)
 {
     return PhotosSearch(userId, String.Join(",", tags), tagMode, text, minUploadDate, maxUploadDate, license, perPage, page, PhotoSearchExtras.All);
 }
示例#60
0
 /// <summary>
 /// Search for photos.
 /// </summary>
 /// <param name="tags">A comma seperated list of tags to search for.</param>
 /// <param name="tagMode">Match all tags, or any tag.</param>
 /// <param name="text">Text to search for in photo title or description.</param>
 /// <param name="perPage">Number of photos to return per page.</param>
 /// <param name="page">The page number to return.</param>
 /// <param name="extras">Optional extras to return.</param>
 /// <returns>A <see cref="Photos"/> instance.</returns>
 public Photos PhotosSearch(string tags, TagMode tagMode, string text, int perPage, int page, PhotoSearchExtras extras)
 {
     return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, extras);
 }