예제 #1
0
        public void DetachedContextDoesNotAffectViewTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var context2 = new TestContext <string> {
                Property = contextUpdated
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            BindingStorage.SetContext(view, context);
            BindingStorage.SetContext(view, context2);

            context.Property = contextPropertyUpdated;

            Assert.AreEqual(contextPropertyUpdated, context.Property);
            Assert.AreEqual(contextUpdated, context2.Property);
            Assert.AreEqual(contextUpdated, view.Value);
        }
예제 #2
0
        public void SwitchedContextDoesNotUpdatedTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var context2 = new TestContext <string> {
                Property = contextUpdated
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .ViewEvent(nameof(view.ValueChanged))
            .To <TestContext <string> >(ctx => ctx.Property);

            BindingStorage.SetContext(view, context);
            BindingStorage.SetContext(view, context2);

            view.Value = viewUpdated;

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(viewUpdated, context2.Property);
            Assert.AreEqual(viewUpdated, view.Value);
        }
예제 #3
0
        private BindingStorage GetBindingStorageForSubWorkload(IEnumerable <BindingStorage> bindingContainers, Workload subWorkload, Guid universalIdentity, bool createNewIfNotFound)
        {
            IEnumerable <BindingStorage> enumerable = from s in bindingContainers
                                                      where s.Workload == Workload.SharePoint
                                                      select s;
            BindingStorage bindingStorage3 = (from bindingStorage in enumerable
                                              where bindingStorage.Scopes.Any <string>()
                                              select bindingStorage).FirstOrDefault((BindingStorage bindingStorage) => BindingMetadata.FromStorage(bindingStorage.Scopes.First <string>()).Workload == subWorkload);

            if (bindingStorage3 != null)
            {
                return(bindingStorage3);
            }
            foreach (BindingStorage bindingStorage2 in enumerable)
            {
                if (!bindingStorage2.Scopes.Any <string>())
                {
                    bindingStorage3 = bindingStorage2;
                    return(bindingStorage3);
                }
            }
            if (createNewIfNotFound)
            {
                bindingStorage3 = Utils.CreateNewBindingStorage(base.OrganizationalUnitRoot, Workload.SharePoint, universalIdentity);
                this.StorageBindings.Add(bindingStorage3);
            }
            return(bindingStorage3);
        }
예제 #4
0
        public void OneWayBindingFullFlowTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            // set binding => nothing should be cnahged
            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(viewInitial, view.Value);

            // set context => view should be updated
            BindingStorage.SetContext(view, context);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(contextInitial, view.Value);

            // context update => view should be updated
            context.Property = contextUpdated;

            Assert.AreEqual(contextUpdated, context.Property);
            Assert.AreEqual(contextUpdated, view.Value);
        }
예제 #5
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);
        }
예제 #6
0
        public static IBindingBuilder <UITextField, IInpuntViewModel <string> > BindToInput(this UIViewController contextOwner, UITextField textField)
        {
            SetTextFieldInnerBindings(textField);

            return(BindingStorage.Bind <UITextField>(contextOwner, textField)
                   .ViewProperty <IInpuntViewModel <string> >((view, viewModel) => view.SetContext(viewModel)));
        }
예제 #7
0
        public void ContextCanUpdateManyViewsTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };
            var view2 = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            view.Bind(view2)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            BindingStorage.SetContext(view, context);
            BindingStorage.SetContext(view2, context);

            context.Property = contextUpdated;

            Assert.AreEqual(contextUpdated, context.Property);
            Assert.AreEqual(contextUpdated, view.Value);
            Assert.AreEqual(contextUpdated, view2.Value);
        }
 private void DeleteBindingStorage(BindingStorage bindingInstance)
 {
     foreach (ScopeStorage instance in bindingInstance.AppliedScopes)
     {
         ((IConfigDataProvider)this).Delete(instance);
     }
     base.DataProvider.Delete(bindingInstance);
 }
