private static string GetTag(Type t) { TagAttribute attr = t.GetTypeInfo() .GetCustomAttributes <TagAttribute>() .FirstOrDefault(); if (attr != null) { return(attr.Tag); } // This hack is used to issue a warning when you load an assembly // more than once. When this happens, even if the assembly is the // same but is loaded from different sources, all the types will // be considered different; so that the preceding code will fail // finding the type TagAttribute, whence a null tag. The code // below will just check for type names, so it will not fail; // yet, other parts of the system will do, as soon as you are going // to compare types. var tag = t.CustomAttributes.FirstOrDefault( a => a.AttributeType.FullName == "Fusi.Tools.Config.TagAttribute") ?.ConstructorArguments[0].Value as string; if (tag != null) { Debug.WriteLine( $"WARNING: assembly {t.Assembly} loaded multiple times!"); } return(tag); }
/// <summary> /// Retrieves all Tag Fields of TField Instance /// </summary> /// <typeparam name="TField">TField type as derived class from CustomField</typeparam> /// <param name="fieldType">type of Field</param> /// <returns>A Dictionary of TField Properties and TField Attributes of TField Class</returns> internal static Dictionary <PropertyInfo, TagAttribute> PropsAndTagsdAttributes <TField>(this Type fieldType) where TField : CustomField { #if NET40 IEnumerable <PropertyInfo> tagFieldProps = fieldType?.GetProperties().Where( prop => Attribute.GetCustomAttributes(prop).Any(attr => attr.GetType() == typeof(TagAttribute))); #else IEnumerable <PropertyInfo> tagFieldProps = fieldType?.GetProperties().Where( prop => prop.GetCustomAttributes().Any(attr => attr.GetType() == typeof(TagAttribute))); #endif if (!tagFieldProps.Any()) { throw new ArgumentException($"for type {fieldType?.FullName} they have not been defined any properties with attibute of TagAttribute"); } var tagPropsAttributesOfT = new Dictionary <PropertyInfo, TagAttribute>(); foreach (PropertyInfo tagFieldProp in tagFieldProps) { #if NET40 TagAttribute tagFieldFieldAttr = (TagAttribute)Attribute.GetCustomAttribute(tagFieldProp, typeof(TagAttribute)); #else TagAttribute tagFieldFieldAttr = tagFieldProp.GetCustomAttribute <TagAttribute>(); #endif tagPropsAttributesOfT.Add(tagFieldProp, tagFieldFieldAttr); } return(tagPropsAttributesOfT); }
static void Main(String[] args) { Memo m1 = new Memo("NTitle3", "Content1"); m1.AddAttribute(new DateAttribute(new DateTime(2013, 6, 6))); TagAttribute tag = new TagAttribute("Project"); tag.Name = "ASDF"; tag.Value = "Purject"; m1.AddAttribute(tag); tag = new TagAttribute(); tag.Value = "Assignment"; m1.AddAttribute(tag); tag.Value = " ASSHOLE "; m1.AddAttribute(new TagAttribute("Bug")); Memo m2 = new Memo("ATitle2", "Content2"); m2.AddAttribute(new TagAttribute("Goal")); Memo m3 = new Memo("AATitle1", "Content3"); m2.AddAttribute(new TagAttribute("Project")); m3.AddAttribute(new TagAttribute("Bug")); MemoList ml1 = new MemoList(); ml1.SetTitle("MemoList1"); MemoList ml2 = new MemoList(); ml2.SetTitle("MemoList2"); ml1.Add(m1); ml1.Add(m2); ml2.Add(m3); ml1.Sort(MemoList.MemoListSortingEnumeration.Title); Console.WriteLine(ml1.ToString()); Console.WriteLine(ml2.ToString()); }
void OnTagChanged(int oldValue, int newValue, SerializedProperty property) { Asset asset = property?.serializedObject.targetObject as Asset; int metricIndex = GetMetricIndex(property); int change = oldValue ^ newValue; List <Type> tagTypes = TagAttribute.GetVisibleTypesInInspector().ToList(); if ((change & (change - 1)) == 0) // power of 2, only one change, perform below to avoid looping over all tags { var index = (int)Math.Log(change, 2); if (index < tagTypes.Count) { Type tagType = tagTypes[index]; ApplyTagChange(asset, metricIndex, newValue, index, tagType); } } else // multiple changes { for (int index = 0; index < TagAttribute.GetAllDescriptions().Count; ++index) { if ((change & (1 << index)) != 0) { Type tagType = tagTypes[index]; ApplyTagChange(asset, metricIndex, newValue, index, tagType); } } } }
public void TestEquivalence() { var attr = new TagAttribute("align", "left"); var attr2 = new TagAttribute("align", "left"); Assert.AreEqual(attr, attr2); }
public IEnumerable <Token> ParseLine(string line) { var result = new List <Token>(); for (int i = 0; i < line.Length; i++) { if (DetermineRuleOfSubline(line, i) == null) { continue; } var offset = (i == 0) ? 0 : 1; var subLine = line.Substring(i - offset); var markdownTag = getMarkdownTag.Match(subLine); if (markdownTag.Length == 0 || !subLine.StartsWith(markdownTag.Value)) { continue; } var text = markdownTag.Groups[2].Value; var linkAttribute = new TagAttribute($"{markdownTag.Groups[3].Value}", "href");; var titleAttribute = new TagAttribute(markdownTag.Groups[4].Value, "title"); var attributes = new List <TagAttribute> { linkAttribute, titleAttribute }; var linkTag = new Link() { MarkdownTag = markdownTag.Groups[1].Value, Attributes = attributes, TextInsideTag = text }; result.Add(new Token(i, i + markdownTag.Groups[1].Value.Length, linkTag)); i += markdownTag.Groups[1].Length; } return(result); }
public IEnumerable <Token> ParseLine(string line) { var result = new List <Token>(); for (var i = 0; i < line.Length; i++) { if (DetermineRuleOfSubline(line, i) is null) { continue; } var tag = getFullMarkdownTag.Match(line.Substring(i)); if (tag.Length == 0) { continue; } var src = new TagAttribute(tag.Groups[2].Value, "src"); var alt = new TagAttribute(tag.Groups[1].Value, "alt"); var attributes = new List <TagAttribute>() { src, alt }; var newTag = new ImageTag { Attributes = attributes, MarkdownTag = tag.Groups[0].Value }; result.Add(new Token(i, newTag)); i += tag.Length; } return(result); }
public static void Recompile() { Dictionary <string, Type> tagTypes = new Dictionary <string, Type>(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in assembly.GetTypes()) { TagAttribute attribute = type.GetCustomAttribute <TagAttribute>(); if (attribute == null || attribute.Tags == null) { continue; } foreach (string tag in attribute.Tags) { tagTypes[tag] = type; } } } StringBuilder tagPrebuildBuilder = new StringBuilder(); tagPrebuildBuilder.AppendLine("using System;"); tagPrebuildBuilder.AppendLine("using System.Collections.Generic;"); tagPrebuildBuilder.AppendLine(); tagPrebuildBuilder.AppendLine("public static class TagPrebuild"); tagPrebuildBuilder.AppendLine("{"); tagPrebuildBuilder.AppendLine("\tstatic readonly Dictionary<string, Type> m_TagTypes = new Dictionary<string, Type>()"); tagPrebuildBuilder.AppendLine("\t{"); foreach (var entry in tagTypes) { tagPrebuildBuilder.AppendFormat("\t\t{{ \"{0}\", typeof({1}) }},", entry.Key, entry.Value.Name).AppendLine(); } tagPrebuildBuilder.AppendLine("\t};"); tagPrebuildBuilder.AppendLine(); tagPrebuildBuilder.AppendLine("\tpublic static Type GetTagType(string _Tag)"); tagPrebuildBuilder.AppendLine("\t{"); tagPrebuildBuilder.AppendLine("\t\treturn m_TagTypes.ContainsKey(_Tag) ? m_TagTypes[_Tag] : null;"); tagPrebuildBuilder.AppendLine("\t}"); tagPrebuildBuilder.AppendLine("}"); const string directory = "Assets/Scripts/Prebuild/"; const string filename = "TagPrebuild.cs"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } File.WriteAllText(directory + filename, tagPrebuildBuilder.ToString()); }
public void TypeHasTagAttribute() { Type t = typeof(ChronotopicsPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.chronotopics", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(TiledTextLayerPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.net.fusisoft.tiled-text-layer", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(VarQuotationsLayerFragmentSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.fr.it.vedph.tgr.var-quotations", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(AvailableWitnessesPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.tgr.available-witnesses", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(SerialTextInfoPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.serial-text-info", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(NotePartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.net.fusisoft.note", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(PersonWorksPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.person-works", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(WordFormsPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.pura.word-forms", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(CorrPseudonymsPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.corr-pseudonyms", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(MsHistoryPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.ms-history", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(MsPlacesPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.tgr.ms-places", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(ApparatusLayerFragmentSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.fr.net.fusisoft.apparatus", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(LitDedicationsPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.itinera.lit-dedications", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(LemmaTagLayerFragmentSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.fr.it.vedph.pura.lemma-tag", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(PrisonerInfoPartSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.it.vedph.ingra.prisoner-info", attr.Tag); }
public void TypeHasTagAttribute() { Type t = typeof(LingTagsLayerFragmentSeeder); TagAttribute attr = t.GetTypeInfo().GetCustomAttribute <TagAttribute>(); Assert.NotNull(attr); Assert.Equal("seed.fr.it.vedph.tgr.ling-tags", attr.Tag); }
/// <summary> /// Adds a TagAttribute's tag value. /// </summary> /// <param name="tag">The tag object.</param> public void Add(Attribute tag) { TagAttribute attr = tag as TagAttribute; if (attr != null && !Contains(attr.Tag)) { Add(attr.Tag); } }
/// <summary> /// Initializes a new instance of the <see cref="PartBase"/> class. /// </summary> protected PartBase() { Id = Guid.NewGuid().ToString(); TagAttribute attr = GetType().GetTypeInfo() .GetCustomAttribute <TagAttribute>(); TypeId = attr != null ? attr.Tag : GetType().FullName; TimeCreated = TimeModified = DateTime.UtcNow; }
public void Fragment_Has_Tag() { TagAttribute attr = typeof(QuotationsLayerFragment).GetTypeInfo() .GetCustomAttribute <TagAttribute>(); string typeId = attr != null ? attr.Tag : GetType().FullName; Assert.NotNull(typeId); Assert.StartsWith(PartBase.FR_PREFIX, typeId); }
/// <summary> Scan for script. /// Accumulates text from the page, until </[a-zA-Z] is encountered. /// </summary> /// <param name="tag">The tag this scanner is responsible for. /// </param> /// <param name="lexer">The source of CDATA. /// </param> /// <param name="stack">The parse stack, <em>not used</em>. /// </param> public override ITag Scan(ITag tag, Lexer lexer, NodeList stack) { System.String language; System.String code; INode content; int position; INode node; TagAttribute attribute; System.Collections.ArrayList vector; if (tag is ScriptTag) { language = ((ScriptTag)tag).Language; if ((null != language) && (language.ToUpper().Equals("JScript.Encode".ToUpper()) || language.ToUpper().Equals("VBScript.Encode".ToUpper()))) { code = ScriptDecoder.Decode(lexer.Page, lexer.Cursor); ((ScriptTag)tag).ScriptCode = code; } } content = lexer.ParseCDATA(!STRICT); position = lexer.Position; node = lexer.NextNode(false); if (null != node) { if (!(node is ITag) || !(((ITag)node).IsEndTag() && ((ITag)node).TagName.Equals(tag.Ids[0]))) { lexer.Position = position; node = null; } } // build new end tag if required if (null == node) { attribute = new TagAttribute("/script", null); #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR vector = ArrayList_WP_8_1.ArrayList.Synchronized(new System.Collections.ArrayList(10)); #else vector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); #endif vector.Add(attribute); node = lexer.NodeFactory.CreateTagNode(lexer.Page, position, position, vector); } tag.SetEndTag((ITag)node); if (null != content) { tag.Children = new NodeList(content); content.Parent = tag; } node.Parent = tag; tag.DoSemanticAction(); return(tag); }
public bool Matches(MemberInfo member) { foreach (Attribute attr in member.GetCustomAttributes(typeof(TagAttribute), true)) { TagAttribute tagAttr = (TagAttribute)attr; if (tagAttr.Tag == tagToMatch) { return(true); } } return(false); }
public TalTagAttribute(TagAttribute tagAttr) { Name = tagAttr.Name; Value = tagAttr.Value; Eq = tagAttr.Eq; Quote = tagAttr.Quote; QuoteEntity = tagAttr.QuoteEntity; var attr = tagAttr as TalTagAttribute; if (attr != null) { CommandType = attr.CommandType; } }
/// <summary> /// Gets the byte serialization tag for a given type. /// </summary> /// <param name="type">Type to look up.</param> /// <returns>The tag to use for (de)serialization.</returns> public byte GetTag() { MemberInfo enumMember = typeof(Type).GetMember(VariantType.ToString()) .FirstOrDefault(); TagAttribute tag = enumMember.GetCustomAttribute <TagAttribute>(); if (tag == null) { // Shouldn't happen throw new InvalidOperationException(); } return(tag.Value); }
public void AddRootAttribute(Guid objectId, string tagName, string objectType) { if (db.TagAttributes.Where(x => x.ObjectId == objectId && x.ObjectDeepLevel == 1).Count() != 1) { TagAttribute rootNode = new TagAttribute { TagId = Guid.NewGuid(), TagName = tagName, ObjectId = objectId, ObjectDeepLevel = 1, ObjectType = objectType }; db.TagAttributes.Add(rootNode); db.SaveChanges(); } this.RootId = db.TagAttributes.Where(x => x.ObjectId == objectId && x.ObjectDeepLevel == 1).SingleOrDefault().TagId; }
public void AddSecondLevelAttribute(Guid objectId, string tagName, string objectType) { if (db.TagAttributes.Where(x => x.ObjectId == objectId && x.ObjectDeepLevel == 2 && x.TagName == tagName).Count() != 1) { TagAttribute classificationNode = new TagAttribute { TagId = Guid.NewGuid(), TagName = tagName, TagValue = tagName, ParentId = this.RootId, ObjectId = objectId, ObjectDeepLevel = 2, ObjectType = objectType }; db.TagAttributes.Add(classificationNode); db.SaveChanges(); } this.ClassificationId = db.TagAttributes.Where(x => x.ObjectId == objectId && x.ObjectDeepLevel == 2 && x.TagName == tagName).SingleOrDefault().TagId; this.ClassificationName = db.TagAttributes.Where(x => x.ObjectId == objectId && x.ObjectDeepLevel == 2 && x.TagName == tagName).SingleOrDefault().TagName; }
// Function to identify and validate the rich tag. Returns the position of the > if the tag was valid. bool ValidateHtmlTag(int[] chars, int startIndex, out int endIndex) { Array.Clear(m_htmlTag, 0, m_htmlTag.Length); int tagCharCount = 0; int tagHashCode = 0; TagAttribute attribute_1 = new TagAttribute(); TagAttribute attribute_2 = new TagAttribute(); byte attributeFlag = 0; TagUnits tagUnits = TagUnits.Pixels; int numSequenceStart = 0; int numSequenceEnd = 0; int numSequenceDecimalPos = 0; int numSequenceUnitPos = 0; endIndex = startIndex; bool isValidHtmlTag = false; bool hasNumericalValue = false; for (int i = startIndex; i < chars.Length && chars[i] != 0 && tagCharCount < m_htmlTag.Length && chars[i] != 60; i++) { if (chars[i] == 62) // ASCII Code of End HTML tag '>' { isValidHtmlTag = true; endIndex = i; m_htmlTag[tagCharCount] = (char)0; if (numSequenceEnd == 0) numSequenceEnd = tagCharCount - 1; break; } m_htmlTag[tagCharCount] = (char)chars[i]; tagCharCount += 1; // Compute HashCode for 1st attribute if (attributeFlag == 1) { if (chars[i] != 34) // Exclude quotes from the HashCode. { if (attribute_1.startIndex == 0) attribute_1.startIndex = tagCharCount - 1; attribute_1.hashCode = (attribute_1.hashCode << 5) - attribute_1.hashCode + chars[i]; attribute_1.length += 1; } else if (attribute_1.startIndex != 0) attributeFlag = 2; } // Compute HashCode for 2st attribute if (attributeFlag == 3) { if (chars[i] != 34) // Exclude quotes from the HashCode. { if (attribute_2.startIndex == 0) attribute_2.startIndex = tagCharCount - 1; attribute_2.hashCode = (attribute_2.hashCode << 5) - attribute_2.hashCode + chars[i]; attribute_2.length += 1; } else if (attribute_2.startIndex != 0) attributeFlag = 0; } // Extract numerical value and unit type (px, em, %) if (chars[i] == 61) // '=' { numSequenceStart = tagCharCount; attributeFlag += 1; } else if (chars[i] == 46) // '.' numSequenceDecimalPos = tagCharCount - 1; else if (numSequenceStart != 00 && !hasNumericalValue && char.IsDigit((char)chars[i])) hasNumericalValue = true; else if (numSequenceStart != 0 && numSequenceUnitPos == 0 && (chars[i] == 112 || chars[i] == 101 || chars[i] == 37)) { numSequenceEnd = tagCharCount - 2; numSequenceUnitPos = tagCharCount - 1; if (chars[i] == 101) tagUnits = TagUnits.FontUnits; else if (chars[i] == 37) tagUnits = TagUnits.Percentage; } // Compute HashCode for the <tag> if (numSequenceStart == 0) tagHashCode = (tagHashCode << 3) - tagHashCode + chars[i]; } if (!isValidHtmlTag) { return false; } //Debug.Log("Tag is [" + m_htmlTag.ArrayToString() + "]. Tag HashCode: " + tagHashCode + " Attribute HashCode: " + attribute_1.hashCode); // Special handling of the NoParsing tag if (tag_NoParsing && tagHashCode != 53822163) return false; else if (tagHashCode == 53822163) { tag_NoParsing = false; return true; } // Color <#FF00FF> if (m_htmlTag[0] == 35 && tagCharCount == 7) // if Tag begins with # and contains 7 characters. { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; } // Color <#FF00FF00> with alpha else if (m_htmlTag[0] == 35 && tagCharCount == 9) // if Tag begins with # and contains 9 characters. { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; } else { float value = 0; switch (tagHashCode) { case 98: // <b> m_style |= FontStyles.Bold; return true; case 427: // </b> if ((m_fontStyle & FontStyles.Bold) != FontStyles.Bold) m_style &= ~FontStyles.Bold; return true; case 105: // <i> m_style |= FontStyles.Italic; return true; case 434: // </i> m_style &= ~FontStyles.Italic; return true; case 115: // <s> m_style |= FontStyles.Strikethrough; return true; case 444: // </s> if ((m_fontStyle & FontStyles.Strikethrough) != FontStyles.Strikethrough) m_style &= ~FontStyles.Strikethrough; return true; case 117: // <u> m_style |= FontStyles.Underline; return true; case 446: // </u> if ((m_fontStyle & FontStyles.Underline) != FontStyles.Underline) m_style &= ~FontStyles.Underline; return true; case 6552: // <sub> m_currentFontSize *= m_fontAsset.fontInfo.SubSize > 0 ? m_fontAsset.fontInfo.SubSize : 1; // Subscript characters are half size. m_fontScale = m_currentFontSize / m_fontAsset.fontInfo.PointSize; m_baselineOffset = m_fontAsset.fontInfo.SubscriptOffset * m_fontScale; m_style |= FontStyles.Subscript; //m_isRecalculateScaleRequired = true; return true; case 22673: // </sub> m_currentFontSize /= m_fontAsset.fontInfo.SubSize > 0 ? m_fontAsset.fontInfo.SubSize : 1; //m_fontSize / m_fontAsset.FontInfo.PointSize * .1f; m_baselineOffset = 0; m_fontScale = m_currentFontSize / m_fontAsset.fontInfo.PointSize; m_style &= ~FontStyles.Subscript; //m_isRecalculateScaleRequired = true; return true; case 6566: // <sup> m_currentFontSize *= m_fontAsset.fontInfo.SubSize > 0 ? m_fontAsset.fontInfo.SubSize : 1; m_fontScale = m_currentFontSize / m_fontAsset.fontInfo.PointSize; m_baselineOffset = m_fontAsset.fontInfo.SuperscriptOffset * m_fontScale; m_style |= FontStyles.Superscript; //m_isRecalculateScaleRequired = true; return true; case 22687: // </sup> m_currentFontSize /= m_fontAsset.fontInfo.SubSize > 0 ? m_fontAsset.fontInfo.SubSize : 1; //m_fontSize / m_fontAsset.FontInfo.PointSize * .1f; m_baselineOffset = 0; m_fontScale = m_currentFontSize / m_fontAsset.fontInfo.PointSize; m_style &= ~FontStyles.Superscript; //m_isRecalculateScaleRequired = true; return true; case 6380: // <pos=000.00px> <pos=0em> <pos=50%> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_xAdvance = value; //m_isIgnoringAlignment = true; return true; case TagUnits.FontUnits: m_xAdvance = value * m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; //m_isIgnoringAlignment = true; return true; case TagUnits.Percentage: m_xAdvance = m_marginWidth * value / 100; //m_isIgnoringAlignment = true; return true; } return false; case 22501: // </pos> m_isIgnoringAlignment = false; return true; case 16034505: // <voffset> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_baselineOffset = value; return true; case TagUnits.FontUnits: m_baselineOffset = value * m_fontScale * m_fontAsset.fontInfo.Ascender; return true; case TagUnits.Percentage: //m_baselineOffset = m_marginHeight * val / 100; return false; } return false; case 54741026: // </voffset> m_baselineOffset = 0; return true; case 43991: // <page> // This tag only works when Overflow - Page mode is used. if (m_overflowMode == TextOverflowModes.Page) { m_xAdvance = 0 + tag_LineIndent + tag_Indent; //m_textInfo.lineInfo[m_lineNumber].marginLeft = m_xAdvance; m_lineOffset = 0; m_pageNumber += 1; m_isNewPage = true; } return true; case 43969: // <nobr> m_isNonBreakingSpace = true; return true; case 156816: // </nobr> m_isNonBreakingSpace = false; return true; case 45545: // <size=> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: if (m_htmlTag[5] == 43) // <size=+00> { m_currentFontSize = m_fontSize + value; m_isRecalculateScaleRequired = true; return true; } else if (m_htmlTag[5] == 45) // <size=-00> { m_currentFontSize = m_fontSize + value; m_isRecalculateScaleRequired = true; return true; } else // <size=00.0> { m_currentFontSize = value; m_isRecalculateScaleRequired = true; return true; } case TagUnits.FontUnits: m_currentFontSize *= value; m_isRecalculateScaleRequired = true; return true; case TagUnits.Percentage: m_currentFontSize = m_fontSize * value / 100; m_isRecalculateScaleRequired = true; return true; } return false; case 158392: // </size> m_currentFontSize = m_fontSize; m_isRecalculateScaleRequired = true; //m_fontScale = m_fontSize / m_fontAsset.fontInfo.PointSize * .1f; return true; case 41311: // <font=xx> //Debug.Log("Font name: \"" + new string(m_htmlTag, attribute_1.startIndex, attribute_1.length) + "\" HashCode: " + attribute_1.hashCode + " Material Name: \"" + new string(m_htmlTag, attribute_2.startIndex, attribute_2.length) + "\" Hashcode: " + attribute_2.hashCode); int fontHashCode = attribute_1.hashCode; int materialHashCode = attribute_2.hashCode; TextMeshProFont tempFont; Material tempMaterial; // HANDLE NEW FONT ASSET if (m_fontAsset_Dict.TryGetValue(fontHashCode, out tempFont)) { if (tempFont != m_currentFontAsset) { //Debug.Log("Assigning Font Asset: " + tempFont.name); m_currentFontAsset = m_fontAsset_Dict[fontHashCode]; m_isRecalculateScaleRequired = true; } } else { // Load new font asset tempFont = Resources.Load("Fonts & Materials/" + new string(m_htmlTag, attribute_1.startIndex, attribute_1.length), typeof(TextMeshProFont)) as TextMeshProFont; if (tempFont != null) { //Debug.Log("Loading and Assigning Font Asset: " + tempFont.name); m_fontAsset_Dict.Add(fontHashCode, tempFont); m_currentFontAsset = tempFont; m_isRecalculateScaleRequired = true; } else return false; } // HANDLE NEW MATERIAL if (materialHashCode == 0) { if (!m_fontMaterial_Dict.TryGetValue(m_currentFontAsset.materialHashCode, out tempMaterial)) m_fontMaterial_Dict.Add(m_currentFontAsset.materialHashCode, m_currentFontAsset.material); if (m_currentMaterial != m_currentFontAsset.material) { //Debug.Log("Assigning Default Font Asset Material: " + m_currentFontAsset.material.name); m_currentMaterial = m_currentFontAsset.material; } } else if (m_fontMaterial_Dict.TryGetValue(materialHashCode, out tempMaterial)) { if (tempMaterial != m_currentMaterial) { //Debug.Log("Assigning Material: " + tempMaterial.name); m_currentMaterial = tempMaterial; } } else { // Load new material tempMaterial = Resources.Load("Fonts & Materials/" + new string(m_htmlTag, attribute_2.startIndex, attribute_2.length), typeof(Material)) as Material; if (tempMaterial != null) { //Debug.Log("Loading and Assigning Material: " + tempMaterial.name); m_fontMaterial_Dict.Add(materialHashCode, tempMaterial); m_currentMaterial = tempMaterial; } else return false; } return true; case 320078: // <space=000.00> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_xAdvance += value; return true; case TagUnits.FontUnits: m_xAdvance += value * m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; return true; case TagUnits.Percentage: // Not applicable return false; } return false; case 276254: // <alpha=#FF> m_htmlColor.a = (byte)(HexToInt(m_htmlTag[7]) * 16 + HexToInt(m_htmlTag[8])); return true; case 1750458: // <a name=" "> return true; case 426: // </a> return true; case 43066: // <link="name"> if (m_isParsingText) { tag_LinkInfo.hashCode = attribute_1.hashCode; tag_LinkInfo.firstCharacterIndex = m_characterCount; //Debug.Log("Link begin at Character # " + m_characterCount); } return true; case 155913: // </link> if (m_isParsingText) { tag_LinkInfo.lastCharacterIndex = m_characterCount - 1; tag_LinkInfo.characterCount = m_characterCount - tag_LinkInfo.firstCharacterIndex; m_textInfo.linkInfo.Add(tag_LinkInfo); m_textInfo.linkCount += 1; //Debug.Log("*** LinkInfo Element Added ***\nHashCode: " + tag_LinkInfo.hashCode + " First Index: " + tag_LinkInfo.firstCharacterIndex + " Last Index: " + tag_LinkInfo.lastCharacterIndex + " Link Count: " + m_textInfo.linkCount); } return true; case 275917: // <align=> switch (attribute_1.hashCode) { case 3317767: // <align=left> m_lineJustification = TextAlignmentOptions.Left; return true; case 108511772: // <align=right> m_lineJustification = TextAlignmentOptions.Right; return true; case -1364013995: // <align=center> m_lineJustification = TextAlignmentOptions.Center; return true; case 1838536479: // <align=justified> m_lineJustification = TextAlignmentOptions.Justified; return true; } return false; case 1065846: // </align> m_lineJustification = m_textAlignment; return true; case 327550: // <width=xx> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_width = value; break; case TagUnits.FontUnits: return false; //break; case TagUnits.Percentage: m_width = m_marginWidth * value / 100; break; } return true; case 1117479: // </width> m_width = -1; return true; case 322689: // <style="name"> TMP_Style style = TMP_StyleSheet.Instance.GetStyle(attribute_1.hashCode); if (style == null) return false; m_styleStack[m_styleStackIndex] = style.hashCode; m_styleStackIndex += 1; //// Parse Style Macro for (int i = 0; i < style.styleOpeningTagArray.Length; i++) { if (style.styleOpeningTagArray[i] == 60) ValidateHtmlTag(style.styleOpeningTagArray, i + 1, out i); } return true; case 1112618: // </style> style = TMP_StyleSheet.Instance.GetStyle(attribute_1.hashCode); if (style == null) { // Get style from the Style Stack m_styleStackIndex = m_styleStackIndex > 0 ? m_styleStackIndex - 1 : 0; style = TMP_StyleSheet.Instance.GetStyle(m_styleStack[m_styleStackIndex]); } if (style == null) return false; //// Parse Style Macro for (int i = 0; i < style.styleClosingTagArray.Length; i++) { if (style.styleClosingTagArray[i] == 60) ValidateHtmlTag(style.styleClosingTagArray, i + 1, out i); } return true; case 281955: // <color=#FF00FF> or <color=#FF00FF00> // <color=#FF00FF> if (m_htmlTag[6] == 35 && tagCharCount == 13) { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; } // <color=#FF00FF00> else if (m_htmlTag[6] == 35 && tagCharCount == 15) { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; } // <color=name> switch (attribute_1.hashCode) { case 112785: // <color=red> m_htmlColor = Color.red; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case 3027034: // <color=blue> m_htmlColor = Color.blue; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case 93818879: // <color=black> m_htmlColor = Color.black; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case 98619139: // <color=green> m_htmlColor = Color.green; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case 113101865: // <color=white> m_htmlColor = Color.white; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case -1008851410: // <color=orange> m_htmlColor = new Color32(255, 128, 0, 255); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case -976943172: // <color=purple> m_htmlColor = new Color32(160, 32, 240, 255); m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; case -734239628: // <color=yellow> m_htmlColor = Color.yellow; m_colorStack[m_colorStackIndex] = m_htmlColor; m_colorStackIndex += 1; return true; } return false; case 1983971: // <cspace=xx.x> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_cSpacing = value; break; case TagUnits.FontUnits: m_cSpacing = value; m_cSpacing *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: return false; } return true; case 7513474: // </cspace> m_cSpacing = 0; return true; case 2152041: // <mspace=xx.x> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_monoSpacing = value; break; case TagUnits.FontUnits: m_monoSpacing = value; m_monoSpacing *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: return false; } return true; case 7681544: // </mspace> m_monoSpacing = 0; return true; case 280416: // <class="name"> return false; case 1071884: // </color> m_colorStackIndex -= 1; if (m_colorStackIndex <= 0) { m_htmlColor = m_fontColor32; m_colorStackIndex = 0; } else { m_htmlColor = m_colorStack[m_colorStackIndex - 1]; } return true; case 2068980: // <indent=10px> <indent=10em> <indent=50%> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: tag_Indent = value; break; case TagUnits.FontUnits: tag_Indent *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: tag_Indent = m_marginWidth * tag_Indent / 100; break; } m_xAdvance = tag_Indent; return true; case 7598483: // </indent> tag_Indent = 0; return true; case 1109386397: // <line-indent> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: tag_LineIndent = value; break; case TagUnits.FontUnits: tag_LineIndent = value; tag_LineIndent *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: tag_LineIndent = m_marginWidth * tag_LineIndent / 100; break; } m_xAdvance += tag_LineIndent; return true; case -445537194: // </line-indent> tag_LineIndent = 0; return true; case 2246877: // <sprite=x> if (m_inlineGraphics == null) m_inlineGraphics = GetComponent<InlineGraphicManager>() ?? gameObject.AddComponent<InlineGraphicManager>(); if (char.IsDigit(m_htmlTag[7])) { int index = (int)ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); m_spriteIndex = m_inlineGraphics.GetSpriteIndexByIndex(index); if (m_spriteIndex == -1) return false; } else { // Get sprite index by looking it up by name. m_spriteIndex = m_inlineGraphics.GetSpriteIndexByHashCode(attribute_1.hashCode); if (m_spriteIndex == -1) return false; //Debug.Log("Sprite name is: \"" + new string(m_htmlTag, attribute_1.startIndex, attribute_1.length) + "\" with HashCode: " + attribute_1.hashCode); } m_isSprite = true; return true; case 13526026: // <allcaps> m_style |= FontStyles.UpperCase; return true; case 52232547: // </allcaps> m_style &= ~FontStyles.UpperCase; return true; case 766244328: // <smallcaps> m_style |= FontStyles.SmallCaps; return true; case -1632103439: // </smallcaps> m_style &= ~FontStyles.SmallCaps; m_isRecalculateScaleRequired = true; return true; case 2109854: // <margin=00.0> <margin=00em> <margin=50%> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); // px if (value == -9999 || value == 0) return false; m_marginLeft = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginLeft *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100; break; } m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0; m_marginRight = m_marginLeft; return true; case 7639357: // </margin> m_marginLeft = 0; m_marginRight = 0; return true; case 1100728678: // <margin-left=xx.x> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); // px if (value == -9999 || value == 0) return false; m_marginLeft = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginLeft *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100; break; } m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0; return true; case -884817987: // <margin-right=xx.x> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); // px if (value == -9999 || value == 0) return false; m_marginRight = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginRight *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.TabSize; break; case TagUnits.Percentage: m_marginRight = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginRight / 100; break; } m_marginRight = m_marginRight >= 0 ? m_marginRight : 0; return true; case 1109349752: // <line-height=xx.x> value = ConvertToFloat(m_htmlTag, numSequenceStart, numSequenceEnd, numSequenceDecimalPos); if (value == -9999 || value == 0) return false; m_lineHeight = value; switch (tagUnits) { case TagUnits.Pixels: m_lineHeight /= m_fontScale; break; case TagUnits.FontUnits: m_lineHeight *= m_fontAsset.fontInfo.LineHeight; break; case TagUnits.Percentage: m_lineHeight = m_fontAsset.fontInfo.LineHeight * m_lineHeight / 100; break; } return true; case -445573839: // </line-height> m_lineHeight = 0; return true; case 15115642: // <noparse> tag_NoParsing = true; return true; } } return false; }
private Node CreateNodeFromObject(TagAttribute tagAttribute) { return new Node { id = tagAttribute.TagId.ToString(), title = tagAttribute.TagName, type = "Profile", url = "http://congphuc.net" }; }
public void AddThirdLevelAttribute(object attributeObject, Guid objectId, string objectType, string tableReference) { var listAttributeObjects = AttributeManager.GetProperiesFromTypeByAttribute<TagMemberAttribute>(attributeObject); List<TagAttribute> lisTagAttributes = new List<TagAttribute>(); foreach(var i in listAttributeObjects) { string tagValue = string.Empty; if (i.PropertyValue != null) { tagValue = i.ToString(); } TagAttribute tag = new TagAttribute(); switch (i.TaggingType) { case TaggingType.ColumnNameAsTag: tag.TagName = i.Property.Name; tag.TagValue = i.PropertyValue.ToString(); break; case TaggingType.ValueAsTag: tag.TagName = i.PropertyValue.ToString(); tag.TagValue = i.PropertyValue.ToString(); break; case TaggingType.ReferenceColumnNameAsTag: string referenceValueProperty = i.ReferenceValueProperty; string value = listAttributeObjects.Where(x=>x.Property.Name == referenceValueProperty).FirstOrDefault().PropertyValue.ToString(); tag.TagName = i.PropertyValue.ToString(); tag.TagValue = value; break; case TaggingType.ReferenceValueAsTag: break; } tag.TagId = Guid.NewGuid(); tag.ObjectId = objectId; tag.ObjectType = objectType; tag.ObjectDeepLevel = 3; tag.ParentId = this.ClassificationId; tag.ParentName = this.ClassificationName; tag.ModifiedDate = DateTime.Now; tag.TableReference = tableReference; if (i.TaggingType != TaggingType.ReferenceValueAsTag) { lisTagAttributes.Add(tag); } } ///Save TagAttribute List foreach (var tag in lisTagAttributes) { db.TagAttributes.Add(tag); } db.SaveChanges(); }