Exemplo n.º 1
0
        protected override void Process(ReferenceParserPipeline pipeline)
        {
            if (!pipeline.ReferenceText.StartsWith("{") || !pipeline.ReferenceText.EndsWith("}"))
            {
                return;
            }

            // ignore formatting specifiers: {0}, {1} etc.
            if (pipeline.ReferenceText.Length == 3 && char.IsDigit(pipeline.ReferenceText[1]))
            {
                return;
            }

            // if the reference also contains a ", it is probably a Json string
            if (pipeline.ReferenceText.IndexOf('\"') >= 0 || pipeline.ReferenceText.IndexOf('\'') >= 0 || pipeline.ReferenceText.IndexOf(':') >= 0)
            {
                return;
            }

            var sourceProperty = new SourceProperty <string>(pipeline.ProjectItem, pipeline.SourceTextNode.Key, string.Empty, SourcePropertyFlags.IsSoftGuid);

            sourceProperty.SetValue(pipeline.SourceTextNode);

            pipeline.Reference = Factory.Reference(pipeline.ProjectItem, sourceProperty, pipeline.ReferenceText, pipeline.Database.DatabaseName);
            pipeline.Abort();
        }
Exemplo n.º 2
0
        protected override void Process(ReferenceParserPipeline pipeline)
        {
            if (!pipeline.ReferenceText.StartsWith("~/"))
            {
                return;
            }

            var sourceProperty = new SourceProperty <string>(pipeline.ProjectItem, pipeline.SourceTextNode.Key, string.Empty, SourcePropertyFlags.IsFileName);

            sourceProperty.SetValue(pipeline.SourceTextNode);

            pipeline.Reference = Factory.FileReference(pipeline.ProjectItem, sourceProperty, pipeline.ReferenceText);
            pipeline.Abort();
        }
        protected override void Process(ReferenceParserPipeline pipeline)
        {
            if (!PathHelper.IsProbablyItemPath(pipeline.ReferenceText))
            {
                return;
            }

            var sourceProperty = new SourceProperty <string>(pipeline.ProjectItem, pipeline.SourceTextNode.Key, string.Empty, SourcePropertyFlags.IsQualified);

            sourceProperty.SetValue(pipeline.SourceTextNode);

            pipeline.Reference = Factory.Reference(pipeline.ProjectItem, sourceProperty, pipeline.ReferenceText, pipeline.Database.DatabaseName);
            pipeline.Abort();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the source with the current value in the target object.  Uses the ConvertBack function to convert the data if available.
        /// </summary>
        public void UpdateSource()
        {
            var value = TargetProperty.GetValue(Target, null);

            if (ConvertBack != null)
            {
                value = ConvertBack(value);
            }
            var converted = Utilities.CoerceValue(
                SourceProperty.PropertyType, TargetProperty.PropertyType, null, value);

            SourceProperty.SetValue(Source,
                                    converted,
                                    null);
        }
        protected override void Process(ReferenceParserPipeline pipeline)
        {
            Guid guid;

            if (!Guid.TryParse(pipeline.ReferenceText, out guid))
            {
                return;
            }

            var sourceProperty = new SourceProperty <string>(pipeline.ProjectItem, pipeline.SourceTextNode.Key, string.Empty, SourcePropertyFlags.IsGuid);

            sourceProperty.SetValue(pipeline.SourceTextNode);

            pipeline.Reference = Factory.Reference(pipeline.ProjectItem, sourceProperty, pipeline.ReferenceText, pipeline.Database.DatabaseName);
            pipeline.Abort();
        }
Exemplo n.º 6
0
        private void ProxyOnOnPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (SourceProperty != null && Context != null)
            {
                object value = e.NewValue;
                if (Expression.Converter != null)
                {
                    value = Expression.Converter.ConvertBack(value, SourceProperty.PropertyType, Expression.ConverterParameter, CultureInfo.CurrentUICulture);
                }

                value = ConverterHelper.ChangeType(value, SourceProperty.PropertyType);

                if (SourceProperty.CanWrite)
                {
                    SourceProperty.SetValue(Context, value);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Updates the source with the current value in the target object.  Uses the ConvertBack function to convert the data if available.
        /// </summary>
        public void UpdateSource()
        {
            if (this.BindingDirection == BindingDirection.OneWay)
            {
                return;
            }
            var value = TargetProperty.GetValue(Target, null);

            if (ConvertBack != null)
            {
                value = ConvertBack(value);
            }
            var converted = Utilities.CoerceValue(
                SourceProperty.PropertyType, TargetProperty.PropertyType, null, value);

            SourceProperty.SetValue(Source,
                                    converted,
                                    null);
        }
Exemplo n.º 8
0
        public void Update()
        {
            var value = Value;

#if DATABINDING
            var bindingExpression = BindingOperations.GetBindingExpressionsForElement(SourceObject).FirstOrDefault();
            if (bindingExpression != null)
            {
                value = bindingExpression.ConvertValue(Value);
#endif
            if (SourceProperty != null)
            {
                SourceProperty.SetValue(SourceObject, value, null);
            }
#if DATABINDING
            bindingExpression.UpdateSource();
        }
#endif
        }
Exemplo n.º 9
0
        protected virtual void ParseRenderingReferences([NotNull] ItemParseContext context, [NotNull, ItemNotNull] ICollection <IReference> references, [NotNull] IProjectItem projectItem, [NotNull] ITextNode renderingTextNode)
        {
            if (!string.IsNullOrEmpty(renderingTextNode.Key))
            {
                var sourceProperty = new SourceProperty <string>(projectItem, renderingTextNode.Key, string.Empty, SourcePropertyFlags.IsShort);
                sourceProperty.SetValue(new AttributeNameTextNode(renderingTextNode));

                references.Add(Factory.LayoutRenderingReference(projectItem, sourceProperty, string.Empty, context.ParseContext.Database.DatabaseName));
            }

            // parse references for rendering properties
            foreach (var attributeTextNode in renderingTextNode.Attributes)
            {
                foreach (var reference in ReferenceParserService.ParseReferences(projectItem, attributeTextNode))
                {
                    references.Add(reference);
                }
            }

            foreach (var childTextNode in renderingTextNode.ChildNodes)
            {
                ParseRenderingReferences(context, references, projectItem, childTextNode);
            }
        }
        protected virtual void ParseRenderingReferences([NotNull] ItemParseContext context, [NotNull] [ItemNotNull] ICollection<IReference> references, [NotNull] IProjectItem projectItem, [NotNull] ITextNode renderingTextNode)
        {
            if (!string.IsNullOrEmpty(renderingTextNode.Key))
            {
                var sourceProperty = new SourceProperty<string>(renderingTextNode.Key, string.Empty, SourcePropertyFlags.IsShort);
                sourceProperty.SetValue(new AttributeNameTextNode(renderingTextNode));

                references.Add(context.ParseContext.Factory.LayoutRenderingReference(projectItem, sourceProperty));
            }

            // parse references for rendering properties
            foreach (var attributeTextNode in renderingTextNode.Attributes)
            {
                foreach (var reference in context.ParseContext.ReferenceParser.ParseReferences(projectItem, attributeTextNode))
                {
                    references.Add(reference);
                }
            }

            foreach (var childTextNode in renderingTextNode.ChildNodes)
            {
                ParseRenderingReferences(context, references, projectItem, childTextNode);
            }
        }