Exemplo n.º 1
0
 private static void GeneratePropertyDeclaration(RequestParser rp, CodeWriter cw)
 {
     cw.AppendLine($"public {rp.NullableTargetType()} {rp.PropName}");
     using var block = cw.CurlyBlock();
     cw.AppendLine($"get => ({rp.NullableTargetType()})this.GetValue({rp.ParentType()}.{rp.DependencyPropName()});");
     cw.AppendLine($"set => this.SetValue({rp.ParentType()}.{rp.DependencyPropName()}, value);");
 }
Exemplo n.º 2
0
 private static void GenerateAttachedHelperMethods(RequestParser rp, CodeWriter cw)
 {
     cw.AppendLine($"public static {rp.NullableTargetType()} Get{rp.PropName}(System.Windows.DependencyObject obj) =>");
     cw.AppendLine($"    ({rp.NullableTargetType()})obj.GetValue({rp.ParentType()}.{rp.DependencyPropName()});");
     cw.AppendLine($"public static void Set{rp.PropName}(System.Windows.DependencyObject obj, {rp.NullableTargetType()} value) =>");
     cw.AppendLine($"    obj.SetValue({rp.ParentType()}.{rp.DependencyPropName()}, value);");
 }
Exemplo n.º 3
0
        private static void GenerateDependencyProperty(RequestParser rp, CodeWriter cw)
        {
            if (rp.FromCustomDpDeclaration)
            {
                return;
            }
            cw.AppendLine($"public static readonly System.Windows.DependencyProperty {rp.DependencyPropName()} = ");
            var attached = rp.Attached ? "Attached" : "";

            cw.AppendLine($"    System.Windows.DependencyProperty.Register{attached}(");
            cw.AppendLine($"    \"{rp.PropName}\", typeof({TypeOfArgument(rp)}), typeof({rp.ParentType()}),");
            cw.AppendLine($"    new System.Windows.FrameworkPropertyMetadata({rp.DefaultExpression()}{ChangeFunc(rp)}));");
            cw.AppendLine();
        }