示例#1
0
		internal static IPolicySetResponse GetIPolicySetResponse(PolicySet policySet)
		{
			if (null == policySet)
				throw new ArgumentException("policySet");

			PolicySetResponse psr = new PolicySetResponse(policySet.Name);
			psr.Date = policySet.Date;
			
			if ( policySet.Properties != null)
			{
				foreach (CustomProperty property in policySet.Properties)
				{
					psr.Properties[property.Name] = property.Value;
				}
			}

			psr.PolicyReportCollection = new Collection<IPolicyResponse>();
			if ( policySet.Policies != null )
			{
				foreach (Workshare.PolicyContent.Policy policy in policySet.Policies)
				{
					psr.PolicyReportCollection.Add( PolicyAdaptor.GetIPolicyResponse(policy) );
				}
			}

			return psr;
		}
示例#2
0
		internal static PolicySet GetPolicySet(IPolicySetResponse psr)
		{
			if (null == psr)
				throw new ArgumentNullException("psr");

			PolicySet policySet = new PolicySet();

			policySet.Name = psr.Name;
			policySet.Date = psr.Date;

			policySet.Properties = new CustomProperty[0];
			int index = 0;
			if (psr.Properties != null && psr.Properties.Count > 0)
			{
				policySet.Properties = new CustomProperty[psr.Properties.Count];
				foreach (string key in psr.Properties.Keys)
				{
					policySet.Properties[index++] = new CustomProperty(key, psr.Properties[key]);
				}
			}

			policySet.Policies = new Workshare.PolicyContent.Policy[0];
			if (psr.PolicyReportCollection != null && psr.PolicyReportCollection.Count > 0)
			{
				policySet.Policies = new Workshare.PolicyContent.Policy[psr.PolicyReportCollection.Count];
				index = 0;
				foreach (IPolicyResponse response in psr.PolicyReportCollection)
				{
					policySet.Policies[index++] = PolicyAdaptor.GetPolicy(response);
				}
			}

			return policySet;
		}