ParseString() public method

public ParseString ( string str ) : object
str string
return object
Esempio n. 1
0
		public override object CreateObjectFromString (string xaml, bool createNamescope, bool validateTemplates)
		{
			XamlParser p = new XamlParser () {
				CreateNameScope = createNamescope,
				ValidateTemplates = validateTemplates,
				ResourceBase = resourceBase,
			};

			return p.ParseString (xaml);
		}
Esempio n. 2
0
		private static unsafe IntPtr ParseTemplate (Value *context_ptr, string resource_base, IntPtr surface, IntPtr binding_source, string xaml, ref MoonError error)
		{
			XamlContext context = Value.ToObject (typeof (XamlContext), context_ptr) as XamlContext;

			var parser = new XamlParser (context);

			var source = NativeDependencyObjectHelper.FromIntPtr (binding_source);
			if (source == null) {
				error = new MoonError (parser.ParseException ("Attempting to parse a template with an invalid binding source."));
				return IntPtr.Zero;
			}

			FrameworkElement fwe = source as FrameworkElement;
			if (fwe == null) {
				error = new MoonError (parser.ParseException ("Only FrameworkElements can be used as TemplateBinding sources."));
				return IntPtr.Zero;
			}

			context.IsExpandingTemplate = true;
			context.TemplateBindingSource = fwe;

			INativeEventObjectWrapper dob = null;
			try {
				dob = parser.ParseString (xaml) as INativeEventObjectWrapper;
			} catch (Exception e) {
				error = new MoonError (e);
				return IntPtr.Zero;
			}

			if (dob == null) {
				error = new MoonError (parser.ParseException ("Unable to parse template item."));
				return IntPtr.Zero;
			}

			return dob.NativeHandle;
		}
Esempio n. 3
0
		protected override void HydrateInternal (object value, string xaml, bool createNamescope, bool validateTemplates, bool import_default_xmlns)
		{
			XamlParser p = new XamlParser () {
				CreateNameScope = createNamescope,
				ValidateTemplates = validateTemplates,
				HydrateObject = value,
				ResourceBase = resourceBase,
			};

			object v = p.ParseString (xaml);
		}
Esempio n. 4
0
		public unsafe static Value HydrateFromString (string xaml, Value *obj, bool create_namescope, bool validate_templates)
		{
			XamlParser p = new XamlParser () {
				CreateNameScope = create_namescope,
				ValidateTemplates = validate_templates,
				HydrateObject = Value.ToObject (null, obj),
			};

			object v = p.ParseString (xaml);

			return ObjectToValue (v);
		}
Esempio n. 5
0
		public static Value CreateFromString (string xaml, bool create_namescope, bool validate_templates, IntPtr owner)
		{
			XamlParser p = new XamlParser () {
				CreateNameScope = create_namescope,
				ValidateTemplates = validate_templates,
				Owner = NativeDependencyObjectHelper.FromIntPtr (owner)
			};

			object v = p.ParseString (xaml);

			return ObjectToValue (v);
		}
Esempio n. 6
0
		private static unsafe IntPtr ParseTemplate (Value *context_ptr, IntPtr resource_base, IntPtr surface, IntPtr binding_source, string xaml, ref MoonError error)
		{
			XamlContext context = Value.ToObject (typeof (XamlContext), context_ptr) as XamlContext;

			var parser = new XamlParser (context) {
				ResourceBase = UriHelper.FromNativeUri (resource_base),
			};

			FrameworkElement fwe = null;
			var source = NativeDependencyObjectHelper.FromIntPtr (binding_source);

			if (source != null) {
				fwe = source as FrameworkElement;
				if (fwe == null) {
					error = new MoonError (parser.ParseException ("Only FrameworkElements can be used as TemplateBinding sources."));
					return IntPtr.Zero;
				}
			}

			context.IsExpandingTemplate = true;
			context.TemplateOwner = source as DependencyObject;
			context.TemplateBindingSource = fwe;
			parser.HydrateObject = context.Template;

			
			INativeEventObjectWrapper dob = null;
			try {
				FrameworkTemplate template = parser.ParseString (xaml) as FrameworkTemplate;
				
				if (template != null) {
					dob = template.Content as INativeEventObjectWrapper;
					template.Content = null;
				}

				// No errors, but the template was just empty.
				if (dob == null)
					return IntPtr.Zero;
			} catch (Exception e) {
				error = new MoonError (e);
				return IntPtr.Zero;
			} finally {
				context.IsExpandingTemplate = false;
				context.TemplateOwner = null;
				context.TemplateBindingSource = null;
			}

			// XamlParser needs to ref its return value otherwise we can end up returning a an object to native
			// code with a refcount of '1' and it could then get GC'ed before we use it.
			Mono.NativeMethods.event_object_ref (dob.NativeHandle);
			return dob.NativeHandle;
		}
Esempio n. 7
0
		public static Value CreateFromString (string xaml, bool create_namescope, bool validate_templates)
		{
			XamlParser p = new XamlParser () {
				CreateNameScope = create_namescope,
				ValidateTemplates = validate_templates,
			};

			object v = p.ParseString (xaml);

			return ObjectToValue (v);
		}