Esempio n. 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 void DeleteBindingStorage(BindingStorage bindingStorage)
        {
            ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
            ExBindingStoreObject exBindingStoreObject = bindingStorage.RawObject as ExBindingStoreObject;

            if (exBindingStoreObject == null)
            {
                throw new InvalidOperationException("BindingStorage has no associated ExBindingStoreObject, cannot be deleted.");
            }
            base.Delete(exBindingStoreObject);
        }
        public BindingStorage FindBindingStorageByPolicyId(Guid policyId)
        {
            BindingStorage       result = null;
            ExBindingStoreObject exBindingStoreObject = this.FindByAlternativeId <ExBindingStoreObject>(policyId.ToString());

            if (exBindingStoreObject != null)
            {
                result = exBindingStoreObject.ToBindingStorage(this.policyConfigProvider);
            }
            return(result);
        }
        public BindingStorage FindBindingStorageById(string identity)
        {
            BindingStorage       result = null;
            SearchFilter         filter = new SearchFilter.IsEqualTo(ExBindingStoreObjectSchema.MasterIdentity.StorePropertyDefinition, identity);
            ExBindingStoreObject exBindingStoreObject = this.InternalFindPaged <ExBindingStoreObject>(filter, this.GetDefaultFolder(), false, null, 1, new ProviderPropertyDefinition[0]).FirstOrDefault <ExBindingStoreObject>();

            if (exBindingStoreObject != null)
            {
                result = exBindingStoreObject.ToBindingStorage(this.policyConfigProvider);
            }
            return(result);
        }
Esempio n. 5
0
 public void FromBindingStorage(BindingStorage bindingStorage, ExPolicyConfigProvider policyConfigProvider)
 {
     ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
     ArgumentValidator.ThrowIfNull("policyConfigProvider", policyConfigProvider);
     this.Name           = bindingStorage.Name;
     this.MasterIdentity = bindingStorage.MasterIdentity;
     this.PolicyId       = bindingStorage.PolicyId;
     this.Workload       = bindingStorage.Workload;
     this.PolicyVersion  = bindingStorage.PolicyVersion;
     this.RawAppliedScopes.Clear();
     foreach (ScopeStorage scopeStorage in bindingStorage.AppliedScopes)
     {
         string item = ExBindingStoreObject.ScopeStorageToString(scopeStorage);
         this.RawAppliedScopes.Add(item);
     }
 }
        public void SaveBindingStorage(BindingStorage bindingStorage)
        {
            ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
            if (bindingStorage.ObjectState == ObjectState.Unchanged)
            {
                return;
            }
            ExBindingStoreObject exBindingStoreObject = bindingStorage.RawObject as ExBindingStoreObject;

            if (bindingStorage.ObjectState == ObjectState.New)
            {
                exBindingStoreObject = new ExBindingStoreObject();
            }
            if (exBindingStoreObject == null)
            {
                throw new InvalidOperationException("BindingStorage has no associated ExBindingStoreObject to save.");
            }
            exBindingStoreObject.FromBindingStorage(bindingStorage, this.policyConfigProvider);
            this.Save(exBindingStoreObject);
        }