예제 #9
0
            public void ViewWillAppear(bool animated)
            {
                ViewModel = ViewModel ?? (TViewModel)Activator.CreateInstance(typeof(TViewModel)); //todo
                ViewModel.ViewWillAppearing();

                if (SetContextOrder == UpdateOrder.BeforeAppear)
                {
                    BindingStorage.SetContext(owner, ViewModel);
                }
            }
        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);
        }
예제 #13
0
        private void UpdateSharepointStorageBinding(Guid universalIdentity, Workload subWorkload, MultiValuedProperty <BindingMetadata> scopes, Exception mulipleStorageObjectsException)
        {
            ExAssert.RetailAssert(subWorkload == Workload.SharePoint || subWorkload == Workload.OneDriveForBusiness, "UpdateSharepointStorageBinding called for non-Sharepoint workload.");
            if (this.StorageBindings.Count((BindingStorage x) => x.Workload == Workload.SharePoint) > 2)
            {
                throw mulipleStorageObjectsException;
            }
            BindingStorage bindingStorageForSubWorkload = this.GetBindingStorageForSubWorkload(this.StorageBindings, subWorkload, universalIdentity, scopes.Any <BindingMetadata>());

            if (bindingStorageForSubWorkload != null)
            {
                Utils.PopulateScopeStorages(bindingStorageForSubWorkload, scopes);
            }
        }
        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);
        }
예제 #15
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);
        }
예제 #16
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 static BindingConfiguration FromBindingStorage(BindingStorage bindingStorage)
        {
            BindingConfiguration bindingConfiguration = new BindingConfiguration(bindingStorage.OrganizationalUnitRoot.ObjectGuid, bindingStorage.Id.ObjectGuid);

            UnifiedPolicyStorageFactory.CopyPropertiesFromStorage <BindingConfiguration>(bindingConfiguration, new TenantSettingFacade <BindingStorage>(bindingStorage));
            if (bindingStorage.AppliedScopes.Any <ScopeStorage>() || bindingStorage.RemovedScopes.Any <ScopeStorage>())
            {
                bindingConfiguration.AppliedScopes = new IncrementalCollection <ScopeConfiguration>(from s in bindingStorage.AppliedScopes
                                                                                                    select UnifiedPolicyStorageFactory.FromScopeStorage(s), bindingStorage.RemovedScopes.Select((ScopeStorage s) => UnifiedPolicyStorageFactory.FromScopeStorage(s)));
            }
            else
            {
                bindingConfiguration.AppliedScopes = new IncrementalCollection <ScopeConfiguration>();
            }
            return(bindingConfiguration);
        }
예제 #18
0
            public async void ViewDidAppear(bool animated)
            {
                await Task.Yield();

                if (SetContextOrder == UpdateOrder.AfterAppear)
                {
                    BindingStorage.SetContext(owner, ViewModel);
                }

                await ViewModel.ReloadDataAsync();

                if (SetContextOrder == UpdateOrder.AfterReload)
                {
                    BindingStorage.SetContext(owner, ViewModel);
                }
            }
        private Dictionary <Workload, List <ChangeNotificationData> > GenerateSyncsForFailedBindings()
        {
            Dictionary <Workload, List <ChangeNotificationData> > dictionary = new Dictionary <Workload, List <ChangeNotificationData> >();

            using (IEnumerator <BindingStorage> enumerator = this.PsPolicyPresentationObject.StorageBindings.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BindingStorage bindingStorage = enumerator.Current;
                    IEnumerable <UnifiedPolicySettingStatus> source = PolicySettingStatusHelpers.LoadSyncStatuses(base.DataSession, Utils.GetUniversalIdentity(bindingStorage), typeof(BindingStorage).Name);
                    bool flag = false;
                    if (source.Any((UnifiedPolicySettingStatus s) => SetCompliancePolicyBase.HasDistributionFailed(bindingStorage, s)))
                    {
                        flag = true;
                        bindingStorage.PolicyVersion = CombGuidGenerator.NewGuid();
                        if (!dictionary.ContainsKey(bindingStorage.Workload))
                        {
                            dictionary[bindingStorage.Workload] = new List <ChangeNotificationData>();
                        }
                        dictionary[bindingStorage.Workload].Add(AggregatedNotificationClients.CreateChangeData(bindingStorage.Workload, bindingStorage));
                    }
                    List <ChangeNotificationData> list = this.GenerateSyncsForFailedScopes(bindingStorage.AppliedScopes);
                    list.AddRange(this.GenerateSyncsForFailedScopes(bindingStorage.RemovedScopes));
                    if (list.Any <ChangeNotificationData>())
                    {
                        if (!dictionary.ContainsKey(bindingStorage.Workload))
                        {
                            dictionary[bindingStorage.Workload] = new List <ChangeNotificationData>();
                        }
                        dictionary[bindingStorage.Workload].AddRange(list);
                        if (!flag)
                        {
                            flag = true;
                            bindingStorage.PolicyVersion = CombGuidGenerator.NewGuid();
                            base.DataSession.Save(bindingStorage);
                            dictionary[bindingStorage.Workload].Add(AggregatedNotificationClients.CreateChangeData(bindingStorage.Workload, bindingStorage));
                        }
                    }
                    if (flag)
                    {
                        base.DataSession.Save(bindingStorage);
                    }
                }
            }
            return(dictionary);
        }
예제 #20
0
        internal static MultiValuedProperty <BindingMetadata> GetScopesFromStorage(BindingStorage bindingStorage)
        {
            ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
            MultiValuedProperty <BindingMetadata> multiValuedProperty = new MultiValuedProperty <BindingMetadata>();

            if (bindingStorage.AppliedScopes.Any <ScopeStorage>())
            {
                foreach (ScopeStorage scopeStorage in bindingStorage.AppliedScopes)
                {
                    if (scopeStorage.Mode == Mode.Enforce)
                    {
                        multiValuedProperty.TryAdd(BindingMetadata.FromStorage(scopeStorage.Scope));
                    }
                }
            }
            multiValuedProperty.ResetChangeTracking();
            return(multiValuedProperty);
        }
예제 #21
0
        public void SetContextTest()
        {
            var context = new TestContext <string> {
                Property = contextInitial
            };
            var view = new TestView <string> {
                Value = viewInitial
            };

            view.Bind(view)
            .ViewProperty(v => v.Value)
            .To <TestContext <string> >(ctx => ctx.Property);

            BindingStorage.SetContext(view, context);

            Assert.AreEqual(contextInitial, context.Property);
            Assert.AreEqual(contextInitial, view.Value);
        }
예제 #22
0
        private void UpdateWorkloadStorageBinding(Guid universalIdentity, Workload workload, MultiValuedProperty <BindingMetadata> scopes, Exception mulipleStorageObjectsException)
        {
            ExAssert.RetailAssert(workload != Workload.SharePoint, "UpdateWorkloadBinding called for Sharepoint workload.");
            if (this.StorageBindings.Count((BindingStorage x) => x.Workload == workload) > 1)
            {
                throw mulipleStorageObjectsException;
            }
            BindingStorage bindingStorage = this.StorageBindings.FirstOrDefault((BindingStorage x) => x.Workload == workload);

            if (bindingStorage == null && scopes.Any <BindingMetadata>())
            {
                bindingStorage = Utils.CreateNewBindingStorage(base.OrganizationalUnitRoot, workload, universalIdentity);
                this.StorageBindings.Add(bindingStorage);
            }
            if (bindingStorage != null)
            {
                Utils.PopulateScopeStorages(bindingStorage, scopes);
            }
        }
        private void SaveBindingStorage(BindingStorage bindingInstance)
        {
            BindingStorage existingStorage = this.FindBindingStorage(QueryFilter.AndTogether(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, base.TenantId),
                new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, bindingInstance.Id.ObjectGuid)
            }), null, false, null, int.MaxValue, true).Cast <BindingStorage>().FirstOrDefault <BindingStorage>();

            if (existingStorage == null)
            {
                using (MultiValuedProperty <ScopeStorage> .Enumerator enumerator = bindingInstance.AppliedScopes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ScopeStorage scopeStorage = enumerator.Current;
                        scopeStorage[UnifiedPolicyStorageBaseSchema.ContainerProp] = bindingInstance.Id.ObjectGuid.ToString();
                        scopeStorage[UnifiedPolicyStorageBaseSchema.WorkloadProp]  = bindingInstance.Workload;
                        ((IConfigDataProvider)this).Save(scopeStorage);
                    }
                    goto IL_20A;
                }
            }
            IEnumerable <ScopeStorage> enumerable = from s in bindingInstance.AppliedScopes
                                                    where !existingStorage.AppliedScopes.Any((ScopeStorage e) => e.Id.ObjectGuid == s.Id.ObjectGuid) || bindingInstance.AppliedScopes.Any((ScopeStorage e) => e.Id.ObjectGuid == s.Id.ObjectGuid && s.GetChangedPropertyDefinitions().Any <PropertyDefinition>())
                                                    select s;
            IEnumerable <ScopeStorage> enumerable2 = from e in existingStorage.AppliedScopes
                                                     where !bindingInstance.AppliedScopes.Any((ScopeStorage n) => n.Id.ObjectGuid == e.Id.ObjectGuid)
                                                     select e;

            foreach (ScopeStorage instance in enumerable2)
            {
                ((IConfigDataProvider)this).Delete(instance);
            }
            foreach (ScopeStorage scopeStorage2 in enumerable)
            {
                scopeStorage2[UnifiedPolicyStorageBaseSchema.ContainerProp] = bindingInstance.Id.ObjectGuid.ToString();
                scopeStorage2[UnifiedPolicyStorageBaseSchema.WorkloadProp]  = bindingInstance.Workload;
                ((IConfigDataProvider)this).Save(scopeStorage2);
            }
