• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mono.Value类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.Value的典型用法代码示例。如果您正苦于以下问题:C# Value类的具体用法?C# Value怎么用?C# Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Value类属于Mono命名空间,在下文中一共展示了Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetMethodForAttachedProperty

		private unsafe MethodInfo GetMethodForAttachedProperty (Value *top_level, string xmlns, string type_name, string full_type_name, string prop_name, string method_prefix, Type [] arg_types)
		{
			string assembly_name = AssemblyNameFromXmlns (xmlns);
			string ns = ClrNamespaceFromXmlns (xmlns);
				
			if (assembly_name == null && !TryGetDefaultAssemblyName (top_level, out assembly_name)) {
				Console.Error.WriteLine ("Unable to find an assembly to load type from.");
				return null;
			}

			Assembly clientlib;
			if (LoadAssembly (assembly_name, out clientlib) != AssemblyLoadResult.Success) {
				Console.Error.WriteLine ("couldn't load assembly:  {0}   namespace:  {1}", assembly_name, ns);
				return null;
			}

			Type attach_type = clientlib.GetType (full_type_name, false);
			if (attach_type == null) {
				attach_type = Application.GetComponentTypeFromName (type_name);
				if (attach_type == null) {
					Console.Error.WriteLine ("attach type is null type name: {0} full type name: {1}", type_name, full_type_name);
					return null;
				}
			}

			MethodInfo [] methods = attach_type.GetMethods (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

			string method_name = String.Concat (method_prefix, prop_name);
			foreach (MethodInfo method in methods) {

				if (method.Name != method_name)
					continue;

				ParameterInfo [] the_params = method.GetParameters ();
				if (the_params.Length != arg_types.Length)
					continue;

				bool match = true;
				for (int i = 0; i < arg_types.Length; i++) {
					if (!arg_types [i].IsAssignableFrom (the_params [i].ParameterType)) {
						Console.WriteLine ("NOT A MATCH:  {0} -- {1} : {2}", method, arg_types [i], the_params [i]);
						match = false;
						break;
					}
				}

				if (match)
					return method;
			}

			return null;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:52,代码来源:ManagedXamlLoader.cs


示例2: ParseTemplate

		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;
		}
开发者ID:shana,项目名称:moon,代码行数:36,代码来源:XamlParser.cs


示例3: FromObject

		//
		// How do we support "null" values, should the caller take care of that?
		//
		// The caller is responsible for calling value_free_value on the returned Value
		public static Value FromObject (object v, bool box_value_types)
		{
			Value value = new Value ();
			
			unsafe {
				// get rid of this case right away.
				if (box_value_types && v.GetType().IsValueType) {
					//Console.WriteLine ("Boxing a value of type {0}:", v.GetType());

					GCHandle handle = GCHandle.Alloc (v);
					value.k = Deployment.Current.Types.TypeToKind (v.GetType ());
					value.IsGCHandle = true;
					value.u.p = GCHandle.ToIntPtr (handle);
					return value;
				}

				if (v is IEasingFunction && !(v is EasingFunctionBase))
					v = new EasingFunctionWrapper (v as IEasingFunction);

				if (v is INativeEventObjectWrapper) {
					INativeEventObjectWrapper dov = (INativeEventObjectWrapper) v;

					if (dov.NativeHandle == IntPtr.Zero)
						throw new Exception (String.Format (
							"Object {0} has not set its native property", dov.GetType()));

					NativeMethods.event_object_ref (dov.NativeHandle);

					value.k = dov.GetKind ();
					value.u.p = dov.NativeHandle;

				} else if (v is DependencyProperty) {
					value.k = Kind.DEPENDENCYPROPERTY;
					value.u.p = ((DependencyProperty)v).Native;
				}
				else if (v is int || (v.GetType ().IsEnum && Enum.GetUnderlyingType (v.GetType()) == typeof(int))) {
					value.k = Deployment.Current.Types.TypeToKind (v.GetType ());
					value.u.i32 = (int) v;
				}
				else if (v is bool) {
					value.k = Kind.BOOL;
					value.u.i32 = ((bool) v) ? 1 : 0;
				}
				else if (v is double) {
					value.k = Kind.DOUBLE;
					value.u.d = (double) v;
				}
				else if (v is float) {
					value.k = Kind.FLOAT;
					value.u.f = (float) v;
				}
				else if (v is long) {
					value.k = Kind.INT64;
					value.u.i64 = (long) v;
				}
				else if (v is TimeSpan) {
					TimeSpan ts = (TimeSpan) v;
					value.k = Kind.TIMESPAN;
					value.u.i64 = ts.Ticks;
				}
				else if (v is ulong) {
					value.k = Kind.UINT64;
					value.u.ui64 = (ulong) v;
				}
				else if (v is uint) {
					value.k = Kind.UINT32;
					value.u.ui32 = (uint) v;
				}
				else if (v is char) {
					value.k = Kind.CHAR;
					value.u.ui32 = (uint) (char) v;
				}
				else if (v is string) {
					value.k = Kind.STRING;

					value.u.p = StringToIntPtr ((string) v);
				}
				else if (v is Rect) {
					Rect rect = (Rect) v;
					value.k = Kind.RECT;
					value.u.p = Marshal.AllocHGlobal (sizeof (Rect));
					Marshal.StructureToPtr (rect, value.u.p, false); // Unmanaged and managed structure layout is equal.
				}
				else if (v is Size) {
					Size size = (Size) v;
					value.k = Kind.SIZE;
					value.u.p = Marshal.AllocHGlobal (sizeof (Size));
					Marshal.StructureToPtr (size, value.u.p, false); // Unmanaged and managed structure layout is equal.
				}
				else if (v is CornerRadius) {
					CornerRadius corner = (CornerRadius) v;
					value.k = Kind.CORNERRADIUS;
					value.u.p = Marshal.AllocHGlobal (sizeof (CornerRadius));
					Marshal.StructureToPtr (corner, value.u.p, false); // Unmanaged and managed structure layout is equal.
				}
				else if (v is AudioFormat) {
//.........这里部分代码省略.........
开发者ID:shana,项目名称:moon,代码行数:101,代码来源:Value.cs


示例4: Hydrate

		public void Hydrate (Value value, string xaml, bool createNamescope, bool validateTemplates, bool import_default_xmlns)
		{
			HydrateInternal (value, xaml, createNamescope, validateTemplates, import_default_xmlns);
		}
开发者ID:shana,项目名称:moon,代码行数:4,代码来源:XamlLoaderCallbacks.cs


示例5: RegisterAny

        private static DependencyProperty RegisterAny(string name, Type propertyType, Type ownerType, PropertyMetadata metadata, bool attached, bool readOnly, bool setsParent, bool custom)
        {
            ManagedType property_type;
            ManagedType owner_type;
            UnmanagedPropertyChangeHandler handler = null;
            CustomDependencyProperty result;
            bool is_nullable = false;
            object default_value = DependencyProperty.UnsetValue;
            PropertyChangedCallback property_changed_callback = null;

            if (name == null)
                throw new ArgumentNullException ("name");

            if (name.Length == 0)
                throw new ArgumentException("The 'name' argument cannot be an empty string");

            if (propertyType == null)
                throw new ArgumentNullException ("propertyType");

            if (ownerType == null)
                throw new ArgumentNullException ("ownerType");

            if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition () == typeof (Nullable<>)) {
                is_nullable = true;
                // Console.WriteLine ("DependencyProperty.RegisterAny (): found nullable {0}, got nullable {1}", propertyType.FullName, propertyType.GetGenericArguments () [0].FullName);
                propertyType = propertyType.GetGenericArguments () [0];
            }

            Types types = Deployment.Current.Types;

            property_type = types.Find (propertyType);
            owner_type = types.Find (ownerType);

            if (metadata != null) {
                default_value = metadata.DefaultValue ?? UnsetValue;
                property_changed_callback = metadata.property_changed_callback;
            }

            if ((default_value == DependencyProperty.UnsetValue) && propertyType.IsValueType && !is_nullable)
                default_value = Activator.CreateInstance (propertyType);

            if (default_value != null && default_value != UnsetValue && !propertyType.IsAssignableFrom (default_value.GetType ()))
                throw new ArgumentException (string.Format ("DefaultValue is of type {0} which is not compatible with type {1}", default_value.GetType (), propertyType));

            if (property_changed_callback != null)
                handler = UnmanagedPropertyChangedCallbackSafe;

            Value v;
            if (default_value == DependencyProperty.UnsetValue) {
                v = new Value { k = types.TypeToKind (propertyType), IsNull = true };
                default_value = null;
            } else {
                v = Value.FromObject (default_value, true);
            }

            IntPtr handle;
            using (v) {
                var val = v;
                if (custom)
                    handle = NativeMethods.dependency_property_register_custom_property (name, property_type.native_handle, owner_type.native_handle, ref val, attached, readOnly, handler);
                else
                    handle = NativeMethods.dependency_property_register_core_property (name, property_type.native_handle, owner_type.native_handle, ref val, attached, readOnly, handler);
            }

            if (handle == IntPtr.Zero)
                return null;

            if (is_nullable)
                NativeMethods.dependency_property_set_is_nullable (handle, true);

            result = new CustomDependencyProperty (handle, name, property_type, owner_type, default_value);
            result.attached = attached;
            result.PropertyChangedHandler = handler;
            result.property_changed_callback = property_changed_callback;

            return result;
        }
开发者ID:Clancey,项目名称:ClanceyLib,代码行数:77,代码来源:DependencyProperty.cs


示例6: AddChild

		private unsafe bool AddChild (XamlCallbackData *data, Value* parent_parent_ptr, bool parent_is_property, string parent_xmlns, Value *parent_ptr, IntPtr parent_data, Value* child_ptr, IntPtr child_data)
		{
			object parent = Value.ToObject (null, parent_ptr);
			object child = Value.ToObject (null, child_ptr);

			if (parent_is_property) {
				object parent_parent = Value.ToObject (null, parent_parent_ptr);
				return AddChildToProperty (data, parent_parent, parent_xmlns, parent, child, child_data);
			}

			return AddChildToItem (data, parent_parent_ptr, parent, parent_data, child_ptr, child, child_data);
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:12,代码来源:ManagedXamlLoader.cs


示例7: LookupObject

		private unsafe bool LookupObject (Value *top_level, Value *parent, string xmlns, string name, bool create, bool is_property, out Value value)
		{
			if (name == null)
				throw new ArgumentNullException ("type_name");

			
			if (is_property) {
				int dot = name.IndexOf ('.');
				return LookupPropertyObject (top_level, parent, xmlns, name, dot, create, out value);
			}

			if (top_level == null && xmlns == null) {
				return LookupComponentFromName (top_level, name, create, out value);
			}

			string assembly_name = AssemblyNameFromXmlns (xmlns);
			string clr_namespace = ClrNamespaceFromXmlns (xmlns);
			string full_name = string.IsNullOrEmpty (clr_namespace) ? name : clr_namespace + "." + name;

			Type type = LookupType (top_level, assembly_name, full_name);
			if (type == null) {
				Console.Error.WriteLine ("ManagedXamlLoader::LookupObject: GetType ({0}) failed using assembly: {1} ({2}, {3}).", name, assembly_name, xmlns, full_name);
				value = Value.Empty;
				return false;
			}

			if (create) {

				if (!type.IsPublic) {
					value = Value.Empty;
					throw new XamlParseException ("Attempting to create a private type");
				}

				object res = null;
				try {
					res = Activator.CreateInstance (type);
				} catch (TargetInvocationException ex) {
					Console.WriteLine (ex);
					Console.Error.WriteLine ("ManagedXamlLoader::LookupObject: CreateInstance ({0}) failed: {1}", name, ex.InnerException);
					value = Value.Empty;
					return false;
				}

				if (res == null) {
					Console.Error.WriteLine ("ManagedXamlLoader::LookupObject ({0}, {1}, {2}): unable to create object instance: '{3}', the object was of type '{4}'",
								 assembly_name, xmlns, name, full_name, type.FullName);
					value = Value.Empty;
					return false;
				}
				// This is freed in native.
				value = Value.FromObject (res, false);
			} else {
				value = Value.Empty;
				value.k = Deployment.Current.Types.Find (type).native_handle;
			}

			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:58,代码来源:ManagedXamlLoader.cs


示例8: LookupPropertyObject

		private unsafe bool LookupPropertyObject (Value* top_level, Value* parent_value, string xmlns, string name, int dot, bool create, out Value value)
		{
			string prop_name = name.Substring (dot + 1);
			object parent = Value.ToObject (null, parent_value);

			if (parent == null) {
				value = Value.Empty;
				return false;
			}

			PropertyInfo pi = null;
			bool is_attached = true;
			string type_name = name.Substring (0, dot);

			Type t = parent.GetType ();
			while (t != typeof (object)) {
				if (t.Name == type_name) {
					is_attached = false;
					break;
				}
				t = t.BaseType;
			}

			if (is_attached) {
				Type attach_type = null;
				string full_type_name = type_name;
				if (xmlns != null) {
					string ns = ClrNamespaceFromXmlns (xmlns);
					full_type_name = String.Concat (ns, ".", type_name);
				}

				MethodInfo get_method = GetGetMethodForAttachedProperty (top_level, xmlns, type_name, full_type_name, prop_name);

				if (get_method != null)
					attach_type = get_method.ReturnType;

				if (attach_type == null) {
					value = Value.Empty;
					return false;
				}

				ManagedType mt = Deployment.Current.Types.Find (attach_type);
				value = Value.Empty;
				value.IsNull = true;
				value.k = mt.native_handle;
				return true;
			} else {
				pi = parent.GetType ().GetProperty (name.Substring (dot + 1), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);

				if (pi == null) {
					value = Value.Empty;
					return false;
				}

				ManagedType mt = Deployment.Current.Types.Find (pi.PropertyType);
				value = Value.Empty;
				value.k = mt.native_handle;
				value.IsNull = true;

				return true;
			}
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:62,代码来源:ManagedXamlLoader.cs


示例9: cb_add_child

		private unsafe bool cb_add_child (XamlCallbackData *data, Value* parent_parent, bool parent_is_property, string parent_xmlns, Value *parent, IntPtr parent_data, Value* child, IntPtr child_data, ref MoonError error)
		{
			try {
				return AddChild (data, parent_parent, parent_is_property, parent_xmlns, parent, parent_data, child, child_data);
			} catch (Exception ex) {
				Console.Error.WriteLine (ex);
				error = new MoonError (ex);
				return false;
			}
				
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:11,代码来源:ManagedXamlLoader.cs


示例10: TryGetDefaultAssemblyName

		private unsafe bool TryGetDefaultAssemblyName (Value* top_level, out string assembly_name)
		{
			if (assembly != null) {
				assembly_name = assembly.GetName ().Name;
				return true;
			}

			object obj = Value.ToObject (null, top_level);

			if (obj == null) {
				assembly_name = null;
				return false;
			}

			assembly_name = obj.GetType ().Assembly.GetName ().Name;
			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:17,代码来源:ManagedXamlLoader.cs


示例11: cb_set_property

		//
		// Proxy so that we return bool in case of any failures, instead of
		// generating an exception and unwinding the stack.
		//
		private unsafe bool cb_set_property (XamlCallbackData *data, string xmlns, Value* target, IntPtr target_data, Value* target_parent, string prop_xmlns, string name, Value* value_ptr, IntPtr value_data, ref MoonError error)
		{
			try {
				return SetProperty (data, xmlns, target, target_data, target_parent, prop_xmlns, name, value_ptr, value_data);
			} catch (Exception ex) {
				try {
					Console.Error.WriteLine ("ManagedXamlLoader::SetProperty ({0}, {1}, {2}, {3}, {4}) threw an exception: {5}", (IntPtr) data->top_level, xmlns, (IntPtr)target, name, (IntPtr)value_ptr, ex.Message);
					Console.Error.WriteLine (ex);
					error = new MoonError (ex);
					return false;
				}
				catch {
					return false;
				}
			}
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:20,代码来源:ManagedXamlLoader.cs


示例12: cb_lookup_object

		///
		///
		/// Callbacks invoked by the xaml.cpp C++ parser
		///
		///

#region Callbacks from xaml.cpp
		//
		// Proxy so that we return IntPtr.Zero in case of any failures, instead of
		// genereting an exception and unwinding the stack.
		//
		private unsafe bool cb_lookup_object (XamlCallbackData *data, Value* parent, string xmlns, string name, bool create, bool is_property, out Value value, ref MoonError error)
		{
			value = Value.Empty;
			try {
				return LookupObject (data->top_level, parent, xmlns, name, create, is_property, out value);
			} catch (Exception ex) {
				NativeMethods.value_free_value (ref value);
				value = Value.Empty;
				Console.Error.WriteLine ("ManagedXamlLoader::LookupObject ({0}, {1}, {2}, {3}) failed: {3} ({4}).", (IntPtr) data->top_level, xmlns, create, name, ex.Message, ex.GetType ().FullName);
				Console.WriteLine (ex);
				error = new MoonError (ex);
				return false;
			}
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:25,代码来源:ManagedXamlLoader.cs


示例13: GetObjectValue

		private static unsafe object GetObjectValue (object target, IntPtr target_data, string prop_name, IntPtr parser, Value* value_ptr, out string error)
		{
			error = null;

			IntPtr unmanaged_value = IntPtr.Zero;
			object o_value = Value.ToObject (null, value_ptr);
			if (error == null && unmanaged_value != IntPtr.Zero)
				o_value = Value.ToObject (null, unmanaged_value);

			if (o_value is String && SL3MarkupExpressionParser.IsStaticResource ((string) o_value)) {
				MarkupExpressionParser mp = new SL3MarkupExpressionParser ((DependencyObject) target, prop_name, parser, target_data);
				string str_value = o_value as String;
				o_value = mp.ParseExpression (ref str_value);
			}

			return o_value;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:17,代码来源:ManagedXamlLoader.cs


示例14: TrySetObjectTextProperty

		private unsafe bool TrySetObjectTextProperty (XamlCallbackData *data, string xmlns, object target, Value* target_ptr, IntPtr target_data, Value* value_ptr, IntPtr value_data)
		{
			object obj_value = Value.ToObject (null, value_ptr);
			string str_value = obj_value as string;

			if (str_value == null)
				return false;
			
			string assembly_name = AssemblyNameFromXmlns (xmlns);
			string clr_namespace = ClrNamespaceFromXmlns (xmlns);
			string type_name = NativeMethods.xaml_get_element_name (data->parser, target_data);
			string full_name = String.IsNullOrEmpty (clr_namespace) ? type_name : clr_namespace + "." + type_name;

			Type type = LookupType (data->top_level, assembly_name, full_name);

			if (type == null || type.IsSubclassOf (typeof (DependencyObject)))
				return false;

			// For now just trim the string right here, in the future this should probably be done in the xaml parser
			object e = ConvertType (null, type, str_value.Trim ());

			NativeMethods.value_free_value2 ((IntPtr)target_ptr);

			unsafe {
				Value *val = (Value *) target_ptr;

				GCHandle handle = GCHandle.Alloc (e);
				val->IsGCHandle = true;
				val->k = Deployment.Current.Types.TypeToKind (e.GetType ());
				val->u.p = GCHandle.ToIntPtr (handle);
			}

			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:34,代码来源:ManagedXamlLoader.cs


示例15: LookupComponentFromName

		private unsafe bool LookupComponentFromName (Value* top_level, string name, bool create, out Value value)
		{
			if (!create) {
				Type type = Application.GetComponentTypeFromName (name);
				if (type == null) {
					value = Value.Empty;
					return false;
				}
				value = Value.Empty;
				value.k = Deployment.Current.Types.Find (type).native_handle;
				return true;
			}

			object obj = Application.CreateComponentFromName (name);
			if (obj == null) {
				value = Value.Empty;
				return false;
			}

			value = Value.FromObject (obj, false);
			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:22,代码来源:ManagedXamlLoader.cs


示例16: SetProperty

		private unsafe bool SetProperty (XamlCallbackData *data, string xmlns, Value* target_ptr, IntPtr target_data, Value* target_parent_ptr, string prop_xmlns, string name, Value* value_ptr, IntPtr value_data)
		{
			string error;
			object target = Value.ToObject (null, target_ptr);

			if (target == null) {
				Console.Error.WriteLine ("target is null: {0} {1} {2}", (IntPtr)target_ptr, name, xmlns);
				return false;
			}

			if (name == null) {
				if (TrySetEnumContentProperty (data, xmlns, target, target_ptr, target_data, value_ptr, value_data))
					return true;
				if (TrySetCollectionContentProperty (xmlns, target, target_ptr, target_data, value_ptr, value_data))
					return true;
				if (TrySetObjectTextProperty (data, xmlns, target, target_ptr, target_data, value_ptr, value_data))
					return true;
				Console.Error.WriteLine ("no property name supplied");
				return false;
			}

			string full_name = name;
			int dot = name.IndexOf ('.');
			string type_name = null;

			if (dot >= 0) {
				type_name = name.Substring (0, dot);
				if (prop_xmlns != null) {
					string ns = ClrNamespaceFromXmlns (prop_xmlns);
					if (ns != null)
						type_name = String.Concat (ns, ".", type_name);
				}
				name = name.Substring (++dot, name.Length - dot);
			}

			if (TrySetExpression (data, xmlns, target, target_data, target_parent_ptr, type_name, prop_xmlns, name, full_name, value_ptr, value_data))
				return true;

			if (!IsAttachedProperty (data, target, xmlns, prop_xmlns, full_name)) {
				if (TrySetPropertyReflection (data, xmlns, target, target_data, target_parent_ptr, type_name, name, value_ptr, value_data, out error))
					return true;

				if (TrySetEventReflection (data, xmlns, target, type_name, name, value_ptr, out error))
					return true;
			} else {
				if (TrySetAttachedProperty (data, xmlns, target, target_data, prop_xmlns, full_name, value_ptr))
					return true;
			}

			
			return false;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:52,代码来源:ManagedXamlLoader.cs


示例17: TrySetExpression

		private unsafe bool TrySetExpression (XamlCallbackData *data, string xmlns, object target, IntPtr target_data, Value* target_parent_ptr, string type_name, string prop_xmlns, string name, string full_name, Value* value_ptr, IntPtr value_data)
		{
			DependencyObject dob = target as DependencyObject;
			object obj_value = Value.ToObject (null, value_ptr);
			string str_value = obj_value as string;

			if (str_value == null)
				return false;
			
			if (!str_value.StartsWith ("{"))
				return false;

			MarkupExpressionParser p = new SL3MarkupExpressionParser (target, name, data->parser, target_data);
			string expression = str_value;
			object o = p.ParseExpression (ref expression);

			if (o == null)
				return false;

			
			if (o is Binding) {
				Binding binding = o as Binding;
				DependencyProperty prop = null;

				if (dob != null) {
					string full_type_name = type_name;
					if (IsAttachedProperty (full_name))
						GetNameForAttachedProperty (xmlns, prop_xmlns, full_name, out type_name, out full_type_name);
					prop = LookupDependencyPropertyForBinding (data, dob, full_type_name, name);
					if (prop == null && IsAttachedProperty (full_name))
						prop = LookupDependencyPropertyForBinding (data, dob, full_name.Split ('.')[0], name);
				}

				// If it's null we should look for a regular CLR property
				if (prop != null) {
					BindingOperations.SetBinding (dob, prop, binding);
					return true;
				}
			}
			if (o is TemplateBindingExpression) {
				// Applying a {TemplateBinding} to a DO which is not a FrameworkElement should silently discard
				// the binding.
				if (!(dob is FrameworkElement))
					return true;

				TemplateBindingExpression tb = o as TemplateBindingExpression;

				IntPtr context = NativeMethods.sl3_xaml_loader_get_context (data->loader);
				IntPtr source_ptr = NativeMethods.xaml_context_get_template_binding_source (context);

				// Silently discard TemplateBindings which are not in ControlTemplates
				FrameworkTemplate source_template = (FrameworkTemplate) NativeDependencyObjectHelper.Lookup (NativeMethods.xaml_context_get_source_template (context));
				if (!(source_template is ControlTemplate))
					return true;

				DependencyObject templateSourceObject = NativeDependencyObjectHelper.FromIntPtr (source_ptr) as DependencyObject;
				if (templateSourceObject == null)
					return false;

				DependencyProperty sourceProperty = DependencyProperty.Lookup (templateSourceObject.GetKind(),
												       tb.SourcePropertyName);
				if (sourceProperty == null)
					return false;

				DependencyProperty prop = null;

				if (dob != null)
					prop = LookupDependencyPropertyForBinding (data, dob, type_name, name);

				if (prop == null)
					return false;

				tb.TargetProperty = prop;
				tb.SourceProperty = sourceProperty;

				((FrameworkElement) dob).SetTemplateBinding (prop, tb);

				return true;
			}

			if (IsAttachedProperty (full_name))
				return TrySetAttachedProperty (data, xmlns, target, target_data, prop_xmlns, full_name, o);

			PropertyInfo pi = target.GetType ().GetProperty (name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);

			o = ConvertType (pi, pi.PropertyType, o);
			SetValue (data, target_data, pi, target, o);
			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:89,代码来源:ManagedXamlLoader.cs


示例18: TrySetAttachedProperty

		private unsafe bool TrySetAttachedProperty (XamlCallbackData *data, string xmlns, object target, IntPtr target_data, string prop_xmlns, string name, Value* value_ptr)
		{
			string full_name = name;
			string type_name = null;
			string full_type_name = null;

			name = GetNameForAttachedProperty (xmlns, prop_xmlns, name, out type_name, out full_type_name);

			if (name == null)
				return false;

			string error = null;
			object o_value = GetObjectValue (target, target_data, name, data->parser, value_ptr, out error);
			
			return TrySetAttachedProperty (data, xmlns, target, target_data, prop_xmlns, full_name, o_value);
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:16,代码来源:ManagedXamlLoader.cs


示例19: TrySetPropertyReflection

		private unsafe bool TrySetPropertyReflection (XamlCallbackData *data, string xmlns, object target, IntPtr target_data, Value* target_parent_ptr, string type_name, string name, Value* value_ptr, IntPtr value_data, out string error)
		{	
			PropertyInfo pi = target.GetType ().GetProperty (name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy);

			if (pi == null) {
				error = "Property does not exist.";
				return false;
			}

			if (!SetPropertyFromValue (data, target, target_data, target_parent_ptr, pi, value_ptr, value_data, out error))
				return false;

			error = null;
			return true;
		}
开发者ID:fmaulanaa,项目名称:moon,代码行数:15,代码来源:ManagedXamlLoader.cs


示例20: HydrateInternal

		protected abstract void HydrateInternal (Value value, string xaml, bool createNamescope, bool validateTemplates, bool import_default_xmlns);
开发者ID:shana,项目名称:moon,代码行数:1,代码来源:XamlLoaderCallbacks.cs



注:本文中的Mono.Value类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Addins.ExtensionNodeEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Logic.WebServiceResponse类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap