示例#1
0
        public bool LoadConfigurationXml(IPageContext pageContext)
        {
            if (pageContext == null)
            {
                throw new ArgumentNullException("pageContext");
            }
            ITemplateContext    templateContext = (ITemplateContext)pageContext;
            TemplateInputConfig templateConfig  = new TemplateInputConfig
            {
                Name             = templateContext.OutputFolder.DisplayName,
                Description      = templateContext.OutputFolder.Description,
                TemplateIdString = this.GetTemplateIdString(templateContext)
            };

            this.GetDiscoveryConfig(templateContext, ref templateConfig);
            this.GetRunAsAccounts(templateContext, ref templateConfig);
            pageContext.ConfigurationXml = XmlHelper.Serialize(templateConfig, false);
            return(true);
        }
示例#2
0
        private void GetDiscoveryConfig(ITemplateContext templateContext, ref TemplateInputConfig templateConfig)
        {
            if (templateContext == null)
            {
                throw new ArgumentNullException("templateContext");
            }
            foreach (ManagementPackDiscovery discovery in SDKHelper.GetFolderItems <ManagementPackDiscovery>(this, templateContext.OutputFolder))
            {
                if (discovery.Name.StartsWith(DiscoveryNamePrefix, StringComparison.OrdinalIgnoreCase))
                {
                    MatchCollection matchs = new Regex(ValueNodeRegex, RegexOptions.CultureInvariant | RegexOptions.Compiled).Matches(discovery.DataSource.Configuration);

                    templateConfig.ASBNamespaceName = matchs[0].Groups[1].Value;
                    templateConfig.ProxyAgentComputerPrincipalName = matchs[2].Groups[1].Value;
                    return;
                }
            }
            throw new ObjectNotFoundException("my message");
        }
示例#3
0
        private void GetRunAsAccounts(ITemplateContext templateContext, ref TemplateInputConfig templateConfig)
        {
            if (templateContext == null)
            {
                throw new ArgumentNullException("templateContext");
            }

            ManagementPackElementCollection <ManagementPackSecureReferenceOverride> folderItems = SDKHelper.GetFolderItems <ManagementPackSecureReferenceOverride>(this, templateContext.OutputFolder);

            templateConfig.RunAsAccount = string.Empty;

            foreach (ManagementPackSecureReferenceOverride @override in folderItems)
            {
                if (@override.Name.StartsWith(AccountOverrideNamePrefix, StringComparison.OrdinalIgnoreCase))
                {
                    templateConfig.RunAsAccount = @override.Value;
                    break;
                }
            }
        }