IL_20A:
            bindingInstance[UnifiedPolicyStorageBaseSchema.ContainerProp] = bindingInstance.PolicyId.ToString();
            ((IConfigDataProvider)this).Save(bindingInstance);
        }
예제 #24
0
        public void BindingConverterFullFlowTest()
        {
            var viewInitialLocal    = "100";
            var contextInitialLocal = 200;
            var viewUpdatedLocal    = "300";
            var contextUpdatedLocal = 400;

            var context = new TestContext <int> {
                Property = contextInitialLocal
            };
            var view = new TestView <string> {
                Value = viewInitialLocal
            };

            // set binding => nothing should be cnahged
            view.Bind(view)
            .ViewProperty(v => v.Value)
            .ViewEvent(nameof(view.ValueChanged))
            .Converter(Converters.IntString)
            .To <TestContext <int> >(ctx => ctx.Property);

            Assert.AreEqual(contextInitialLocal, context.Property);
            Assert.AreEqual(viewInitialLocal, view.Value);

            // set context => view should be updated
            BindingStorage.SetContext(view, context);

            Assert.AreEqual(contextInitialLocal, context.Property);
            Assert.AreEqual(Converters.IntString.Convert(contextInitialLocal), view.Value);

            // view updated > context shold be updated
            view.Value = viewUpdatedLocal;

            Assert.AreEqual(Converters.IntString.ConvertBack(viewUpdatedLocal), context.Property);
            Assert.AreEqual(viewUpdatedLocal, view.Value);

            // context update => view should be updated
            context.Property = contextUpdatedLocal;

            Assert.AreEqual(contextUpdatedLocal, context.Property);
            Assert.AreEqual(Converters.IntString.Convert(contextUpdatedLocal), view.Value);
        }
