Ejemplo n.º 1
0
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
        {
            if (forType == null)
            {
                throw new ArgumentNullException("forType");
            }
            if (typeMetadata == null)
            {
                throw new ArgumentNullException("typeMetadata");
            }
            if (!typeof(DependencyObject).IsAssignableFrom(forType))
            {
                throw new ArgumentException(string.Format(
                                                "OverrideMetadata type '{0}' must inherit from DependencyObject", forType.FullName));
            }
            if (typeMetadata.HasDefaultValue)
            {
                ValidateDefaultValue(Name, PropertyType, OwnerType, typeMetadata.DefaultValue);
            }

            IntPtr forTypePtr = Noesis.Extend.EnsureNativeType(forType, false);

            Noesis_OverrideMetadata(forTypePtr, swigCPtr, PropertyMetadata.getCPtr(typeMetadata));

            DependencyPropertyRegistry.Override(this, forType, typeMetadata);
        }
        public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata)
        {
            IntPtr forTypePtr = Noesis.Extend.EnsureNativeType(forType, false);

            Noesis_OverrideMetadata(forTypePtr, swigCPtr.Handle,
                                    PropertyMetadata.getCPtr(typeMetadata).Handle);
        }
Ejemplo n.º 3
0
        internal static DependencyProperty RegisterCommon(string name, Type propertyType,
                                                          Type ownerType, PropertyMetadata propertyMetadata, DependencyProperty existingProperty = null)
        {
            ValidateParams(name, propertyType, ownerType);

            // Force native type registration, but skip DP registration because we are inside
            // static constructor and DP are already being registered
            IntPtr ownerTypePtr = Noesis.Extend.EnsureNativeType(ownerType, false);

            // Check dependency property with the same name is not already registered
            if (Noesis_ExistsDependencyProperty(ownerTypePtr, name))
            {
                throw new ArgumentException($"DependencyProperty '{name}' already registered to type '{ownerType}'");
            }

            // Check property type is supported and get the registered native type
            Type   originalPropertyType = propertyType;
            IntPtr nativeType           = ValidatePropertyType(ref propertyType);

            ValidateMetadata(name, propertyType, ownerType, ref propertyMetadata);

            // Create and register dependency property
            IntPtr dependencyPtr = Noesis_RegisterDependencyProperty(ownerTypePtr,
                                                                     name, nativeType, PropertyMetadata.getCPtr(propertyMetadata));

            DependencyProperty dependencyProperty = existingProperty;

            if (!ReferenceEquals(dependencyProperty, null))
            {
                // Replace DependencyProperty native pointer with the newly created
                dependencyProperty.swigCPtr = new HandleRef(dependencyProperty, dependencyPtr);
                Noesis.Extend.AddProxy(dependencyProperty);
                BaseComponent.AddReference(dependencyPtr);
            }
            else
            {
                dependencyProperty = new DependencyProperty(dependencyPtr, false);
                dependencyProperty.OriginalPropertyType = originalPropertyType;

                DependencyPropertyRegistry.Register(dependencyProperty, name, propertyType, ownerType, propertyMetadata);
            }

            return(dependencyProperty);
        }
Ejemplo n.º 4
0
        public DependencyProperty AddOwner(Type ownerType, PropertyMetadata metadata)
        {
            if (metadata != null)
            {
                ValidateDefaultValue(Name, PropertyType, ownerType, metadata.DefaultValue);
            }

            IntPtr ownerTypePtr = Noesis.Extend.EnsureNativeType(ownerType, false);
            IntPtr dp           = Noesis_AddOwnerDependencyProperty(swigCPtr, ownerTypePtr, PropertyMetadata.getCPtr(metadata));

            return(new DependencyProperty(dp, false));
        }
        private static DependencyProperty RegisterCommon(string name, Type propertyType,
                                                         Type ownerType, PropertyMetadata propertyMetadata)
        {
            ValidateParams(name, propertyType, ownerType);

            // Force native type registration, but skip DP registration because we are inside
            // static constructor and DP are already being registered
            IntPtr ownerTypePtr = Noesis.Extend.EnsureNativeType(ownerType, false);

            // Check property type is supported and get the registered native type
            Type   originalPropertyType = propertyType;
            IntPtr nativeType           = ValidatePropertyType(ref propertyType);

            // Create and register dependency property
            IntPtr dependencyPtr = Noesis_RegisterDependencyProperty(ownerTypePtr,
                                                                     name, nativeType, PropertyMetadata.getCPtr(propertyMetadata).Handle);

            DependencyProperty dependencyProperty = new DependencyProperty(dependencyPtr, false);

            dependencyProperty.OriginalPropertyType = originalPropertyType;

            RegisterCalled = true;
            return(dependencyProperty);
        }