コード例 #1
0
        public ControlManifestDetails FetchFeatures(ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList featureNodes = manifestFile.SelectNodes("/manifest/control/feature-usage/uses-feature");

            foreach (XmlNode node in featureNodes)
            {
                Feature feature = new Feature();

                try
                {
                    feature.Name     = (node.Attributes["name"]?.Value) ?? string.Empty;
                    feature.Required = bool.Parse(node.Attributes["required"]?.Value ?? "false");
                    feature.Type     = feature.IdentifyType(feature.Name);

                    feature.IsValid = true;
                }
                catch (Exception ex)
                {
                    feature.IsValid = false;
                }

                controlDetails.Features.Add(feature);
            }

            return(controlDetails);
        }
コード例 #2
0
        public void AddFeature(ControlManifestDetails controlDetails, string featureName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode      = manifestFile.SelectSingleNode($"/manifest/control");
            XmlNode featureUsageNode = manifestFile.SelectSingleNode($"/manifest/control/feature-usage");

            if (featureUsageNode == null)
            {
                XmlElement featureUsageNodeElement = manifestFile.CreateElement("feature-usage");
                controlNode.AppendChild(featureUsageNodeElement);
                featureUsageNode = manifestFile.SelectSingleNode($"/manifest/control/feature-usage");
            }

            XmlNode featureNode = manifestFile.SelectSingleNode($"/manifest/control/feature-usage/uses-feature[@name='{featureName}']");

            if (featureNode != null)
            {
                XmlAttribute attrRequired = featureNode.Attributes["required"];
                attrRequired.Value = "true";
            }
            else
            {
                XmlElement featureNodeElement = manifestFile.CreateElement("uses-feature");

                featureNodeElement.SetAttribute("name", featureName);
                featureNodeElement.SetAttribute("required", "true");
                featureUsageNode.AppendChild(featureNodeElement);
            }

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (validatePropertyData())
            {
                ControlProperty controlProperty = new ControlProperty();
                controlProperty.Name               = txtPropertyName.Text;
                controlProperty.DisplayNameKey     = txtDisplayNameKey.Text;
                controlProperty.DescriptionNameKey = txtDescriptionKey.Text;
                controlProperty.Usage              = (Enum.UsageType)ddUsage.SelectedItem;
                controlProperty.IsRequired         = chkRequired.Checked;
                controlProperty.IsUsingTypeGroup   = chkUseTypeGroup.Checked;
                controlProperty.TypeOrTypeGroup    = ddOfType.SelectedValue.ToString();

                ControlManifestHelper manifestHelper = new ControlManifestHelper();

                if (newProperty)
                {
                    manifestHelper.CreateNewProperty(manifestDetails, controlProperty);
                    Routine_EditControl();
                }
                else
                {
                    manifestDetails = manifestHelper.UpdatePropertyDetails(persistedPropertyName, manifestDetails, controlProperty);
                }

                persistedPropertyName = controlProperty.Name;
                ParentControl.RefreshControlManifestDetails();
            }
            else
            {
                MessageBox.Show("The property entry is invalid. Please populate all required fields.", "Invalid Propert State", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        public ControlManifestDetails FetchTypeGroups(ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList tgNodes = manifestFile.SelectNodes("/manifest/control/type-group");

            foreach (XmlNode node in tgNodes)
            {
                TypeGroup typegroup = new TypeGroup();

                try
                {
                    typegroup.Name = (node.Attributes["name"]?.Value) ?? string.Empty;

                    XmlNodeList typeNodes = manifestFile.SelectNodes($"manifest/control/type-group[@name='{typegroup.Name}']/type");
                    foreach (XmlNode type in typeNodes)
                    {
                        typegroup.Types.Add(type.InnerText);
                    }

                    controlDetails.TypeGroups.Add(typegroup);
                }
                catch (Exception ex)
                {
                }
            }

            return(controlDetails);
        }
コード例 #5
0
        public ControlManifestDetails UpdateControlDetails(ControlManifestDetails controlDetails, string displayName = "", string description = "")
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode      controlNode        = manifestFile.SelectSingleNode("/manifest/control");
            XmlAttribute attrDisplayNameKey = controlNode.Attributes["display-name-key"];
            XmlAttribute attrDescriptionKey = controlNode.Attributes["description-key"];

            // Update
            if (!string.IsNullOrEmpty(displayName))
            {
                attrDisplayNameKey.Value          = displayName;
                controlDetails.ControlDisplayName = displayName;
            }

            if (!string.IsNullOrEmpty(description))
            {
                attrDescriptionKey.Value          = description;
                controlDetails.ControlDescription = description;
            }

            manifestFile.Save(controlDetails.ManifestFilePath);

            return(controlDetails);
        }
コード例 #6
0
 public TypeGroupControl(PropertiesForm parent, Dictionary <string, string> attributes, ControlManifestDetails cmd)
 {
     InitializeComponent();
     collection      = attributes;
     manifestDetails = cmd;
     InitializeControls();
     ParentControl = parent;
 }
コード例 #7
0
 public TypeControl(PropertiesForm parent, Dictionary <string, string> attributes, ControlManifestDetails cmd, object t = null)
 {
     ParentControl   = parent;
     collection      = attributes;
     manifestDetails = cmd;
     tag             = (Dictionary <string, string>)t;
     InitializeComponent();
     InitializeControls();
 }
コード例 #8
0
        public int RetrieveTypeGroupReferenceCount(ControlManifestDetails controlDetails, string typeGroupName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList propertyNodes = manifestFile.SelectNodes($"/manifest/control/property[@of-type-group='{typeGroupName}']");

            return(propertyNodes.Count);
        }
コード例 #9
0
        public int RetrieveTypeInTypeGroupCount(ControlManifestDetails controlDetails, string typeGroupName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList tgTypeNodes = manifestFile.SelectNodes($"/manifest/control/type-group[@name='{typeGroupName}']/type");

            return(tgTypeNodes.Count);
        }
コード例 #10
0
        public void DeleteTypeGroup(ControlManifestDetails controlDetails, string tgName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode   = manifestFile.SelectSingleNode($"/manifest/control");
            XmlNode typeGroupNode = manifestFile.SelectSingleNode($"manifest/control/type-group[@name='{tgName}']");

            controlNode.RemoveChild(typeGroupNode);

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #11
0
        public ShowPreviewImage(ControlManifestDetails details)
        {
            InitializeComponent();

            _controlDetails     = details;
            lblDisplayName.Text = _controlDetails.ControlDisplayName;
            lblDescription.Text = _controlDetails.ControlDescription;
            lblTypes.Text       = String.Join(", ", _controlDetails.Properties
                                              .Where(p => p.IsUsingTypeGroup == false && p.Usage == Helper.Enum.UsageType.bound)
                                              .Select(p => p.TypeOrTypeGroup));

            pboxPreviewImage.ImageLocation = _controlDetails.PreviewImagePath;
        }
コード例 #12
0
        public void DeleteProperty(ControlManifestDetails controlDetails, string propertyName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode  = manifestFile.SelectSingleNode($"/manifest/control");
            XmlNode propertyNode = manifestFile.SelectSingleNode($"/manifest/control/property[@name='{propertyName}']");

            controlNode.RemoveChild(propertyNode);

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #13
0
        public void FetchProperties_Test()
        {
            ControlManifestDetails details = new ControlManifestDetails();

            details.WorkingFolderPath   = @"C:\PowerMeUpExamples\TestNewDesign";
            details.ControlName         = "PCFTest";
            details.ControlDescription  = "Testing";
            details.ManifestFilePath    = $"{details.WorkingFolderPath}\\{details.ControlName}\\ControlManifest.Input.xml";
            details.FoundControlDetails = true;

#if DEBUG
            ControlManifestHelper helper = new ControlManifestHelper();
            helper.FetchProperties(details);
#endif
        }
コード例 #14
0
        public void AddNewTypeInTypeGroup(ControlManifestDetails controlDetails, string typeGroupName, string typeName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode tgNode = manifestFile.SelectSingleNode($"manifest/control/type-group[@name='{typeGroupName}']");

            XmlElement typeNode = manifestFile.CreateElement("type");

            typeNode.InnerText = typeName;
            tgNode.AppendChild(typeNode);

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #15
0
        public void DeleteTypeInTypeGroup(ControlManifestDetails controlDetails, string tgName, string typeName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode     typeGroupNode = manifestFile.SelectSingleNode($"manifest/control/type-group[@name='{tgName}']");
            XmlNodeList typeNodes     = manifestFile.SelectNodes($"manifest/control/type-group[@name='{tgName}']/type");

            foreach (XmlNode typeNode in typeNodes)
            {
                if (typeNode.InnerText == typeName)
                {
                    typeGroupNode.RemoveChild(typeNode);
                }
            }

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #16
0
        public void CreateNewTypeGroup(ControlManifestDetails controlDetails, string typeGroupName, string initialType)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode = manifestFile.SelectSingleNode($"/manifest/control");

            XmlElement tgNode = manifestFile.CreateElement("type-group");

            tgNode.SetAttribute("name", typeGroupName);

            XmlElement typeNode = manifestFile.CreateElement("type");

            typeNode.InnerText = initialType;
            tgNode.AppendChild(typeNode);

            controlNode.AppendChild(tgNode);
            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #17
0
        public ControlManifestDetails FetchProperties(ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList propertyNodes = manifestFile.SelectNodes("/manifest/control/property");

            foreach (XmlNode node in propertyNodes)
            {
                ControlProperty property = new ControlProperty();

                try
                {
                    property.Name               = (node.Attributes["name"]?.Value) ?? string.Empty;
                    property.DisplayNameKey     = (node.Attributes["display-name-key"]?.Value) ?? string.Empty;
                    property.DescriptionNameKey = (node.Attributes["description-key"]?.Value) ?? string.Empty;
                    property.TypeOrTypeGroup    = (node.Attributes["of-type"]?.Value) ?? string.Empty;
                    property.IsRequired         = bool.Parse(node.Attributes["required"]?.Value ?? "false");
                    property.Usage              = (node.Attributes["usage"]?.Value ?? "bound") == "bound" ? Enum.UsageType.bound : Enum.UsageType.input;

                    // Check of of-type-group
                    if (string.IsNullOrEmpty(property.TypeOrTypeGroup))
                    {
                        property.TypeOrTypeGroup  = (node.Attributes["of-type-group"]?.Value) ?? string.Empty;
                        property.IsUsingTypeGroup = true;
                    }

                    property.IsValid = true;
                }
                catch (Exception ex)
                {
                    property.IsValid = false;
                }

                controlDetails.Properties.Add(property);
            }

            return(controlDetails);
        }
コード例 #18
0
        public void RemoveFeature(ControlManifestDetails controlDetails, string featureName)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode      = manifestFile.SelectSingleNode($"/manifest/control");
            XmlNode featureUsageNode = manifestFile.SelectSingleNode($"/manifest/control/feature-usage");
            XmlNode featureNode      = manifestFile.SelectSingleNode($"/manifest/control/feature-usage/uses-feature[@name='{featureName}']");

            if (featureNode != null)
            {
                featureUsageNode.RemoveChild(featureNode);
            }

            XmlNodeList featureNodes = manifestFile.SelectNodes("/manifest/control/feature-usage/uses-feature");

            if (featureNodes.Count == 0)
            {
                controlNode.RemoveChild(featureUsageNode);
            }

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #19
0
        public void CreateNewProperty(ControlManifestDetails controlDetails, ControlProperty property)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode = manifestFile.SelectSingleNode($"/manifest/control");

            XmlElement propertyNode = manifestFile.CreateElement("property");

            if (!string.IsNullOrEmpty(property.Name))
            {
                propertyNode.SetAttribute("name", property.Name);
            }
            if (!string.IsNullOrEmpty(property.DisplayNameKey))
            {
                propertyNode.SetAttribute("display-name-key", property.DisplayNameKey);
            }
            if (!string.IsNullOrEmpty(property.DescriptionNameKey))
            {
                propertyNode.SetAttribute("description-key", property.DescriptionNameKey);
            }
            propertyNode.SetAttribute("usage", property.Usage.ToString());
            propertyNode.SetAttribute("required", property.IsRequired ? "true" : "false");
            if (property.IsUsingTypeGroup)
            {
                propertyNode.SetAttribute("of-type-group", property.TypeOrTypeGroup);
            }
            else
            {
                propertyNode.SetAttribute("of-type", property.TypeOrTypeGroup);
            }
            controlNode.AppendChild(propertyNode);

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #20
0
        public void UpdateTypeGroupName(string currentTypeGroupName, string newTypeGroupName, ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode      typeGroupNode = manifestFile.SelectSingleNode($"manifest/control/type-group[@name='{currentTypeGroupName}']");
            XmlAttribute attrName      = typeGroupNode.Attributes["name"];

            // Update
            if (!string.IsNullOrEmpty(newTypeGroupName) && attrName != null)
            {
                attrName.Value = newTypeGroupName;
            }

            // Update References
            XmlNodeList propertyNodes = manifestFile.SelectNodes($"/manifest/control/property[@of-type-group='{currentTypeGroupName}']");

            foreach (XmlNode node in propertyNodes)
            {
                XmlAttribute attrOfTypeGroup = node.Attributes["of-type-group"];
                attrOfTypeGroup.Value = newTypeGroupName;
            }

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
コード例 #21
0
        public ControlManifestDetails GetControlManifestDetails(string controlFolder)
        {
            ControlManifestDetails ControlDetails = new ControlManifestDetails();

            ControlDetails.FoundControlDetails = false;

            var start    = DateTime.Now;
            var mainDirs = Directory.GetDirectories(controlFolder);

            ControlDetails.WorkingFolderPath = controlFolder;

            if (mainDirs != null && mainDirs.Count() > 0)
            {
                // Check if .pcfproj does not already exists
                var filteredPcfProject = mainDirs.ToList().Where(l => (!l.ToLower().EndsWith(".pcfproj")));
                if (filteredPcfProject != null && filteredPcfProject.Count() > 0)
                {
                    var pcfDirs = Directory.GetDirectories(ControlDetails.WorkingFolderPath);
                    if (pcfDirs != null && pcfDirs.Count() > 0)
                    {
                        var filteredPcfDirs = pcfDirs.ToList().Where(l => (!l.ToLower().EndsWith("node_modules")) && (!l.ToLower().EndsWith("obj")) && (!l.ToLower().EndsWith("out")));
                        foreach (var currentDir in filteredPcfDirs)
                        {
                            var indexExists = CodeFileExists(currentDir);
                            if (!string.IsNullOrEmpty(indexExists))
                            {
                                ControlDetails.FoundControlDetails = true;

                                ControlDetails.ControlName = Path.GetFileName(currentDir);
                                var controlManifestFile = currentDir + "\\" + "ControlManifest.Input.xml";
                                ControlDetails.ManifestFilePath = controlManifestFile;
                                XmlReader xmlReader = XmlReader.Create(ControlDetails.ManifestFilePath);

                                while (xmlReader.Read())
                                {
                                    if (xmlReader.NodeType == XmlNodeType.Element)
                                    {
                                        switch (xmlReader.Name)
                                        {
                                        case "control":
                                            ControlDetails.Namespace          = xmlReader.GetAttribute("namespace");
                                            ControlDetails.Version            = xmlReader.GetAttribute("version");
                                            ControlDetails.ControlDisplayName = xmlReader.GetAttribute("display-name-key");
                                            ControlDetails.ControlDescription = xmlReader.GetAttribute("description-key");

                                            if (xmlReader.GetAttribute("preview-image") != null)
                                            {
                                                var sanitizedPreviewImageRelativePath = xmlReader.GetAttribute("preview-image").Replace("/", "\\");
                                                ControlDetails.PreviewImagePath = $"{currentDir}\\{sanitizedPreviewImageRelativePath}";
                                            }

                                            break;

                                        case "data-set":
                                            ControlDetails.IsDatasetTemplate = true;
                                            break;

                                        case "css":
                                            ControlDetails.ExistsCSS = true;
                                            break;

                                        case "resx":
                                            ControlDetails.ExistsResx = true;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                                xmlReader.Close();
                                ControlManifestHelper manifestHelper = new ControlManifestHelper();
                                ControlDetails = manifestHelper.FetchProperties(ControlDetails);
                                ControlDetails = manifestHelper.FetchTypeGroups(ControlDetails);
                                ControlDetails = manifestHelper.FetchFeatures(ControlDetails);
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                //MessageBox.Show("Could not retrieve existing PCF project and CDS solution project details.");
                ControlDetails.FoundControlDetails = false;
            }

            return(ControlDetails);
        }
コード例 #22
0
        public ControlManifestDetails UpdatePropertyDetails(string propertyName, ControlManifestDetails controlDetails, ControlProperty property)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode      propertyNode       = manifestFile.SelectSingleNode($"/manifest/control/property[@name='{propertyName}']");
            XmlAttribute attrName           = propertyNode.Attributes["name"];
            XmlAttribute attrDisplayNameKey = propertyNode.Attributes["display-name-key"];
            XmlAttribute attrDescriptionKey = propertyNode.Attributes["description-key"];
            XmlAttribute attrUsage          = propertyNode.Attributes["usage"];
            XmlAttribute attrRequired       = propertyNode.Attributes["required"];
            XmlAttribute attrOfType         = propertyNode.Attributes["of-type"];
            XmlAttribute attrOfTypeGroup    = propertyNode.Attributes["of-type-group"];

            // Update
            if (!string.IsNullOrEmpty(property.Name) && attrName != null)
            {
                attrName.Value = property.Name;
            }
            if (!string.IsNullOrEmpty(property.DisplayNameKey) && attrDisplayNameKey != null)
            {
                attrDisplayNameKey.Value = property.DisplayNameKey;
            }
            if (!string.IsNullOrEmpty(property.DescriptionNameKey) && attrDescriptionKey != null)
            {
                attrDescriptionKey.Value = property.DescriptionNameKey;
            }
            if (attrUsage != null)
            {
                attrUsage.Value = property.Usage.ToString();
            }
            if (attrRequired != null)
            {
                attrRequired.Value = property.IsRequired ? "true" : "false";
            }
            if (attrOfType != null)
            {
                if (property.IsUsingTypeGroup)
                {
                    // Change of-type ot of-type-group
                    XmlAttribute newattr = manifestFile.CreateNewAttribute("of-type-group", property.TypeOrTypeGroup);
                    propertyNode.Attributes.Append(newattr);
                    propertyNode.Attributes.Remove(attrOfType);
                }
                else
                {
                    attrOfType.Value = property.TypeOrTypeGroup;
                }
            }
            if (attrOfTypeGroup != null)
            {
                if (property.IsUsingTypeGroup)
                {
                    attrOfTypeGroup.Value = property.TypeOrTypeGroup;
                }
                else
                {
                    // Change of-type ot of-type-group
                    XmlAttribute newattr = manifestFile.CreateNewAttribute("of-type", property.TypeOrTypeGroup);
                    propertyNode.Attributes.Append(newattr);
                    propertyNode.Attributes.Remove(attrOfTypeGroup);
                }
            }

            // Update Control Manifest Details
            var updateProp = controlDetails.Properties.FirstOrDefault(p => p.Name == propertyName);

            updateProp = property;

            manifestFile.Save(controlDetails.ManifestFilePath);

            return(controlDetails);
        }
コード例 #23
0
        public void UpdateTypeInTypeGroup(string currentTypeGroupName, string currentType, string newType, ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList typeNodes = manifestFile.SelectNodes($"manifest/control/type-group[@name='{currentTypeGroupName}']/type");

            foreach (XmlNode type in typeNodes)
            {
                if (type.InnerText == currentType)
                {
                    type.InnerText = newType;
                }
            }

            manifestFile.Save(controlDetails.ManifestFilePath);
        }