Пример #1
0
		/// <summary>
		/// Defaults are: OS Platform x86; Registry target HKCU; Append to file.
		/// </summary>
		public ADMVisitor(
			string admFilePath,
			OSPlatformEnum osPlatform = OSPlatformEnum.x86,
			RegistryTargetEnum registryTarget = RegistryTargetEnum.HKCU,
			bool appendFile = true, Predicate<string> namePredicate = null)
		{
			_namePred = namePredicate;
			this._admFileWriter = new ADMFileWriter(admFilePath, appendFile);
			this._osPlatform = osPlatform;
			this._registryTarget = registryTarget;
		}
Пример #2
0
		private bool GenerateADMFile(string outputFilePath)
		{
			using (ADMFileWriter admWriter = new ADMFileWriter(outputFilePath))
			{
				if (_registryTarget == RegistryTargetEnum.Both || _registryTarget == RegistryTargetEnum.HKLM)
				{
					// Generate HKLM first
					admWriter.WriteHKLMHeader();
					GenerateADMEntries(admWriter, RegistryTargetEnum.HKLM);
				}

				if (_registryTarget == RegistryTargetEnum.Both || _registryTarget == RegistryTargetEnum.HKCU)
				{
					// Generate HKCU after
					admWriter.WriteHKCUHeader();
					GenerateADMEntries(admWriter, RegistryTargetEnum.HKCU);
				}
			}

			return true;
		}
Пример #3
0
		private void GenerateOptionGroupTemplates(ADMFileWriter admWriter, RegistryTargetEnum localRegTarget)
		{
			// Create Section : Document Management			
			admWriter.StartCategory("Document Management");

			// Create OptionGroup : Interwoven Servers
			GenerateInterwovenTemplate(admWriter, localRegTarget);

			// Create OptionGroup : SharepointSites
			GenerateSharepointTemplate(admWriter, localRegTarget);

			admWriter.EndCategory();
		}
Пример #4
0
		private void GenerateSharepointTemplate(ADMFileWriter admWriter, RegistryTargetEnum localRegTarget)
		{
			admWriter.StartCategory("SharePointSiteCollection");

			for (int i = 1; i < 6; i++)
			{
				string instanceName = string.Format("Site{0}", i);
				WriteSharepointSiteInstance(admWriter, instanceName, localRegTarget);
			}

			admWriter.EndCategory();
		}
Пример #5
0
		private void GenerateInterwovenTemplate(ADMFileWriter admWriter, RegistryTargetEnum localRegTarget)
		{
			admWriter.StartCategory("InterwovenServers");

			for (int i = 1; i < 6; i++)
			{
				string instanceName = string.Format("Server{0}", i);
				WriteInterwovenServerInstance(admWriter, instanceName, localRegTarget);
			}

			admWriter.EndCategory();
		}
Пример #6
0
		private void WriteInterwovenServerInstance(ADMFileWriter admWriter, string instanceName, RegistryTargetEnum localRegTarget)
		{
			// Document Management\InterwovenServers\Server1
			WriteDocumentManagementInstance(admWriter, _interwovenServersOptionDefs, "InterwovenServers", instanceName, localRegTarget);
		}
Пример #7
0
		private void WriteSharepointSiteInstance(ADMFileWriter admWriter, string instanceName, RegistryTargetEnum localRegTarget)
		{
			// Document Management\SharePointSiteCollection\Site1
			WriteDocumentManagementInstance(admWriter, _sharepointSiteCollectionOptionDefs, "SharePointSiteCollection", instanceName, localRegTarget);
		}
Пример #8
0
		private void WriteDocumentManagementInstance(ADMFileWriter admWriter, List<OptionInfo> optionDefs, string subsectionName, string instanceName, RegistryTargetEnum localRegTarget)
		{
			// Document Management\<SubSectionName>\<InstanceName>
			string sectionName = string.Format("Document Management\\{0}\\{1}", subsectionName, instanceName);
			string keyname = Utils.GetOptionKeyName(sectionName, string.Empty, this._osPlatform, localRegTarget);

			admWriter.StartCategory(instanceName);

			foreach (OptionInfo optDef in optionDefs)
			{
				admWriter.StartPolicy(optDef.DisplayText);
				admWriter.StartKeyName(keyname);

				OptionDataTypeEnum optionDataType = (OptionDataTypeEnum) Enum.Parse(typeof(OptionDataTypeEnum), optDef.DataType);

				admWriter.AddPart(optDef.DisplayText, optionDataType, optDef.Name, string.Empty);
				admWriter.EndPolicy();
			}

			admWriter.EndCategory();
		}
Пример #9
0
		private void GenerateADMEntries(ADMFileWriter admWriter, RegistryTargetEnum localRegTarget)
		{
			var categoryGroups = from opt in _options
								 orderby opt.DisplayText
								 group opt by opt.CategoryRef into optGrp
								 orderby optGrp.Key
								 select new { CategoryName = optGrp.Key, Options = optGrp };


			admWriter.StartWorkshareCategory();

			foreach (var oCat in categoryGroups)
			{
				admWriter.StartCategory(oCat.CategoryName);
				var subCategoryGroups = from opt in oCat.Options
									 orderby opt.DisplayText
									 group opt by opt.CategoryRef into optGrp
									 orderby optGrp.Key
									 select new { SubCategoryName = optGrp.Key, Options = optGrp };

				foreach (var oSubCat in subCategoryGroups)
				{
					admWriter.StartCategory(oSubCat.SubCategoryName);
					foreach (var opt in oSubCat.Options)
					{
						if ((localRegTarget == RegistryTargetEnum.HKLM && opt.ReadLocalMachine == "false") ||
							 (localRegTarget == RegistryTargetEnum.HKCU && opt.ReadCurrentUser == "false"))
						{
							continue;
						}

						admWriter.StartPolicy(opt.DisplayText);
						admWriter.StartKeyName(Utils.GetOptionKeyName(opt.CategoryRef, opt.SubCategoryRef, this._osPlatform, localRegTarget));

						OptionDataTypeEnum optionDataType = (OptionDataTypeEnum) Enum.Parse(typeof(OptionDataTypeEnum), opt.DataType);

						admWriter.AddPart(opt.DisplayText, optionDataType, opt.Name, opt.DefaultValue, opt.ValueRange);
						admWriter.EndPolicy();
					}
					admWriter.EndCategory();	//	SubCategory
				}

				if (localRegTarget == RegistryTargetEnum.HKLM)
				{
					var hklmOptions = from opt in oCat.Options
					                  where (opt.ReadLocalMachine != "false") && (opt.ReadCurrentUser == "true")
									  select opt;

					admWriter.StartCategory("IgnoredUserOverrides");
					foreach (var opt in hklmOptions)
					{
						admWriter.StartPolicy(opt.DisplayText);
						admWriter.StartKeyName(Utils.GetIgnoreHKCUValueKeyName(this._osPlatform));
						admWriter.AddPart(opt.DisplayText, OptionDataTypeEnum.Boolean, opt.Name, "false");
						admWriter.EndPolicy();
					}
					admWriter.EndCategory(); // IgnoredUserOverrides
				}
				admWriter.EndCategory();	//	Category
			}

			GenerateOptionGroupTemplates(admWriter, localRegTarget);

			admWriter.EndWorkshareCategory();
		}