Ejemplo n.º 1
0
        public override void Bind(BindContext context)
        {
            if (IsBound)
            {
                return;
            }

            base.Bind(context);

            var fieldChangeAttribute = GetAttribute <FieldChangeCallbackAttribute>();

            if (fieldChangeAttribute != null)
            {
                string targetPropertyName = fieldChangeAttribute.CallbackPropertyName;

                PropertySymbol targetProperty = ContainingType.GetMember <PropertySymbol>(targetPropertyName, context);

                if (targetProperty == null)
                {
                    throw new CompilerException($"Target property '{targetPropertyName}' for FieldChangeCallback was not found");
                }

                if (targetProperty.Type != Type)
                {
                    throw new CompilerException($"Target property type '{targetProperty.Type}' did not match field type");
                }

                targetProperty.MarkFieldCallback(this);
            }
        }