private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            IPageTypeMetaDataTypeLink pageTypeMetaDataTypeLink = DataFacade.BuildNew<IPageTypeMetaDataTypeLink>();
            pageTypeMetaDataTypeLink.Id = Guid.NewGuid();

            Dictionary<string, string> piggybag = PiggybagSerializer.Deserialize(this.ExtraPayload);

            DataEntityToken dataEntityToken = piggybag.GetParentEntityTokens().FindDataEntityToken(typeof(IPageType));
            IPageType parentPageType = (IPageType)dataEntityToken.Data;

            pageTypeMetaDataTypeLink.PageTypeId = parentPageType.Id;

            this.Bindings.Add("CompositionDescriptionName", "");
            this.Bindings.Add("CompositionDescriptionLabel", "");

            this.Bindings.Add("NewMetaDataTypeLink", pageTypeMetaDataTypeLink);

            List<KeyValuePair<Guid, string>> metaDataTypeOptions =
                PageMetaDataFacade.GetAllMetaDataTypes().
                ToList(f => new KeyValuePair<Guid, string>(f.GetImmutableTypeId(), f.GetTypeTitle()));

            this.Bindings.Add("MetaDataTypeOptions", metaDataTypeOptions);

            List<KeyValuePair<Guid, string>> metaDataContainerOptions = PageMetaDataFacade.GetAllMetaDataContainers();

            this.Bindings.Add("MetaDataContainerOptions", metaDataContainerOptions);
            this.Bindings.Add("CompositionContainerId", metaDataContainerOptions.First().Key);

            this.BindingsValidationRules.Add("CompositionDescriptionName", new List<ClientValidationRule> { new NotNullClientValidationRule(), new StringLengthClientValidationRule(1, 128) });
            this.BindingsValidationRules.Add("CompositionDescriptionLabel", new List<ClientValidationRule> { new NotNullClientValidationRule(), new StringLengthClientValidationRule(1, 256) });
        }
        private void editDefinitionCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            Pair <string, Type>     metaDataPair           = this.GetBinding <Pair <string, Type> >("SelectedMetaDataDefinition");
            IPageMetaDataDefinition pageMetaDataDefinition = PageMetaDataFacade.GetMetaDataDefinition(GetCurrentPageId(), metaDataPair.First);

            this.UpdateBinding("Label", pageMetaDataDefinition.Label);

            List <KeyValuePair <Guid, string> > containers = PageMetaDataFacade.GetAllMetaDataContainers();

            this.UpdateBinding("MetaDataContainerOptions", containers);
            this.UpdateBinding("SelectedMetaDataContainer", pageMetaDataDefinition.MetaDataContainerId);

            IPage page = GetCurrentPage();

            Dictionary <int, string> startDisplayOptions = new Dictionary <int, string>();

            if (page != null)
            {
                startDisplayOptions.Add(0, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption0"));
            }
            startDisplayOptions.Add(1, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption1"));
            startDisplayOptions.Add(2, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption2"));
            startDisplayOptions.Add(3, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption3"));
            startDisplayOptions.Add(4, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption4"));
            startDisplayOptions.Add(5, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption5"));
            this.UpdateBinding("StartDisplayOptions", startDisplayOptions);
            this.UpdateBinding("SelectedStartDisplay", pageMetaDataDefinition.StartLevel);

            int levels = pageMetaDataDefinition.Levels;

            if (levels > 10)
            {
                levels = 10000;
            }

            Dictionary <int, string> inheritDisplayOptions = new Dictionary <int, string>();

            inheritDisplayOptions.Add(0, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption0"));
            inheritDisplayOptions.Add(1, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption1"));
            inheritDisplayOptions.Add(2, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption2"));
            inheritDisplayOptions.Add(3, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption3"));
            inheritDisplayOptions.Add(10000, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption4"));
            this.UpdateBinding("InheritDisplayOptions", inheritDisplayOptions);
            this.UpdateBinding("SelectedInheritDisplay", levels);
        }
        private void createFieldGroupCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e)
        {
            Type type = this.GetBinding <Type>(SelectedTypeBindingName);

            string metaDataDefinitionName = type.GetTypeTitle();
            int    counter = 1;

            while (PageMetaDataFacade.IsDefinitionAllowed(GetCurrentPageId(), metaDataDefinitionName, metaDataDefinitionName, type.GetImmutableTypeId()) == false)
            {
                metaDataDefinitionName = string.Format("{0} {1}", type.GetTypeTitle(), counter++);
            }

            this.UpdateBinding(FieldGroupNameBindingName, metaDataDefinitionName);
            this.UpdateBinding(FieldGroupLabelBindingName, metaDataDefinitionName);


            if (this.BindingExist(ContainersBindingName) == false)
            {
                List <KeyValuePair <Guid, string> > containers = PageMetaDataFacade.GetAllMetaDataContainers();
                this.UpdateBinding(ContainersBindingName, containers);
                this.UpdateBinding(SelectedContainerBindingName, containers.First().Key);

                Dictionary <int, string> startDisplayOptions = new Dictionary <int, string>();
                if (GetCurrentPage() != null)
                {
                    startDisplayOptions.Add(0, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption0"));
                }
                startDisplayOptions.Add(1, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption1"));
                startDisplayOptions.Add(2, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption2"));
                startDisplayOptions.Add(3, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption3"));
                startDisplayOptions.Add(4, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption4"));
                startDisplayOptions.Add(5, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.StartDisplayOption5"));
                this.UpdateBinding(StartDisplayOptionsBindingName, startDisplayOptions);
                this.UpdateBinding(SelectedStartDisplayBindingName, startDisplayOptions.Keys.First());

                Dictionary <int, string> inheritDisplayOptions = new Dictionary <int, string>();
                inheritDisplayOptions.Add(0, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption0"));
                inheritDisplayOptions.Add(1, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption1"));
                inheritDisplayOptions.Add(2, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption2"));
                inheritDisplayOptions.Add(3, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption3"));
                inheritDisplayOptions.Add(10000, StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataWorkflow.InheritDisplayOption4"));
                this.UpdateBinding(InheritDisplayOptionsBindingName, inheritDisplayOptions);
                this.UpdateBinding(SelectedInheritDisplayBindingName, inheritDisplayOptions.Keys.Last());
            }
        }
        private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            IPageTypeMetaDataTypeLink pageTypeMetaDataTypeLink = this.GetDataItemFromEntityToken <IPageTypeMetaDataTypeLink>();

            IPageMetaDataDefinition pageMetaDataDefinition = PageMetaDataFacade.GetMetaDataDefinition(pageTypeMetaDataTypeLink.PageTypeId, pageTypeMetaDataTypeLink.Name);

            //this.UpdateBinding("CompositionDescriptionName", compositionDescription.Name);
            this.UpdateBinding("CompositionDescriptionLabel", pageMetaDataDefinition.Label);

            List <KeyValuePair <Guid, string> > metaDataContainerOptions = PageMetaDataFacade.GetAllMetaDataContainers();

            this.Bindings.Add("MetaDataContainerOptions", metaDataContainerOptions);
            this.Bindings.Add("CompositionContainerId", pageMetaDataDefinition.MetaDataContainerId);

            var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(pageTypeMetaDataTypeLink.DataTypeId);

            this.Bindings.Add("MetaTypeName", dataTypeDescriptor.TypeManagerTypeName);
        }