public string GenerateProperty(PropertyDefinition property)
        {
            StringBuilder xString = new StringBuilder();

            if (property.GetMethod != null)
            {
                xString.AppendLine(GenerateMethodPlugEntry.GenerateMethod(property.GetMethod));
                xString.AppendLine();
            }
            if (property.SetMethod != null)
            {
                xString.AppendLine(GenerateMethodPlugEntry.GenerateMethod(property.SetMethod));
                xString.AppendLine();
            }
            return(xString.ToString());
        }
Ejemplo n.º 2
0
        public override void Execute(TextViewContext context)
        {
            if (context.SelectedTreeNodes.Length != 1)
            {
                throw new Exception("SelectedTreeNodes = " + context.SelectedTreeNodes.Length);
            }
            var xCurrentProperty = context.SelectedTreeNodes[0] as PropertyTreeNode;

            if (xCurrentProperty == null)
            {
                throw new Exception("Current TreeNode is not a Property!");
            }

            if (MessageBox.Show("Do you want to generate plug code to your clipboard?", "Cosmos Plug tool", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }

            var xProp = xCurrentProperty.PropertyDefinition;
            var xSB   = new StringBuilder();

            if (xProp.GetMethod != null)
            {
                xSB.AppendLine(GenerateMethodPlugEntry.GenerateMethod(xProp.GetMethod));
                xSB.AppendLine();
            }
            if (xProp.SetMethod != null)
            {
                xSB.AppendLine(GenerateMethodPlugEntry.GenerateMethod(xProp.SetMethod));
                xSB.AppendLine();
            }

            Clipboard.SetText(xSB.ToString().Trim());

            MessageBox.Show("Done", "Cosmos Plug tool");
        }