// Construtors public Node(IAttributes attribute, List <int> index) { Attribute = attribute; //continuous if (Attribute.GetAttributeType() == "continuous") { Threshold = attribute.GetThreshold(); // setting the Branchs lessThanBranch = new Branch("less", Attribute.GetLessThanList(index, Threshold)); GreaterThanBranch = new Branch("greater", Attribute.GetGreaterThanList(index, Threshold)); // add to branches branchs.Add(lessThanBranch); branchs.Add(GreaterThanBranch); // Sets the type of node nodeType = "Continuous"; } if (Attribute.GetAttributeType() == "discrete") { //Create branches foreach (string value in Attribute.GetAttributeValues()) { branchs.Add(new Branch(value, Attribute.GetAttributeValueList(index, value))); } // sets the type of node nodeType = "Discrete"; } }
public AttributesBase( IAttributes provider ) { this.provider = provider; if( provider != null ) provider.ValueChanged += OnPropertyChanged; }
public StyleTag(string tagName, IAttributes attributes, string innerText, DocInfo docInfo) { Attributes = attributes; InnerText = innerText; TagName = tagName; DocInfo = docInfo; }
void IContentHandler.StartElement(string uri, string localName, string qName, IAttributes atts) { XmlQualifiedName q = new XmlQualifiedName(localName, uri); XmlElement elem = m_factory.GetElement(Prefix(qName), q, m_doc); for (int i=0; i<atts.Length; i++) { XmlAttribute a = m_doc.CreateAttribute(Prefix(atts.GetQName(i)), atts.GetLocalName(i), atts.GetUri(i)); a.AppendChild(m_doc.CreateTextNode(atts.GetValue(i))); elem.SetAttributeNode(a); } if ((elem.LocalName != "stream") || (elem.NamespaceURI != URI.STREAM)) { if (m_stanza != null) m_stanza.AppendChild(elem); m_stanza = elem; } else { FireOnDocumentStart(elem); } }
public QuestionnaireController(IQuestionSets qs, IResponseSets rs, IQuestions q, IAttributes a) { this.QuestionSets = qs; this.ResponseSets = rs; this.Questions = q; this.Attributes = a; }
public ContentFormSubmitEventArgs(int siteId, int channelId, IContentInfo contentInfo, IAttributes form) { SiteId = siteId; ChannelId = channelId; ContentInfo = contentInfo; Form = form; }
internal MyCharacter(byte[] binData) { // TODO check if size of the hex chunk is correct (432) _binData = binData; // Spell Points byte[] binDataSP = new byte[LengthSpellPoints]; Array.Copy(_binData, OffsetSpellPoints, binDataSP, 0, LengthSpellPoints); _spellPoints = new MySpellPoints(binDataSP); // Attributes byte[] binDataAttributes = new byte[Constants.LengthAttributes]; Array.Copy(_binData, Constants.OffsetAttributes, binDataAttributes, 0, Constants.LengthAttributes); _attributes = new MyAttributes(binDataAttributes); // Skills byte[] binDataSkills = new byte[Constants.LengthSkills]; Array.Copy(_binData, Constants.OffsetSkills, binDataSkills, 0, Constants.LengthSkills); _skills = new MySkills(binDataSkills); // Resistances byte[] binDataResistances = new byte[LengthResistances]; Array.Copy(_binData, OffsetResistances, binDataResistances, 0, LengthResistances); _resistances = new MyResistances(binDataResistances); }
internal SpanData( ISpanContext context, ISpanId parentSpanId, bool?hasRemoteParent, string name, ITimestamp startTimestamp, IAttributes attributes, ITimedEvents <IAnnotation> annotations, ITimedEvents <IMessageEvent> messageEvents, ILinks links, int?childSpanCount, Status status, SpanKind kind, ITimestamp endTimestamp) { this.Context = context ?? throw new ArgumentNullException(nameof(context)); this.ParentSpanId = parentSpanId; this.HasRemoteParent = hasRemoteParent; this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.StartTimestamp = startTimestamp ?? throw new ArgumentNullException(nameof(startTimestamp)); this.Attributes = attributes ?? Export.Attributes.Create(new Dictionary <string, IAttributeValue>(), 0); this.Annotations = annotations ?? TimedEvents <IAnnotation> .Create(new List <ITimedEvent <IAnnotation> >(), 0); this.MessageEvents = messageEvents ?? TimedEvents <IMessageEvent> .Create(new List <ITimedEvent <IMessageEvent> >(), 0); this.Links = links ?? LinkList.Create(new List <ILink>(), 0); this.ChildSpanCount = childSpanCount; this.Status = status; this.Kind = kind; this.EndTimestamp = endTimestamp; }
/// <summary> /// Filter a start element event. /// </summary> /// <param name="uri">The element's Namespace URI, or the empty string.</param> /// <param name="localName">The element's local name, or the empty string.</param> /// <param name="qName">The element's qualified (prefixed) name, or the empty string.</param> /// <param name="atts">The element's attributes.</param> /// <exception cref="SAXException">The client may throw /// an exception during processing.</exception> public virtual void StartElement(string uri, string localName, string qName, IAttributes atts) { if (contentHandler != null) { contentHandler.StartElement(uri, localName, qName, atts); } }
private void OutputTextAndTag(string qName, IAttributes attributes, bool close) { // If we're not already in an element to be transformed, first // echo the previous text... outWriter.Print(XMLUtils.EscapeXML(textToBeTransformed.ToString())); textToBeTransformed = new StringBuilder(); // ... then echo the new tag to outStream outWriter.Print('<'); if (close) { outWriter.Print('/'); } outWriter.Print(qName); if (attributes != null) { for (int i = 0; i < attributes.GetLength(); i++) { outWriter.Print(' '); outWriter.Print(attributes.GetQName(i)); outWriter.Print("=\""); outWriter.Print(XMLUtils.EscapeXML(attributes.GetValue(i))); outWriter.Print('"'); } } outWriter.Print(">\n"); }
private static Span.Types.Attributes FromIAttributes(IAttributes source) { var attributes = new Span.Types.Attributes { DroppedAttributesCount = source.DroppedAttributesCount, }; attributes.AttributeMap.Add(source.AttributeMap.ToDictionary( kvp => kvp.Key, kvp => kvp.Value.Match( s => new OpenTelemetry.Proto.Trace.V1.AttributeValue { StringValue = new TruncatableString() { Value = s } }, b => new OpenTelemetry.Proto.Trace.V1.AttributeValue { BoolValue = b }, l => new OpenTelemetry.Proto.Trace.V1.AttributeValue { IntValue = l }, d => new OpenTelemetry.Proto.Trace.V1.AttributeValue { DoubleValue = d }, o => new OpenTelemetry.Proto.Trace.V1.AttributeValue { StringValue = new TruncatableString() { Value = o?.ToString() } }))); return(attributes); }
private void SetAttributesInternal(IAttributes atts) { int length = atts.Length; base.SetAttributes(atts); _declared = new bool[length]; _specified = new bool[length]; var a2 = atts as IAttributes2; if (a2 != null) { for (int i = 0; i < length; i++) { _declared[i] = a2.IsDeclared(i); _specified[i] = a2.IsSpecified(i); } } else { for (int i = 0; i < length; i++) { _declared[i] = !"CDATA".Equals(atts.GetType(i)); _specified[i] = true; } } }
public void GenerateChordTemplateData(IAttributes attribute, dynamic song) { var ind = 0; if (song.ChordTemplates == null) { return; } foreach (var y in song.ChordTemplates) { if (!String.IsNullOrEmpty(y.ChordName)) //Only add chords with name, checked in RS1 and RS14 packages { attribute.ChordTemplates.Add(new ChordTemplate { ChordId = ind++, ChordName = y.ChordName, Fingers = new List <int> { y.Finger0, y.Finger1, y.Finger2, y.Finger3, y.Finger4, y.Finger5 }, Frets = new List <int> { y.Fret0, y.Fret1, y.Fret2, y.Fret3, y.Fret4, y.Fret5 } }); } } }
public override void StartElement(string @namespace, string simple, string qualified, IAttributes attributes) { int elemType = GetElementType(qualified); switch (elemType) { case PAGE: title = null; body = null; time = null; id = null; break; // intentional fall-through. case BODY: case DATE: case TITLE: case ID: contents.Length = 0; break; default: // this element should be discarded. break; } }
/// <summary> /// Creates a new /// <see cref="JsoupElementNode"/> /// instance. /// </summary> /// <param name="element">the element</param> public JsoupElementNode(iText.StyledXmlParser.Jsoup.Nodes.Element element) : base(element) { this.element = element; this.attributes = new JsoupAttributes(element.Attributes()); this.lang = GetAttribute(CommonAttributeConstants.LANG); }
/// <summary>Copy a whole set of attributes.</summary> public virtual void SetAttributes(IAttributes atts) { if (atts == null) { throw new ArgumentNullException("atts"); } Clear(); int attLen = atts.Length; if (Capacity < attLen) { Capacity = attLen; } for (int attIndx = 0; attIndx < attLen; attIndx++) { InternalSetAttribute( ref this.atts[attIndx], atts.GetUri(attIndx), atts.GetLocalName(attIndx), atts.GetQName(attIndx), atts.GetType(attIndx), atts.GetValue(attIndx), atts.IsSpecified(attIndx)); } }
/// <summary> /// Default ctor /// </summary> internal PropertyInfo(string name, MethodInfo getter, MethodInfo setter, IAttributes attributes) { this.name = name; this.getter = getter; this.setter = setter; this.attributes = attributes; }
/// <summary> /// Returns a new immutable <see cref="SpanData"/>. /// </summary> /// <param name="context">The <see cref="SpanContext"/> of the <see cref="ISpan"/>.</param> /// <param name="parentSpanId">The parent <see cref="SpanId"/> of the <see cref="ISpan"/>. <c>null</c> if the <see cref="ISpan"/> is a root.</param> /// <param name="resource">The <see cref="Resource"/> this span was executed on.</param> /// <param name="name">The name of the <see cref="ISpan"/>.</param> /// <param name="startTimestamp">The start <see cref="Timestamp"/> of the <see cref="ISpan"/>.</param> /// <param name="attributes">The <see cref="IAttributes"/> associated with the <see cref="ISpan"/>.</param> /// <param name="events">The <see cref="Events"/> associated with the <see cref="ISpan"/>.</param> /// <param name="links">The <see cref="ILinks"/> associated with the <see cref="ISpan"/>.</param> /// <param name="childSpanCount">The <see cref="ChildSpanCount"/> associated with the <see cref="ISpan"/>.</param> /// <param name="status">The <see cref="Status"/> of the <see cref="ISpan"/>.</param> /// <param name="kind">The <see cref="SpanKind"/> of the <see cref="ISpan"/>.</param> /// <param name="endTimestamp">The end <see cref="Timestamp"/> of the <see cref="ISpan"/>.</param> /// <returns>A new immutable <see cref="SpanData"/>.</returns> public static SpanData Create( SpanContext context, SpanId parentSpanId, Resource resource, string name, Timestamp startTimestamp, IAttributes attributes, ITimedEvents <IEvent> events, ILinks links, int?childSpanCount, Status status, SpanKind kind, Timestamp endTimestamp) { if (events == null) { events = TimedEvents <IEvent> .Create(new List <ITimedEvent <IEvent> >(), 0); } return(new SpanData( context, parentSpanId, resource, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp)); }
internal SpanData( SpanContext context, SpanId parentSpanId, Resource resource, string name, Timestamp startTimestamp, IAttributes attributes, ITimedEvents <IEvent> events, ILinks links, int?childSpanCount, Status status, SpanKind kind, Timestamp endTimestamp) { this.Context = context ?? throw new ArgumentNullException(nameof(context)); this.ParentSpanId = parentSpanId; this.Resource = resource ?? throw new ArgumentNullException(nameof(resource)); this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.StartTimestamp = startTimestamp ?? throw new ArgumentNullException(nameof(startTimestamp)); this.Attributes = attributes ?? Export.Attributes.Create(new Dictionary <string, IAttributeValue>(), 0); this.Events = events ?? TimedEvents <IEvent> .Create(Enumerable.Empty <ITimedEvent <IEvent> >(), 0); this.Links = links ?? LinkList.Create(Enumerable.Empty <ILink>(), 0); this.ChildSpanCount = childSpanCount; this.Status = status; this.Kind = kind; this.EndTimestamp = endTimestamp; }
private static string ParseDateTime(IAttributes attributes, NameValueCollection pageScripts, TableStyleInfo styleInfo, StringBuilder extraBuilder) { if (styleInfo.Additional.IsValidate) { extraBuilder.Append( $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>"); } var selectedValue = attributes.GetString(styleInfo.AttributeName); var dateTime = selectedValue == Current ? DateTime.Now : TranslateUtils.ToDateTime(selectedValue); if (pageScripts != null) { pageScripts["calendar"] = $@"<script type=""text/javascript"" src=""{SiteServerAssets.GetUrl(SiteServerAssets.DatePicker.Js)}""></script>"; } var value = string.Empty; if (dateTime > DateUtils.SqlMinValue) { value = DateUtils.GetDateAndTimeString(dateTime, EDateFormatType.Day, ETimeFormatType.LongTime); } return($@"<input id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" type=""text"" class=""form-control"" value=""{value}"" onfocus=""{SiteServerAssets.DatePicker.OnFocus}"" style=""width: 180px"" />"); }
private static string ParseSelectMultiple(IAttributes attributes, TableStyleInfo styleInfo, StringBuilder extraBuilder) { if (styleInfo.Additional.IsValidate) { extraBuilder.Append( $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>"); } var builder = new StringBuilder(); var styleItems = styleInfo.StyleItems ?? new List <TableStyleItemInfo>(); var selectedValues = TranslateUtils.StringCollectionToStringList(attributes.GetString(styleInfo.AttributeName)); var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage); builder.Append($@"<select id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" class=""form-control"" isListItem=""true"" multiple {validateAttributes}>"); foreach (var styleItem in styleItems) { var isSelected = selectedValues.Contains(styleItem.ItemValue); builder.Append($@"<option value=""{styleItem.ItemValue}"" {(isSelected ? "selected" : string.Empty)}>{styleItem.ItemTitle}</option>"); } builder.Append("</select>"); return(builder.ToString()); }
public static string ParseTextEditor(IAttributes attributes, string attributeName, SiteInfo siteInfo, NameValueCollection pageScripts, StringBuilder extraBuilder) { var value = attributes.GetString(attributeName); value = ContentUtility.TextEditorContentDecode(siteInfo, value, true); value = UEditorUtils.TranslateToHtml(value); value = StringUtils.HtmlEncode(value); var controllerUrl = ApiRouteUEditor.GetUrl(ApiManager.InnerApiUrl, siteInfo.Id); var editorUrl = SiteServerAssets.GetUrl("ueditor"); if (pageScripts["uEditor"] == null) { extraBuilder.Append( $@"<script type=""text/javascript"">window.UEDITOR_HOME_URL = ""{editorUrl}/"";window.UEDITOR_CONTROLLER_URL = ""{controllerUrl}"";</script><script type=""text/javascript"" src=""{editorUrl}/editor_config.js""></script><script type=""text/javascript"" src=""{editorUrl}/ueditor_all_min.js""></script>"); } pageScripts["uEditor"] = string.Empty; extraBuilder.Append($@" <script type=""text/javascript""> $(function(){{ UE.getEditor('{attributeName}', {UEditorUtils.ConfigValues}); $('#{attributeName}').show(); }}); </script>"); return($@"<textarea id=""{attributeName}"" name=""{attributeName}"" style=""display:none"">{value}</textarea>"); }
//============================================================ // <T>构造属性集合。</T> //============================================================ public void Append(IAttributes attributes) { foreach (IStringPair pair in attributes) { Set(pair.Name, pair.Value); } }
//////////////////////////////////////////////////////////////////// // Manipulators //////////////////////////////////////////////////////////////////// /// <summary> /// Copy an entire Attributes object. The "specified" flags are /// assigned as true, and "declared" flags as false (except when /// an attribute's type is not CDATA), /// unless the object is an Attributes2 object. /// In that case those flag values are all copied. /// </summary> /// <seealso cref="Attributes.SetAttributes(IAttributes)"/> public override void SetAttributes(IAttributes atts) { int length = atts.Length; base.SetAttributes(atts); declared = new bool[length]; specified = new bool[length]; if (atts is Attributes2 a2) { for (int i = 0; i < length; i++) { declared[i] = a2.IsDeclared(i); specified[i] = a2.IsSpecified(i); } } else { for (int i = 0; i < length; i++) { declared[i] = !"CDATA".Equals(atts.GetType(i), StringComparison.Ordinal); specified[i] = true; } } }
public ScriptTag(string tagName, IAttributes attributes, string innerText, DocInfo docInfo) { Attributes = attributes; this.InnerText = innerText; TagName = tagName; DocInfo = docInfo; }
public static double GetAttributesDimension(IAttributes sticker, bool isWidth, double maxStickerDimension) { TLDocumentAttributeImageSize imageSizeAttribute = null; for (var i = 0; i < sticker.Attributes.Count; i++) { imageSizeAttribute = sticker.Attributes[i] as TLDocumentAttributeImageSize; if (imageSizeAttribute != null) { break; } } if (imageSizeAttribute != null) { var width = imageSizeAttribute.W.Value; var height = imageSizeAttribute.H.Value; var maxDimension = Math.Max(width, height); if (maxDimension > maxStickerDimension) { var scaleFactor = maxStickerDimension / maxDimension; return(isWidth ? scaleFactor * width : scaleFactor *height); } return(isWidth ? width : height); } return(isWidth ? double.NaN : maxStickerDimension); }
private static bool ValidateEmployee(EmpBEntity employee) { PropertyInfo[] properties = employee.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in properties) { object[] customAtt = property.GetCustomAttributes(typeof(IAttributes), true); foreach (object att in customAtt) { IAttributes valAtt = (IAttributes)att; if (valAtt == null) { continue; } if (valAtt.IsValid(property.GetValue(employee, null))) { continue; } ErrorMessage error = new ErrorMessage(property.Name, valAtt.message); employee.ErrorList.Add(error); } } return(employee.ErrorList.Count == 0); }
private static string ToConciseString(IAttributes attributes) { if (!attributes.Any()) { return "{}"; } var sb = new StringBuilder(); sb.Append("{"); bool first = true; foreach (var entry in attributes) { if (first) { first = false; } else { sb.Append(", "); } sb.Append(entry.Key); sb.Append("="); sb.Append(LiteralString(entry.Value)); } sb.Append(" }"); return sb.ToString(); }
/// <summary> /// Handles IMG tags /// </summary> /// <returns>The image.</returns> /// <param name="text">Text.</param> /// <param name="attributes">Attributes.</param> /// <param name="img">Image.</param> static void startImg(SpannableStringBuilder text, IAttributes attributes, Html.IImageGetter img) { var src = attributes.GetValue("src"); Drawable d = null; if (img != null) { d = img.GetDrawable(src); } if (d == null) { throw new NotImplementedException("Missing Inline image implementation"); // d = Resources.System.GetDrawable (); // getDrawable(com.android.internal.R.drawable.unknown_image); // d.SetBounds (0, 0, d.IntrinsicWidth, d.IntrinsicHeight); } int len = text.Length(); text.Append("\uFFFC"); text.SetSpan(new ImageSpan(d, src), len, text.Length(), SpanTypes.ExclusiveExclusive); }
public static async Task<bool> addToUserModel(IAttributes attributes) { SMRequest createAddRequest = new SMRequest(); createAddRequest.attributes = attributes; SMResponse m = await AsyncClient.post(APIRoutes.addAttributesToUserModel(), createAddRequest); if (m == null) return false; if (m.model == null) { return false; } else { return true; } }
public override void StartElement (string uri, string localName, string qName, IAttributes attributes) { if (buffer != null) { buffer.Length = 0; } }
public override void StartElement (string uri, string localName, string qName, IAttributes attributes) { events.Add(new StartElementClass(uri, localName, qName, attributes) ); }
public override void Applies(Attributes attributes, IAttributes baseAttributes) { attributes.MaxHealth += Amounts.MaxHealth; attributes.MaxMana += Amounts.MaxMana; attributes.Attack += Amounts.Attack; attributes.Defense += Amounts.Defense; attributes.Critical += Amounts.Critical; }
/// <summary> /// Starts an A tag /// </summary> /// <returns>void</returns> /// <param name="text">SpannableStringBuilder</param> /// <param name="attributes">IAttributes</param> static void startA(SpannableStringBuilder text, IAttributes attributes) { String href = attributes.GetValue("href"); int len = text.Length(); text.SetSpan(new Href(href), len, len, SpanTypes.MarkMark); }
public override void StartElement(string uri, string localName, string name, IAttributes attributes) { _builder = new StringBuilder(); if (localName == "path") { List.Add(attributes.GetValue("d")); } }
public void StartElement(String namespaceURI, String localName, String qName, IAttributes atts) { Console.WriteLine(" EVENT: startElement " + makeNSName(namespaceURI, localName, qName)); int attLen = atts.Length; for (int i = 0; i < attLen; i++) { char[] ch = atts.GetValue(i).ToCharArray(); Console.WriteLine(" Attribute " + makeNSName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i)) + '=' + escapeData(ch, 0, ch.Length)); } }
private static object[] GetCustomAttributes(IAttributes attributes) { if (attributes == null) return new object[0]; var list = new ArrayList<object>(); foreach (var attr in attributes.Attributes()) { list.Add(GetAttribute(attr)); } return list.ToArray(); }
/// <summary> /// <para>Receive notification of the beginning of an element.</para><para>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.</para><para>This event allows up to three name components for each element:</para><para><ol><li><para>the Namespace URI; </para></li><li><para>the local name; and </para></li><li><para>the qualified (prefixed) name. </para></li></ol></para><para>Any or all of these may be provided, depending on the values of the <b></b> and the <b></b> properties:</para><para><ul><li><para>the Namespace URI and local name are required when the namespaces property is <b>true</b> (the default), and are optional when the namespaces property is <b>false</b> (if one is specified, both must be); </para></li><li><para>the qualified name is required when the namespace-prefixes property is <b>true</b>, and is optional when the namespace-prefixes property is <b>false</b> (the default). </para></li></ul></para><para>Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the <code></code> property is true (it is false by default, and support for a true value is optional).</para><para>Like characters(), attribute values may have characters that need more than one <code>char</code> value. </para><para><para>endElement </para><simplesectsep></simplesectsep><para>org.xml.sax.Attributes </para><simplesectsep></simplesectsep><para>org.xml.sax.helpers.AttributesImpl </para></para> /// </summary> public void StartElement(string uri, string localName, string qName, IAttributes atts) { var element = new XElement(XName.Get(localName, uri)); var parent = elementStack.Empty() ? null : elementStack.Peek(); if (parent == null) { document.Add(element); } else { parent.Add(element); } var attrCount = atts.GetLength(); for (var i = 0; i < attrCount; i++) { var name = XName.Get(atts.GetLocalName(i), atts.GetURI(i)); var attr = new XAttribute(name, atts.GetValue(i)); element.Add(attr); } elementStack.Push(element); }
public static IEnumerable GetAttributeNamesCopy(IAttributes attrs) { if (attrs is AttributesMap) { if (((AttributesMap)attrs)._map.Keys != null) { foreach (string item in ((AttributesMap)attrs)._map.Keys) { yield return item; } } yield break; } foreach (string name in attrs.GetAttributeNames()) { yield return name; } yield break; }
/// <summary> /// Write an empty element. /// This method writes an empty element tag rather than a start tag /// followed by an end tag. Both a <see cref="StartElement" /> /// and an <see cref="EndElement(string,string,string)" /> event will /// be passed on down the filter chain. /// </summary> /// <param name="uri"> /// The element's Namespace URI, or the empty string /// if the element has no Namespace or if Namespace /// processing is not being performed. /// </param> /// <param name="localName"> /// The element's local name (without prefix). This /// parameter must be provided. /// </param> /// <param name="qName"> /// The element's qualified name (with prefix), or /// the empty string if none is available. This parameter /// is strictly advisory: the writer may or may not use /// the prefix attached. /// </param> /// <param name="atts"> /// The element's attribute list. /// </param> /// <exception cref="SAXException"> /// If there is an error /// writing the empty tag, or if a handler further down /// the filter chain raises an exception. /// </exception> /// <seealso cref="StartElement" /> /// <seealso cref="EndElement(string,string,string) " /> public virtual void EmptyElement(string uri, string localName, string qName, IAttributes atts) { _nsSupport.PushContext(); Write('<'); WriteName(uri, localName, qName, true); WriteAttributes(atts); if (_elementLevel == 1) { ForceNSDecls(); } WriteNSDecls(); Write("/>"); base.StartElement(uri, localName, qName, atts); base.EndElement(uri, localName, qName); }
/// <summary> /// Write out an attribute list, escaping values. /// The names will have prefixes added to them. /// </summary> /// <param name="atts"> /// The attribute list to write. /// </param> /// <exception cref="SAXException"> /// If there is an error writing /// the attribute list, this method will throw an /// IOException wrapped in a SAXException. /// </exception> private void WriteAttributes(IAttributes atts) { int len = atts.Length; for (int i = 0; i < len; i++) { char[] ch = atts.GetValue(i).ToCharArray(); Write(' '); WriteName(atts.GetUri(i), atts.GetLocalName(i), atts.GetQName(i), false); if (_htmlMode && BoolAttribute(atts.GetLocalName(i), atts.GetQName(i), atts.GetValue(i))) { break; } Write("=\""); WriteEsc(ch, 0, ch.Length, true); Write('"'); } }
/// <summary> /// Write a start tag. /// Pass the event on down the filter chain for further processing. /// </summary> /// <param name="uri"> /// The Namespace URI, or the empty string if none /// is available. /// </param> /// <param name="localName"> /// The element's local (unprefixed) name (required). /// </param> /// <param name="qName"> /// The element's qualified (prefixed) name, or the /// empty string is none is available. This method will /// use the qName as a template for generating a prefix /// if necessary, but it is not guaranteed to use the /// same qName. /// </param> /// <param name="atts"> /// The element's attribute list (must not be null). /// </param> /// <exception cref="SAXException"> /// If there is an error /// writing the start tag, or if a handler further down /// the filter chain raises an exception. /// </exception> /// <seealso cref="IContentHandler.StartElement" /> public override void StartElement(string uri, string localName, string qName, IAttributes atts) { _elementLevel++; _nsSupport.PushContext(); if (_forceDtd && !_hasOutputDtd) { StartDTD(localName ?? qName, "", ""); } Write('<'); WriteName(uri, localName, qName, true); WriteAttributes(atts); if (_elementLevel == 1) { ForceNSDecls(); } WriteNSDecls(); Write('>'); // System.out.println("%%%% startElement [" + qName + "] htmlMode = " + htmlMode); if (_htmlMode && (qName.Equals("script") || qName.Equals("style"))) { _cdataElement = true; // System.out.println("%%%% CDATA element"); } base.StartElement(uri, localName, qName, atts); }
public ElementStart(string type, IAttributes attributes) { _type = type; _attributes = attributes; }
public ReplaceAttributes(IAttributes oldAttributes, IAttributes newAttributes) { _oldAttributes = oldAttributes; _newAttributes = newAttributes; }
// throws SAXException public void startElement(string uri, string localName, string qName, IAttributes atts) { base.StartElement (uri, localName, qName, atts); if (localName.CompareTo ("log") == 0) inLog = true; if (logs == null) logs = new List<Log> (); else if (localName.CompareTo ("id") == 0 && inLog) inId = true; else if (localName.CompareTo ("path") == 0 && inLog) inPath = true; else if (localName.CompareTo ("description") == 0 && inLog) inDescription = true; else if (localName.CompareTo ("content") == 0 && inLog) inContent = true; else if (localName.CompareTo ("value") == 0 && inContent) inValue = true; else if (localName.CompareTo ("position") == 0 && inContent) inPosition = true; }
private static bool IsDefined(Type attributeType, IAttributes attributes) { if (attributes == null) return false; foreach (var attr in attributes.Attributes()) { if (attributeType.JavaIsAssignableFrom(attr.AttributeType())) { return true; } } return false; }
//TODO: investigate on values 0.9 and lower, spotted in DLC public void GenerateDynamicVisualDensity(IAttributes attribute, dynamic song, Arrangement arrangement, GameVersion version) { if (arrangement.ArrangementType == ArrangementType.Vocal) { if (version == GameVersion.RS2014) attribute.DynamicVisualDensity = Enumerable.Repeat(2.0f, 20).ToList(); else attribute.DynamicVisualDensity = new List<float> { 4.5f, 4.3000001907348633f, 4.0999999046325684f, 3.9000000953674316f, 3.7000000476837158f, 3.5f, 3.2999999523162842f, 3.0999999046325684f, 2.9000000953674316f, 2.7000000476837158f, 2.5f, 2.2999999523162842f, 2.0999999046325684f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f }; } else { const float floorLimit = 5f; attribute.DynamicVisualDensity = new List<float>(20); float endSpeed = Math.Min(45f, Math.Max(floorLimit, arrangement.ScrollSpeed)) / 10f; if (song.Levels.Length == 1) { attribute.DynamicVisualDensity = Enumerable.Repeat(endSpeed, 20).ToList(); } else { double beginSpeed = 4.5d; double maxLevel = Math.Min(song.Levels.Length, 20d) - 1; double factor = maxLevel > 0 ? Math.Pow(endSpeed / beginSpeed, 1d / maxLevel) : 1d; for (int i = 0; i < 20; i++) { if (i >= maxLevel) { attribute.DynamicVisualDensity.Add(endSpeed); } else { attribute.DynamicVisualDensity.Add((float)(beginSpeed * Math.Pow(factor, i))); } } } } }
public void GeneratePhraseData(IAttributes attribute, dynamic song) { if (song.Phrases == null) return; var ind = 0; foreach (var y in song.Phrases) { attribute.Phrases.Add(new Phrase { IterationCount = PhraseIterationCount(song, ind), MaxDifficulty = y.MaxDifficulty, Name = y.Name }); ind++; } }
public void ReplaceAttributes(IAttributes oldAttributes, IAttributes newAttributes) { throw new System.NotImplementedException(); }
public void GenerateChordTemplateData(IAttributes attribute, dynamic song) { var ind = 0; if (song.ChordTemplates == null) return; foreach (var y in song.ChordTemplates) if (!String.IsNullOrEmpty(y.ChordName)) //Only add chords with name, checked in RS1 and RS14 packages attribute.ChordTemplates.Add(new ChordTemplate { ChordId = ind++, ChordName = y.ChordName, Fingers = new List<int> { y.Finger0, y.Finger1, y.Finger2, y.Finger3, y.Finger4, y.Finger5 }, Frets = new List<int> { y.Fret0, y.Fret1, y.Fret2, y.Fret3, y.Fret4, y.Fret5 } }); }
public void DeleteElementStart(string type, IAttributes attributes) { throw new System.NotImplementedException(); }
public void ElementStart(string type, IAttributes attributes) { _accu[0] = _accu[0].MergeWith(_automaton.CheckElementStart(type, attributes, _collector)); AbortIfIllFormed(); _automaton.DoElementStart(type, attributes); }
public void GenerateDynamicVisualDensity(IAttributes attribute, dynamic song, Arrangement arrangement) { if (arrangement.ArrangementType == ArrangementType.Vocal) { attribute.DynamicVisualDensity = new List<float>{ 4.5f, 4.3000001907348633f, 4.0999999046325684f, 3.9000000953674316f, 3.7000000476837158f, 3.5f, 3.2999999523162842f, 3.0999999046325684f, 2.9000000953674316f, 2.7000000476837158f, 2.5f, 2.2999999523162842f, 2.0999999046325684f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f}; } else { attribute.DynamicVisualDensity = new List<float>(20); float endSpeed = Math.Min(45f, Math.Max(10f, arrangement.ScrollSpeed)) / 10f; if (song.Levels.Length == 1) { for (int i = 0; i < 20; i++) { attribute.DynamicVisualDensity.Add(endSpeed); } } else { double beginSpeed = 4.5d; double maxLevel = Math.Min(song.Levels.Length, 16d) - 1; double factor = maxLevel == 0 ? 1d : Math.Pow(endSpeed / beginSpeed, 1d / maxLevel); for (int i = 0; i < 20; i++) { if (i >= maxLevel) { attribute.DynamicVisualDensity.Add(endSpeed); } else { attribute.DynamicVisualDensity.Add((float)(beginSpeed * Math.Pow(factor, i))); } } } } }
/// <summary> /// Write an element with character data content. /// <para> /// This is a convenience method to write a complete element /// with character data content, including the start tag /// and end tag. /// </para> /// <para> /// This method invokes /// <see cref="StartElement(string, string, string, IAttributes)" />, /// followed by /// <see cref="Characters(string)" />, followed by /// <see cref="EndElement(string, string, string)" />. /// </para> /// </summary> /// <param name="uri"> /// The element's Namespace URI. /// </param> /// <param name="localName"> /// The element's local name. /// </param> /// <param name="qName"> /// The element's default qualified name. /// </param> /// <param name="atts"> /// The element's attributes. /// </param> /// <param name="content"> /// The character data content. /// </param> /// <exception cref="SAXException"> /// If there is an error /// writing the empty tag, or if a handler further down /// the filter chain raises an exception. /// </exception> /// <seealso cref="StartElement(string, string, string, IAttributes)" /> /// <seealso cref="Characters(string)" /> /// <seealso cref="EndElement(string, string, string)" /> public virtual void DataElement(string uri, string localName, string qName, IAttributes atts, string content) { StartElement(uri, localName, qName, atts); Characters(content); EndElement(uri, localName, qName); }
public void GeneratePhraseIterationsData(IAttributes attribute, dynamic song, GameVersion gameVersion) { if (song.PhraseIterations == null) return; for (int i = 0; i < song.PhraseIterations.Length; i++) { var phraseIteration = song.PhraseIterations[i]; var phrase = song.Phrases[phraseIteration.PhraseId]; var endTime = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time; var phraseIt = new PhraseIteration(); phraseIt.StartTime = phraseIteration.Time; phraseIt.EndTime = endTime; phraseIt.PhraseIndex = phraseIteration.PhraseId; phraseIt.Name = phrase.Name; phraseIt.MaxDifficulty = phrase.MaxDifficulty; if (gameVersion == GameVersion.RS2012) phraseIt.MaxScorePerDifficulty = new List<float>(); attribute.PhraseIterations.Add(phraseIt); } var noteCnt = 0; foreach (var y in attribute.PhraseIterations) { if (song.Levels[y.MaxDifficulty].Notes != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[y.MaxDifficulty].Chords != null) { noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords); } } attribute.Score_MaxNotes = noteCnt; attribute.Score_PNV = ((float)attribute.TargetScore) / noteCnt; foreach (var y in attribute.PhraseIterations) { var phrase = song.Phrases[y.PhraseIndex]; for (int ndx = 0; ndx <= phrase.MaxDifficulty; ndx++) { var multiplier = ((float)(ndx + 1)) / (phrase.MaxDifficulty + 1); var pnv = attribute.Score_PNV; var noteCount = 0; if (song.Levels[ndx].Chords != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[ndx].Chords != null) noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[ndx].Chords); if (gameVersion == GameVersion.RS2012) { var score = pnv * noteCount * multiplier; y.MaxScorePerDifficulty.Add(score); } } } }
public void ReplaceAttributes(IAttributes oldAttributes, IAttributes newAttributes) { _sb.Append("r@ " + ToConciseString(oldAttributes) + " " + ToConciseString(newAttributes) + "; "); }
public void GenerateSectionData(IAttributes attribute, dynamic song) { if (song.Sections == null) return; for (int i = 0; i < song.Sections.Length; i++) { var section = song.Sections[i]; var sect = new Section { Name = section.Name, Number = section.Number, StartTime = section.StartTime, EndTime = (i >= song.Sections.Length - 1) ? song.SongLength : song.Sections[i + 1].StartTime, UIName = null }; string[] sep = sect.Name.Split(new string[1] { " " }, StringSplitOptions.RemoveEmptyEntries); // process "<section><number>" used by official XML var numAlpha = new Regex("(?<Alpha>[a-zA-Z]*)(?<Numeric>[0-9]*)"); var match = numAlpha.Match(sep[0]); if (match.Groups["Numeric"].Value != "") sep = new string[] { match.Groups["Alpha"].Value, match.Groups["Numeric"].Value }; if (sep.Length == 1) { string uiName; if (SectionUINames.TryGetValue(sep[0], out uiName)) sect.UIName = uiName; else throw new InvalidDataException(String.Format("Unknown section name: {0}", sep[0])); } else { string uiName; if (SectionUINames.TryGetValue(sep[0], out uiName)) { try { if (Convert.ToInt32(sep[1]) != 0 || Convert.ToInt32(sep[1]) != 1) uiName += String.Format("|{0}", sep[1]); } catch { } sect.UIName = uiName; } else throw new InvalidDataException(String.Format("Unknown section name: {0}", sep[0])); } var phraseIterStart = -1; var phraseIterEnd = 0; var isSolo = section.Name == "solo"; if (song.PhraseIterations != null) { for (int o = 0; o < song.PhraseIterations.Length; o++) { var phraseIter = song.PhraseIterations[o]; if (phraseIterStart == -1 && phraseIter.Time >= sect.StartTime) phraseIterStart = o; if (phraseIter.Time >= sect.EndTime) break; phraseIterEnd = o; if (song.Phrases[phraseIter.PhraseId].Solo > 0) isSolo = true; } } sect.StartPhraseIterationIndex = phraseIterStart; sect.EndPhraseIterationIndex = phraseIterEnd; sect.IsSolo = isSolo; attribute.Sections.Add(sect); } }
// throws SAXException public void startElement(string uri, string localName, string qName, IAttributes atts) { base.StartElement (uri, localName, qName, atts); if (localName.CompareTo ("metric") == 0) { inMetric = true; if (metrics == null) metrics = new List<Metric> (); values = new List<Value> (); } else if (localName.CompareTo ("id") == 0 && inMetric) inId = true; else if (localName.CompareTo ("identifier") == 0 && inMetric) inIdentifier = true; else if (localName.CompareTo ("host") == 0 && inMetric) inHost = true; else if (localName.CompareTo ("plugin") == 0 && inMetric) inPlugin = true; else if (localName.CompareTo ("plugin_instance") == 0 && inMetric) inPluginInstance = true; else if (localName.CompareTo ("type") == 0 && inMetric) inType = true; else if (localName.CompareTo ("type_instance") == 0 && inMetric) inTypeInstance = true; else if (localName.CompareTo ("limits") == 0 && inMetric) { inLimits = true; limits = new List<Limit> (); } else if (localName.CompareTo ("limit") == 0 && inLimits) inLimit = true; else if (localName.CompareTo ("metric_column") == 0 && inLimit) inMetricColumn = true; else if (localName.CompareTo ("max") == 0 && inLimit) inMax = true; else if (localName.CompareTo ("min") == 0 && inLimit) inMin = true; else if (localName.CompareTo ("value") == 0 && inMetric) { if (!inValueRoot) { inValueRoot = true; int result; int.TryParse (atts.GetValue ("interval"), out result); interval = result; column = atts.GetValue ("column"); int.TryParse (atts.GetValue ("start"), out result); start = result; floatValues = new List<float> (); } else // inner <value> inValue = true; } }
private static object[] GetCustomAttributes(Type attributeType, IAttributes attributes) { if (attributes == null) return new object[0]; var list = new ArrayList<object>(); foreach (var attr in attributes.Attributes()) { if (attributeType.JavaIsAssignableFrom(attr.AttributeType())) { list.Add(GetAttribute(attr)); } } return list.ToArray(); }