예제 #25
0
        private PolicyChangeBatch GetBindingChanges(TenantCookieCollection tenantCookies)
        {
            IConfigDataProvider   configDataProvider = ConfigDataProviderFactory.Default.Create(DatabaseType.Directory);
            PolicyChangeBatch     newBatch           = UnifiedPolicySession.GetNewBatch <BindingConfiguration>(tenantCookies);
            List <BindingStorage> list  = new List <BindingStorage>();
            List <ScopeStorage>   list2 = new List <ScopeStorage>();

            new List <BindingConfiguration>();
            foreach (TenantCookie tenantCookie in ((IEnumerable <TenantCookie>)tenantCookies))
            {
                PolicySyncCookie policySyncCookie = PolicySyncCookie.Deserialize(tenantCookie.Cookie);
                string           pagingWatermark  = UnifiedPolicySession.GetPagingWatermark <BindingConfiguration>(policySyncCookie);
                string           pagingWatermark2 = UnifiedPolicySession.GetPagingWatermark <ScopeConfiguration>(policySyncCookie);
                QueryFilter      queryFilter      = UnifiedPolicySession.CreateGetChangesQueryFilter(tenantCookie, pagingWatermark, tenantCookies.Workload, true);
                QueryFilter      queryFilter2     = UnifiedPolicySession.CreateGetChangesQueryFilter(tenantCookie, pagingWatermark2, tenantCookies.Workload, true);
                list.AddRange(configDataProvider.FindPaged <BindingStorage>(queryFilter, null, false, null, 1000).Cast <BindingStorage>());
                list2.AddRange(configDataProvider.FindPaged <ScopeStorage>(queryFilter2, null, false, null, 1000).Cast <ScopeStorage>());
                bool flag;
                UnifiedPolicySession.SetPagingWatermark <BindingConfiguration>(policySyncCookie, PagingHelper.GetProcessedCookie(queryFilter, out flag));
                bool flag2;
                UnifiedPolicySession.SetPagingWatermark <ScopeConfiguration>(policySyncCookie, PagingHelper.GetProcessedCookie(queryFilter2, out flag2));
                TenantCookie tenantCookie2 = newBatch.NewCookies[tenantCookie.TenantId];
                tenantCookie2.Cookie   = policySyncCookie.Serialize();
                tenantCookie2.MoreData = (!flag || !flag2);
            }
            using (List <ScopeStorage> .Enumerator enumerator2 = list2.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    UnifiedPolicySession.< > c__DisplayClass19 CS$ < > 8__locals1 = new UnifiedPolicySession.< > c__DisplayClass19();
                    CS$ < > 8__locals1.scope = enumerator2.Current;
                    Guid           parentBindingId = Guid.Parse((string)CS$ < > 8__locals1.scope[UnifiedPolicyStorageBaseSchema.ContainerProp]);
                    BindingStorage bindingStorage  = list.FirstOrDefault((BindingStorage b) => b.Id.ObjectGuid == parentBindingId && b.OrganizationalUnitRoot.ObjectGuid == CS$ < > 8__locals1.scope.OrganizationalUnitRoot.ObjectGuid);
                    if (bindingStorage == null)
                    {
                        bindingStorage = configDataProvider.Find <BindingStorage>(UnifiedPolicySession.CreateGetObjectQueryFilter(CS$ < > 8__locals1.scope.OrganizationalUnitRoot.ObjectGuid, parentBindingId, true), null, false, null).Cast <BindingStorage>().FirstOrDefault <BindingStorage>();
                        list.Add(bindingStorage);
                    }
                    if (CS$ < > 8__locals1.scope.ObjectState == ObjectState.Deleted)
                    {
                        bindingStorage.RemovedScopes.Add(CS$ < > 8__locals1.scope);
                    }
예제 #26
0
        private static void SetTextFieldInnerBindings(UITextField textField)
        {
            var valueChangedBinding = Binding <UITextField, IInpuntViewModel <string>, string> .TwoWay(
                nameof(IInpuntViewModel <string> .View),
                inputViewModel => inputViewModel.View,
                (field, text) => field.Text = text,
                (inputViewModel, text) => inputViewModel.EditValueAndUpdateModel(text),
                field => field.Text,
                typeof(UITextField).GetRuntimeEvent(nameof(UITextField.EditingChanged))
                );

            var endEditingBinding = Binding <UITextField, IInpuntViewModel <string>, string> .OneWayToSource(
                (inputViewModel, text) => inputViewModel.EditValueAndUpdateModel(text),
                field => field.Text,
                typeof(UITextField).GetRuntimeEvent(nameof(UITextField.EditingDidEnd))
                );

            BindingStorage.SetBinding(textField, textField, valueChangedBinding);
            BindingStorage.SetBinding(textField, textField, endEditingBinding);
        }
        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);
        }
