Esempio n. 1
0
        protected virtual void ProcessParameterBindings(WebPartDefinitionBase definition, XDocument xml)
        {
            if (definition.ParameterBindings != null && definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                xml.SetOrUpdateProperty("ParameterBindings", parameterBindingValue);
            }
        }
Esempio n. 2
0
        protected virtual void ProcessParameterBindings(WebPart instance, WebPartDefinition definition)
        {
            var dataFomWebPart = instance as DataFormWebPart;

            if (dataFomWebPart != null &&
                definition.ParameterBindings != null &&
                definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                dataFomWebPart.ParameterBindings = parameterBindingValue;
            }
        }
Esempio n. 3
0
        protected virtual void ProcessWebpartProperties(WebPart instance, WebPartDefinition definition)
        {
            if (definition.Width.HasValue)
            {
                instance.Width = new Unit(definition.Width.Value);
            }

            if (definition.Height.HasValue)
            {
                instance.Height = new Unit(definition.Height.Value);
            }

            if (!string.IsNullOrEmpty(definition.ChromeState))
            {
                instance.ChromeState = (PartChromeState)Enum.Parse(typeof(PartChromeState), definition.ChromeState);
            }

            if (!string.IsNullOrEmpty(definition.ChromeType))
            {
                var chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
                instance.ChromeType = (PartChromeType)Enum.Parse(typeof(PartChromeType), chromeType);
            }

            if (!string.IsNullOrEmpty(definition.ImportErrorMessage))
            {
                instance.ImportErrorMessage = definition.ImportErrorMessage;
            }

            if (!string.IsNullOrEmpty(definition.Description))
            {
                instance.Description = definition.Description;
            }

            if (!string.IsNullOrEmpty(definition.TitleIconImageUrl))
            {
                instance.TitleIconImageUrl = definition.TitleIconImageUrl;
            }

            if (!string.IsNullOrEmpty(definition.TitleUrl))
            {
                instance.TitleUrl = definition.TitleUrl;
            }

            if (!string.IsNullOrEmpty(definition.ExportMode))
            {
                instance.ExportMode = (WebPartExportMode)Enum.Parse(typeof(WebPartExportMode), definition.ExportMode);
            }


            var dataFomWebPart = instance as DataFormWebPart;

            if (dataFomWebPart != null &&
                definition.ParameterBindings != null &&
                definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                dataFomWebPart.ParameterBindings = parameterBindingValue;
            }
        }
Esempio n. 4
0
        protected virtual void ProcessWebpartProperties(WebPart instance, WebPartDefinition definition)
        {
            if (definition.Width.HasValue)
            {
                instance.Width = new Unit(definition.Width.Value);
            }

            if (definition.Height.HasValue)
            {
                instance.Height = new Unit(definition.Height.Value);
            }

            if (!string.IsNullOrEmpty(definition.ChromeState))
            {
                instance.ChromeState = (PartChromeState)Enum.Parse(typeof(PartChromeState), definition.ChromeState);
            }

            if (!string.IsNullOrEmpty(definition.ChromeType))
            {
                var chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
                instance.ChromeType = (PartChromeType)Enum.Parse(typeof(PartChromeType), chromeType);
            }

            if (!string.IsNullOrEmpty(definition.ImportErrorMessage))
            {
                instance.ImportErrorMessage = definition.ImportErrorMessage;
            }

            if (!string.IsNullOrEmpty(definition.Description))
            {
                instance.Description = definition.Description;
            }

            if (!string.IsNullOrEmpty(definition.TitleIconImageUrl))
            {
                instance.TitleIconImageUrl = definition.TitleIconImageUrl;
            }

            if (!string.IsNullOrEmpty(definition.TitleUrl))
            {
                var urlValue = definition.TitleUrl ?? string.Empty;

                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original value: [{0}]",
                                           urlValue);

                urlValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                {
                    Value   = urlValue,
                    Context = CurrentHost.HostFile.Web
                }).Value;

                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced value: [{0}]", urlValue);

                instance.TitleUrl = urlValue;
            }

            if (!string.IsNullOrEmpty(definition.ExportMode))
            {
                instance.ExportMode = (WebPartExportMode)Enum.Parse(typeof(WebPartExportMode), definition.ExportMode);
            }

            var dataFomWebPart = instance as DataFormWebPart;

            if (dataFomWebPart != null &&
                definition.ParameterBindings != null &&
                definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                dataFomWebPart.ParameterBindings = parameterBindingValue;
            }
        }
