GetNameForMarkupExtension() private method

private GetNameForMarkupExtension ( ) : string
return string
		/// <summary>
		/// Generates XAML markup extension code for the object.
		/// </summary>
		public static string Print(XamlObject obj)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("{");
			sb.Append(obj.GetNameForMarkupExtension());

			bool first = true;
			foreach (var property in obj.Properties) {
				if (!property.IsSet) continue;

				if (first)
					sb.Append(" ");
				else
					sb.Append(", ");
				first = false;

				sb.Append(property.GetNameForMarkupExtension());
				sb.Append("=");

				var value = property.PropertyValue;
				if (value is XamlTextValue) {
					sb.Append((value as XamlTextValue).Text);
				} else if (value is XamlObject) {
					sb.Append(Print(value as XamlObject));
				}
			}
			sb.Append("}");
			return sb.ToString();
		}
Example #2
0
        /// <summary>
        /// Generates XAML markup extension code for the object.
        /// </summary>
        public static string Print(XamlObject obj)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append(obj.GetNameForMarkupExtension());

            bool first = true;

            foreach (var property in obj.Properties)
            {
                if (!property.IsSet)
                {
                    continue;
                }

                if (first)
                {
                    sb.Append(" ");
                }
                else
                {
                    sb.Append(", ");
                }
                first = false;

                sb.Append(property.GetNameForMarkupExtension());
                sb.Append("=");

                var value     = property.PropertyValue;
                var textValue = value as XamlTextValue;
                if (textValue != null)
                {
                    string text          = textValue.Text;
                    bool   containsSpace = text.Contains(' ');

                    if (containsSpace)
                    {
                        sb.Append('\'');
                    }

                    sb.Append(text.Replace("\\", "\\\\"));

                    if (containsSpace)
                    {
                        sb.Append('\'');
                    }
                }
                else if (value is XamlObject)
                {
                    sb.Append(Print(value as XamlObject));
                }
            }
            sb.Append("}");
            return(sb.ToString());
        }
		/// <summary>
		/// Generates XAML markup extension code for the object.
		/// </summary>
		public static string Print(XamlObject obj)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("{");
			sb.Append(obj.GetNameForMarkupExtension());

			bool first = true;
			var properties = obj.Properties.ToList();
			
			if (obj.ElementType == typeof(Binding)){
				var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="Path");
				if (p!=null && p.IsSet) {
					sb.Append(" ");
					AppendPropertyValue(sb, p.PropertyValue, false);
					properties.Remove(p);
					first = false;
				}
			}
			else if (obj.ElementType == typeof(Reference)){
				var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="Name");
				if (p!=null && p.IsSet) {
					sb.Append(" ");
					AppendPropertyValue(sb, p.PropertyValue, false);
					properties.Remove(p);
					first = false;
				}
			}
			else if (obj.ElementType == typeof(StaticResourceExtension)){
				var p=obj.Properties.FirstOrDefault(x=>x.PropertyName=="ResourceKey");
				if (p!=null && p.IsSet) {
					sb.Append(" ");
					AppendPropertyValue(sb, p.PropertyValue, false);
					properties.Remove(p);
					first = false;
				}
			}
			
			foreach (var property in properties) {
				if (!property.IsSet) continue;

				if (first)
					sb.Append(" ");
				else
					sb.Append(", ");
				first = false;

				sb.Append(property.GetNameForMarkupExtension());
				sb.Append("=");

				AppendPropertyValue(sb, property.PropertyValue, property.ReturnType == typeof(string));
			}
			sb.Append("}");
			return sb.ToString();
		}
Example #4
0
        /// <summary>
        /// Generates XAML markup extension code for the object.
        /// </summary>
        public static string Print(XamlObject obj)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append(obj.GetNameForMarkupExtension());

            bool first = true;

            foreach (var property in obj.Properties)
            {
                if (!property.IsSet)
                {
                    continue;
                }

                if (first)
                {
                    sb.Append(" ");
                }
                else
                {
                    sb.Append(", ");
                }
                first = false;

                sb.Append(property.GetNameForMarkupExtension());
                sb.Append("=");

                var value = property.PropertyValue;
                if (value is XamlTextValue)
                {
                    sb.Append((value as XamlTextValue).Text);
                }
                else if (value is XamlObject)
                {
                    sb.Append(Print(value as XamlObject));
                }
            }
            sb.Append("}");
            return(sb.ToString());
        }
		/// <summary>
		/// Generates XAML markup extension code for the object.
		/// </summary>
		public static string Print(XamlObject obj)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("{");
			sb.Append(obj.GetNameForMarkupExtension());

			bool first = true;
			foreach (var property in obj.Properties) {
				if (!property.IsSet) continue;

				if (first)
					sb.Append(" ");
				else
					sb.Append(", ");
				first = false;

				sb.Append(property.GetNameForMarkupExtension());
				sb.Append("=");

				var value = property.PropertyValue;
				var textValue = value as XamlTextValue;
				if (textValue != null) {
					string text = textValue.Text;
					bool containsSpace = text.Contains(' ');
					
					if(containsSpace) {
						sb.Append('\'');
					}
					
					sb.Append(text.Replace("\\", "\\\\"));
					
					if(containsSpace) {
						sb.Append('\'');
					}
				} else if (value is XamlObject) {
					sb.Append(Print(value as XamlObject));
				}
			}
			sb.Append("}");
			return sb.ToString();
		}
Example #6
0
        /// <summary>
        /// Generates XAML markup extension code for the object.
        /// </summary>
        public static string Print(XamlObject obj)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("{");
            sb.Append(obj.GetNameForMarkupExtension());

            bool first      = true;
            var  properties = obj.Properties.ToList();

            if (obj.ElementType == typeof(Binding))
            {
                var p = obj.Properties.FirstOrDefault(x => x.PropertyName == "Path");
                if (p != null && p.IsSet)
                {
                    sb.Append(" ");
                    AppendPropertyValue(sb, p.PropertyValue, false);
                    properties.Remove(p);
                    first = false;
                }
            }
            else if (obj.ElementType == typeof(Reference))
            {
                var p = obj.Properties.FirstOrDefault(x => x.PropertyName == "Name");
                if (p != null && p.IsSet)
                {
                    sb.Append(" ");
                    AppendPropertyValue(sb, p.PropertyValue, false);
                    properties.Remove(p);
                    first = false;
                }
            }
            else if (obj.ElementType == typeof(StaticResourceExtension))
            {
                var p = obj.Properties.FirstOrDefault(x => x.PropertyName == "ResourceKey");
                if (p != null && p.IsSet)
                {
                    sb.Append(" ");
                    AppendPropertyValue(sb, p.PropertyValue, false);
                    properties.Remove(p);
                    first = false;
                }
            }

            foreach (var property in properties)
            {
                if (!property.IsSet)
                {
                    continue;
                }

                if (first)
                {
                    sb.Append(" ");
                }
                else
                {
                    sb.Append(", ");
                }
                first = false;

                sb.Append(property.GetNameForMarkupExtension());
                sb.Append("=");

                AppendPropertyValue(sb, property.PropertyValue, property.ReturnType == typeof(string));
            }
            sb.Append("}");
            return(sb.ToString());
        }