示例#1
0
        public BindingStorage ToBindingStorage(ExPolicyConfigProvider policyConfigProvider)
        {
            ArgumentValidator.ThrowIfNull("policyConfigProvider", policyConfigProvider);
            BindingStorage bindingStorage = new BindingStorage();

            bindingStorage.SetId(PolicyStorage.PoliciesContainer.GetChildId(this.Name));
            bindingStorage.Name           = this.Name;
            bindingStorage.MasterIdentity = this.MasterIdentity;
            bindingStorage.PolicyId       = this.PolicyId;
            bindingStorage.Workload       = this.Workload;
            bindingStorage.PolicyVersion  = this.PolicyVersion;
            foreach (string scopeStorageString in this.RawAppliedScopes)
            {
                ScopeStorage scopeStorage = ExBindingStoreObject.ScopeStorageFromString(scopeStorageString, policyConfigProvider);
                if (scopeStorage != null)
                {
                    bindingStorage.AppliedScopes.Add(scopeStorage);
                }
            }
            if (this.WhenChanged != null)
            {
                bindingStorage.propertyBag.SetField(ADObjectSchema.WhenChangedRaw, ADValueConvertor.ConvertValueToString(this.WhenChanged.Value, null));
            }
            if (this.WhenCreated != null)
            {
                bindingStorage.propertyBag.SetField(ADObjectSchema.WhenCreatedRaw, ADValueConvertor.ConvertValueToString(this.WhenCreated.Value, null));
            }
            bindingStorage.ResetChangeTracking(true);
            bindingStorage.RawObject = this;
            return(bindingStorage);
        }
        public static BindingStorage ToBindingStorage(BindingConfiguration binding)
        {
            BindingStorage bindingStorage = new BindingStorage();

            bindingStorage[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(binding.TenantId);
            bindingStorage.Name = binding.Name;
            bindingStorage.SetId((ADObjectId)DalHelper.ConvertFromStoreObject(binding.ObjectId, typeof(ADObjectId)));
            UnifiedPolicyStorageFactory.CopyPropertiesToStorage <BindingConfiguration>(new TenantSettingFacade <BindingStorage>(bindingStorage), binding);
            if (binding.AppliedScopes != null && binding.AppliedScopes.Changed)
            {
                bindingStorage.AppliedScopes = new MultiValuedProperty <ScopeStorage>(from s in binding.AppliedScopes.ChangedValues
                                                                                      select UnifiedPolicyStorageFactory.ToScopeStorage(s));
            }
            return(bindingStorage);
        }
示例#3
0
        internal static BindingStorage CreateNewBindingStorage(ADObjectId tenantId, Workload workload, Guid policyId)
        {
            string         text           = workload.ToString() + policyId.ToString();
            BindingStorage bindingStorage = new BindingStorage
            {
                MasterIdentity = Guid.NewGuid(),
                Name           = text,
                PolicyId       = policyId,
                Workload       = workload
            };

            bindingStorage[ADObjectSchema.OrganizationalUnitRoot] = tenantId;
            bindingStorage.SetId(tenantId.GetDescendantId(PolicyStorage.PoliciesContainer).GetChildId(policyId.ToString()).GetChildId(text));
            return(bindingStorage);
        }