Ejemplo n.º 1
0
 private static extern void Noesis_DependencySet_Thickness(IntPtr dependencyObject, IntPtr dependencyProperty,
                                                           ref Noesis.Thickness val, bool isNullable, bool isNull);
Ejemplo n.º 2
0
        private static Dictionary <Type, SetDelegate> CreateSetFunctions()
        {
            Dictionary <Type, SetDelegate> setFunctions = new Dictionary <Type, SetDelegate>(50);

            setFunctions[typeof(bool)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Bool(cPtr, dp, (bool)value, false, false);
            };
            setFunctions[typeof(float)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Float(cPtr, dp, (float)value, false, false);
            };
            setFunctions[typeof(double)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Double(cPtr, dp, (double)value, false, false);
            };
            setFunctions[typeof(decimal)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Double(cPtr, dp, (double)(decimal)value, false, false);
            };
            setFunctions[typeof(int)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Int(cPtr, dp, (int)value, false, false);
            };
            setFunctions[typeof(long)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Int(cPtr, dp, (int)(long)value, false, false);
            };
            setFunctions[typeof(uint)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_UInt(cPtr, dp, (uint)value, false, false);
            };
            setFunctions[typeof(ulong)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_UInt(cPtr, dp, (uint)(ulong)value, false, false);
            };
            setFunctions[typeof(char)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_UInt(cPtr, dp, (uint)(char)value, false, false);
            };
            setFunctions[typeof(short)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Short(cPtr, dp, (short)value, false, false);
            };
            setFunctions[typeof(sbyte)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Short(cPtr, dp, (short)(sbyte)value, false, false);
            };
            setFunctions[typeof(ushort)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_UShort(cPtr, dp, (ushort)value, false, false);
            };
            setFunctions[typeof(byte)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_UShort(cPtr, dp, (ushort)(byte)value, false, false);
            };
            setFunctions[typeof(string)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_String(cPtr, dp, value == null ? string.Empty : value.ToString());
            };
            setFunctions[typeof(System.Uri)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis_DependencySet_Uri(cPtr, dp, value == null ? string.Empty : ((Uri)value).OriginalString);
            };
            setFunctions[typeof(Noesis.Color)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Color value_ = (Noesis.Color)value;
                Noesis_DependencySet_Color(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.Point)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Point value_ = (Noesis.Point)value;
                Noesis_DependencySet_Point(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.Rect)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Rect value_ = (Noesis.Rect)value;
                Noesis_DependencySet_Rect(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.Size)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Size value_ = (Noesis.Size)value;
                Noesis_DependencySet_Size(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.Thickness)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Thickness value_ = (Noesis.Thickness)value;
                Noesis_DependencySet_Thickness(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.CornerRadius)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.CornerRadius value_ = (Noesis.CornerRadius)value;
                Noesis_DependencySet_CornerRadius(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(TimeSpan)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.TimeSpanStruct value_ = (Noesis.TimeSpanStruct)((TimeSpan)value);
                Noesis_DependencySet_TimeSpan(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.Duration)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.Duration value_ = (Noesis.Duration)value;
                Noesis_DependencySet_Duration(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(Noesis.KeyTime)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                Noesis.KeyTime value_ = (Noesis.KeyTime)value;
                Noesis_DependencySet_KeyTime(cPtr, dp, ref value_, false, false);
            };
            setFunctions[typeof(bool?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Bool(cPtr, dp, default(bool), true, true);
                }
                else
                {
                    Noesis_DependencySet_Bool(cPtr, dp, (bool)value, true, false);
                }
            };
            setFunctions[typeof(float?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Float(cPtr, dp, default(float), true, true);
                }
                else
                {
                    Noesis_DependencySet_Float(cPtr, dp, (float)value, true, false);
                }
            };
            setFunctions[typeof(double?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Double(cPtr, dp, default(double), true, true);
                }
                else
                {
                    Noesis_DependencySet_Double(cPtr, dp, (double)value, true, false);
                }
            };
            setFunctions[typeof(decimal?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Double(cPtr, dp, default(double), true, true);
                }
                else
                {
                    Noesis_DependencySet_Double(cPtr, dp, (double)(decimal)value, true, false);
                }
            };
            setFunctions[typeof(int?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Int(cPtr, dp, default(int), true, true);
                }
                else
                {
                    Noesis_DependencySet_Int(cPtr, dp, (int)value, true, false);
                }
            };
            setFunctions[typeof(long?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Int(cPtr, dp, default(int), true, true);
                }
                else
                {
                    Noesis_DependencySet_Int(cPtr, dp, (int)(long)value, true, false);
                }
            };
            setFunctions[typeof(uint?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_UInt(cPtr, dp, default(uint), true, true);
                }
                else
                {
                    Noesis_DependencySet_UInt(cPtr, dp, (uint)value, true, false);
                }
            };
            setFunctions[typeof(ulong?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_UInt(cPtr, dp, default(uint), true, true);
                }
                else
                {
                    Noesis_DependencySet_UInt(cPtr, dp, (uint)(ulong)value, true, false);
                }
            };
            setFunctions[typeof(char?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_UInt(cPtr, dp, default(uint), true, true);
                }
                else
                {
                    Noesis_DependencySet_UInt(cPtr, dp, (uint)(char)value, true, false);
                }
            };
            setFunctions[typeof(short?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Short(cPtr, dp, default(short), true, true);
                }
                else
                {
                    Noesis_DependencySet_Short(cPtr, dp, (short)value, true, false);
                }
            };
            setFunctions[typeof(sbyte?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_Short(cPtr, dp, default(short), true, true);
                }
                else
                {
                    Noesis_DependencySet_Short(cPtr, dp, (short)(sbyte)value, true, false);
                }
            };
            setFunctions[typeof(ushort?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_UShort(cPtr, dp, default(ushort), true, true);
                }
                else
                {
                    Noesis_DependencySet_UShort(cPtr, dp, (ushort)value, true, false);
                }
            };
            setFunctions[typeof(byte?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis_DependencySet_UShort(cPtr, dp, default(ushort), true, true);
                }
                else
                {
                    Noesis_DependencySet_UShort(cPtr, dp, (ushort)(byte)value, true, false);
                }
            };
            setFunctions[typeof(Noesis.Color?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Color value_ = default(Noesis.Color);
                    Noesis_DependencySet_Color(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Color value_ = (Noesis.Color)value;
                    Noesis_DependencySet_Color(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.Point?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Point value_ = default(Noesis.Point);
                    Noesis_DependencySet_Point(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Point value_ = (Noesis.Point)value;
                    Noesis_DependencySet_Point(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.Rect?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Rect value_ = default(Noesis.Rect);
                    Noesis_DependencySet_Rect(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Rect value_ = (Noesis.Rect)value;
                    Noesis_DependencySet_Rect(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.Size?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Size value_ = default(Noesis.Size);
                    Noesis_DependencySet_Size(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Size value_ = (Noesis.Size)value;
                    Noesis_DependencySet_Size(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.Thickness?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Thickness value_ = default(Noesis.Thickness);
                    Noesis_DependencySet_Thickness(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Thickness value_ = (Noesis.Thickness)value;
                    Noesis_DependencySet_Thickness(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.CornerRadius?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.CornerRadius value_ = default(Noesis.CornerRadius);
                    Noesis_DependencySet_CornerRadius(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.CornerRadius value_ = (Noesis.CornerRadius)value;
                    Noesis_DependencySet_CornerRadius(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(TimeSpan?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.TimeSpanStruct value_ = default(Noesis.TimeSpanStruct);
                    Noesis_DependencySet_TimeSpan(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.TimeSpanStruct value_ = (Noesis.TimeSpanStruct)((TimeSpan)value);
                    Noesis_DependencySet_TimeSpan(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.Duration?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.Duration value_ = default(Noesis.Duration);
                    Noesis_DependencySet_Duration(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.Duration value_ = (Noesis.Duration)value;
                    Noesis_DependencySet_Duration(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Noesis.KeyTime?)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                if (value == null)
                {
                    Noesis.KeyTime value_ = default(Noesis.KeyTime);
                    Noesis_DependencySet_KeyTime(cPtr, dp, ref value_, true, true);
                }
                else
                {
                    Noesis.KeyTime value_ = (Noesis.KeyTime)value;
                    Noesis_DependencySet_KeyTime(cPtr, dp, ref value_, true, false);
                }
            };
            setFunctions[typeof(Type)] = (cPtr, dp, value) =>
            {
                CheckProperty(cPtr, dp, "set");
                System.Type value_ = (System.Type)value;
                IntPtr      ptr    = value != null?Noesis.Extend.GetNativeType(value_) : IntPtr.Zero;

                Noesis_DependencySet_Type(cPtr, dp, ptr);
            };

            return(setFunctions);
        }