예제 #28
0
        public void AddElement(BindingStorage model)
        {
            int maxId = 0;

            for (int i = 0; i < source.Storages.Count; ++i)
            {
                if (source.Storages[i].Id > maxId)
                {
                    maxId = source.Storages[i].Id;
                }
                if (source.Storages[i].StorageName == model.StorageName)
                {
                    throw new Exception("Уже есть склад с таким названием" + source.Storages[i].StorageName);
                }
            }
            source.Storages.Add(new Storage
            {
                Id          = maxId + 1,
                StorageName = model.StorageName
            });
        }
예제 #29
0
        public void UpdElement(BindingStorage model)
        {
            int index = -1;

            for (int i = 0; i < source.Storages.Count; ++i)
            {
                if (source.Storages[i].Id == model.Id)
                {
                    index = i;
                }
                if (source.Storages[i].StorageName == model.StorageName &&
                    source.Storages[i].Id != model.Id)
                {
                    throw new Exception("Уже есть склад с таким названием");
                }
            }
            if (index == -1)
            {
                throw new Exception("Элемент не найден");
            }
            source.Storages[index].StorageName = model.StorageName;
        }
예제 #30
0
 internal static void PopulateScopeStorages(BindingStorage bindingStorage, MultiValuedProperty <BindingMetadata> scopes)
 {
     ArgumentValidator.ThrowIfNull("bindingStorage", bindingStorage);
     ArgumentValidator.ThrowIfNull("scopes", scopes);
     if (scopes.Changed)
     {
         object[] removed = scopes.Removed;
         for (int i = 0; i < removed.Length; i++)
         {
             BindingMetadata removedScope = (BindingMetadata)removed[i];
             ScopeStorage    scopeStorage = bindingStorage.AppliedScopes.Find((ScopeStorage item) => string.Equals(BindingMetadata.FromStorage(item.Scope).ImmutableIdentity, removedScope.ImmutableIdentity, StringComparison.OrdinalIgnoreCase));
             scopeStorage.Mode          = Mode.PendingDeletion;
             scopeStorage.PolicyVersion = CombGuidGenerator.NewGuid();
         }
         object[] added = scopes.Added;
         for (int j = 0; j < added.Length; j++)
         {
             BindingMetadata addedScope    = (BindingMetadata)added[j];
             ScopeStorage    scopeStorage2 = bindingStorage.AppliedScopes.Find((ScopeStorage item) => string.Equals(BindingMetadata.FromStorage(item.Scope).ImmutableIdentity, addedScope.ImmutableIdentity, StringComparison.OrdinalIgnoreCase));
             if (scopeStorage2 == null)
             {
                 Guid objectGuid = Guid.NewGuid();
                 scopeStorage2 = new ScopeStorage();
                 scopeStorage2[ADObjectSchema.OrganizationalUnitRoot] = bindingStorage.OrganizationalUnitRoot;
                 scopeStorage2.Name = objectGuid.ToString();
                 scopeStorage2.SetId(new ADObjectId(PolicyStorage.PoliciesContainer.GetChildId(scopeStorage2.Name).DistinguishedName, objectGuid));
                 bindingStorage.AppliedScopes.Add(scopeStorage2);
             }
             scopeStorage2.Mode          = Mode.Enforce;
             scopeStorage2.Scope         = BindingMetadata.ToStorage(addedScope);
             scopeStorage2.PolicyVersion = CombGuidGenerator.NewGuid();
         }
         bindingStorage.PolicyVersion = CombGuidGenerator.NewGuid();
         scopes.ResetChangeTracking();
     }
 }