Esempio n. 5
0
        protected virtual string ProcessCommonWebpartProperties(string webPartXml, WebPartDefinitionBase definition)
        {
            var xml = WebpartXmlExtensions.LoadWebpartXmlDocument(webPartXml)
                      .SetTitle(definition.Title)
                      .SetID(definition.Id);

            if (definition.Width.HasValue)
            {
                xml.SetWidth(definition.Width.Value);
            }

            if (definition.Height.HasValue)
            {
                xml.SetHeight(definition.Height.Value);
            }

            if (!string.IsNullOrEmpty(definition.Description))
            {
                xml.SetDescription(definition.Description);
            }

            if (!string.IsNullOrEmpty(definition.ImportErrorMessage))
            {
                xml.SetImportErrorMessage(definition.ImportErrorMessage);
            }

            if (!string.IsNullOrEmpty(definition.TitleUrl))
            {
                xml.SetTitleUrl(definition.TitleUrl);
            }

            if (!string.IsNullOrEmpty(definition.TitleIconImageUrl))
            {
                xml.SetTitleIconImageUrl(definition.TitleIconImageUrl);
            }

            if (!string.IsNullOrEmpty(definition.ChromeState))
            {
                xml.SetChromeState(definition.ChromeState);
            }

            if (!string.IsNullOrEmpty(definition.ChromeType))
            {
                var chromeType = string.Empty;

                if (xml.IsV3version())
                {
                    chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
                }
                else if (xml.IsV2version())
                {
                    chromeType = WebPartChromeTypesConvertService.NormilizeValueToFrameTypes(definition.ChromeType);
                }

                // SetChromeType() sets correct XML props depending on V2/V3 web part XML
                xml.SetChromeType(chromeType);
            }

            if (!string.IsNullOrEmpty(definition.ExportMode))
            {
                xml.SetExportMode(definition.ExportMode);
            }

            if (definition.ParameterBindings != null && definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                xml.SetOrUpdateProperty("ParameterBindings", parameterBindingValue);
            }

            return(xml.ToString());
        }
Esempio n. 6
0
        protected virtual string ProcessCommonWebpartProperties(string webPartXml, WebPartDefinitionBase definition)
        {
            var xml = WebpartXmlExtensions.LoadWebpartXmlDocument(webPartXml)
                      .SetTitle(definition.Title)
                      .SetID(definition.Id);

            if (definition.Width.HasValue)
            {
                xml.SetWidth(definition.Width.Value);
            }

            if (definition.Height.HasValue)
            {
                xml.SetHeight(definition.Height.Value);
            }

            if (!string.IsNullOrEmpty(definition.Description))
            {
                xml.SetDescription(definition.Description);
            }

            if (!string.IsNullOrEmpty(definition.ImportErrorMessage))
            {
                xml.SetImportErrorMessage(definition.ImportErrorMessage);
            }

            if (!string.IsNullOrEmpty(definition.TitleUrl))
            {
                var urlValue = definition.TitleUrl ?? string.Empty;

                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Original value: [{0}]", urlValue);

                urlValue = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                {
                    Value   = urlValue,
                    Context = CurrentClientContext
                }).Value;

                TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Token replaced value: [{0}]", urlValue);

                xml.SetTitleUrl(urlValue);
            }

            if (!string.IsNullOrEmpty(definition.TitleIconImageUrl))
            {
                xml.SetTitleIconImageUrl(definition.TitleIconImageUrl);
            }

            if (!string.IsNullOrEmpty(definition.ChromeState))
            {
                xml.SetChromeState(definition.ChromeState);
            }

            if (!string.IsNullOrEmpty(definition.ChromeType))
            {
                var chromeType = string.Empty;

                if (xml.IsV3version())
                {
                    chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
                }
                else if (xml.IsV2version())
                {
                    chromeType = WebPartChromeTypesConvertService.NormilizeValueToFrameTypes(definition.ChromeType);
                }

                // SetChromeType() sets correct XML props depending on V2/V3 web part XML
                xml.SetChromeType(chromeType);
            }

            if (!string.IsNullOrEmpty(definition.ExportMode))
            {
                xml.SetExportMode(definition.ExportMode);
            }

            if (definition.ParameterBindings != null && definition.ParameterBindings.Count > 0)
            {
                var parameterBinder = new WebPartParameterBindingsOptions();

                foreach (var binding in definition.ParameterBindings)
                {
                    parameterBinder.AddParameterBinding(binding.Name, binding.Location);
                }

                var parameterBindingValue = SecurityElement.Escape(parameterBinder.ParameterBinding);
                xml.SetOrUpdateProperty("ParameterBindings", parameterBindingValue);
            }

            return(xml.ToString());
        }