# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/(public|)\s+(?<type>[^\s]+)\s+(?<name>[^\s]+)\s*\{(\s*(get|set)\s*;){2}\s*\}/public static readonly DependencyProperty ${name}Property = DependencyProperty.Register("${name}", typeof(${type}), typeof(DependencyObjectType), new PropertyMetadata(default(${type}), ${name}Changed));\nprivate static void ${name}Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)\n{\nvar dependencyObjectType = dependencyObject as DependencyObjectType;\nif(dependencyObjectType == null)\nreturn;\nvar oldValue = (${type})dependencyPropertyChangedEventArgs.OldValue;\nvar newValue = (${type})dependencyPropertyChangedEventArgs.NewValue;\n\/* Logic... *\/\n}\n\/\/\/ <summary>\n\/\/\/ ${name}\n\/\/\/ <\/summary>\npublic ${type} ${name}\n{\nget { return (${type})GetValue(${name}Property); }\nset { SetValue(${name}Property, value); }\n}/g;t' <<< "public TypeName PropertyName { get; set; }"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html