Пример #1
0
        public override bool ShouldUpdatePropertyGrids(DesignerPropertyInfo property)
        {
            DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
            DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");

            return(property.Property == oplProp.Property || property.Property == operatorProp.Property);
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if the DesignerInfoPropertySet doesn't exist then we need to create it.
            if (_designerInfo.PropertySet == null)
            {
                _designerInfo.PropertySet = new DesignerInfoPropertySet(_designerInfo, null);
            }

            // if the DesignerProperty doesn't exist then we need to create it.
            DesignerProperty designerProperty;
            if (!_designerInfo.PropertySet.TryGetDesignerProperty(_name, out designerProperty))
            {
                designerProperty = new DesignerProperty(_designerInfo.PropertySet, null);
                designerProperty.LocalName.Value = _name;
                _designerInfo.PropertySet.AddDesignerProperty(_name, designerProperty);
            }

            // First let's check make sure any non-valid values are caught up the stack
            if (!designerProperty.ValueAttr.IsValidValue(_value))
            {
                throw new CommandValidationFailedException(
                    String.Format(CultureInfo.CurrentCulture, Resources.NonValidDesignerProperty, _value, _name));
            }

            // now we update the value of the designer property
            var cmdUpdateDefaultableValue = new UpdateDefaultableValueCommand<string>(designerProperty.ValueAttr, _value);
            CommandProcessor.InvokeSingleCommand(cpc, cmdUpdateDefaultableValue);

            // normalize and resolve the entire DesignerInfo
            XmlModelHelper.NormalizeAndResolve(_designerInfo);
        }
Пример #3
0
            public Param(string category, ParameterInfo pi, object v, string nativeType, string displayName, string description, float rangeMin, float rangeMax)
            {
                _paramInfo   = pi;
                _value       = v;
                _nativeType  = nativeType;
                _displayName = displayName;
                _description = description;

                if (_paramInfo != null)
                {
                    DesignerProperty attr = null;

                    DesignerProperty[] attributes = (DesignerProperty[])_paramInfo.GetCustomAttributes(typeof(DesignerProperty), false);
                    if (attributes.Length > 0)
                    {
                        attr = attributes[0];
                    }

                    if (attr != null)
                    {
                        _attribute = attr;
                    }
                    else if (_paramInfo.ParameterType.IsEnum)
                    {
                        _attribute = new DesignerEnum(_paramInfo.Name, "", category, DesignerProperty.DisplayMode.Parameter, 0, DesignerProperty.DesignerFlags.NoFlags, "");
                    }
                    else
                    {
                        _attribute = Plugin.InvokeTypeCreateDesignerProperty(category, _paramInfo.Name, _paramInfo.ParameterType, rangeMin, rangeMax);
                    }
                }
            }
        public void ShouldValidateArtifactDuringBuild_returns_true_if_designer_info_option_does_not_contain_ValidateOnBuild_value()
        {
            var modelManager             = new Mock <ModelManager>(null, null).Object;
            var modelProvider            = new Mock <XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock <EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                using (var designerProperty = new DesignerProperty(null, new XElement("_")))
                {
                    var optionsDesignerInfoMock = new Mock <OptionsDesignerInfo>(designerInfoRoot, new XElement("_"));
                    optionsDesignerInfoMock
                    .Setup(o => o.ValidateOnBuild)
                    .Returns(designerProperty);

                    designerInfoRoot
                    .AddDesignerInfo(
                        "Options",
                        optionsDesignerInfoMock.Object);

                    entityDesignArtifactMock
                    .Setup(a => a.DesignerInfo)
                    .Returns(designerInfoRoot);

                    Assert.True(
                        EdmUpdateSolutionEvents.ShouldValidateArtifactDuringBuild(entityDesignArtifactMock.Object));
                }
            }
        }
Пример #5
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if the DesignerInfoPropertySet doesn't exist then we need to create it.
            if (_designerInfo.PropertySet == null)
            {
                _designerInfo.PropertySet = new DesignerInfoPropertySet(_designerInfo, null);
            }

            // if the DesignerProperty doesn't exist then we need to create it.
            DesignerProperty designerProperty;

            if (!_designerInfo.PropertySet.TryGetDesignerProperty(_name, out designerProperty))
            {
                designerProperty = new DesignerProperty(_designerInfo.PropertySet, null);
                designerProperty.LocalName.Value = _name;
                _designerInfo.PropertySet.AddDesignerProperty(_name, designerProperty);
            }

            // First let's check make sure any non-valid values are caught up the stack
            if (!designerProperty.ValueAttr.IsValidValue(_value))
            {
                throw new CommandValidationFailedException(
                          String.Format(CultureInfo.CurrentCulture, Resources.NonValidDesignerProperty, _value, _name));
            }

            // now we update the value of the designer property
            var cmdUpdateDefaultableValue = new UpdateDefaultableValueCommand <string>(designerProperty.ValueAttr, _value);

            CommandProcessor.InvokeSingleCommand(cpc, cmdUpdateDefaultableValue);

            // normalize and resolve the entire DesignerInfo
            XmlModelHelper.NormalizeAndResolve(_designerInfo);
        }
 /// <summary>
 /// Creates a new subitem which can show a property on the node.
 /// </summary>
 /// <param name="owner">The node whose property we want to show. MUST be the same as the one the subitem belongs to.</param>
 /// <param name="property">The property we want to show.</param>
 /// <param name="att">The attribute associated with the property.</param>
 public SubItemProperty(Node owner, PropertyInfo property, DesignerProperty att)
     : base(null, null, __font, Brushes.White, Alignment.Center, false)
 {
     _owner     = owner;
     _property  = property;
     _attribute = att;
 }
Пример #7
0
        public List <Param> GetParams(DesignerStructPropertyInfo structParam)
        {
            if (_structParams.ContainsKey(structParam.Name))
            {
                List <Param> ps = _structParams[structParam.Name].GetParams(structParam.ElmentIndexInArray);
                if (ps != null)
                {
                    return(ps);
                }
            }
            else
            {
                if (structParam.ElmentIndexInArray == -1)
                {
                    _structParams[structParam.Name] = new StructParam_t();
                }
                else
                {
                    _structParams[structParam.Name] = new StructArrayParam_t();
                }
            }

            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(structParam.Type, DesignerProperty.SortByDisplayOrder);

            foreach (DesignerPropertyInfo property in properties)
            {
                Param v = new Param(property, structParam.Owner);
                _structParams[structParam.Name].AddParam(structParam.ElmentIndexInArray, v);
            }

            return(_structParams[structParam.Name].GetParams(structParam.ElmentIndexInArray));
        }
Пример #8
0
        public static void PostGenerateCode(object obj, StreamWriter stream, string indent, string var, object parent, string paramName)
        {
            Debug.Check(obj != null);

            Type type = obj.GetType();

            Debug.Check(Plugin.IsCustomClassType(type));

            MethodDef method = parent as MethodDef;
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type);

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    object member = property.GetValue(obj);
                    if (property.Attribute is DesignerStruct)
                    {
                        PostGenerateCode(member, stream, indent, var + "." + property.Property.Name, parent, paramName);
                    }
                    else
                    {
                        if (method != null)
                        {
                            MethodDef.Param param = method.GetParam(paramName, property);
                            if (param != null)
                            {
                                string nativeType = DataCppExporter.GetBasicGeneratedNativeType(param.NativeType);
                                ParameterCppExporter.PostGenerateCode(param, stream, indent, nativeType, var + "." + property.Property.Name, string.Empty, method);
                            }
                        }
                    }
                }
            }
        }
        public void ShouldValidateArtifactDuringBuild_returns_true_if_designer_info_option_does_not_contain_ValidateOnBuild_value()
        {
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                using (var designerProperty = new DesignerProperty(null, new XElement("_")))
                {
                    var optionsDesignerInfoMock = new Mock<OptionsDesignerInfo>(designerInfoRoot, new XElement("_"));
                    optionsDesignerInfoMock
                        .Setup(o => o.ValidateOnBuild)
                        .Returns(designerProperty);

                    designerInfoRoot
                        .AddDesignerInfo(
                            "Options",
                            optionsDesignerInfoMock.Object);

                    entityDesignArtifactMock
                        .Setup(a => a.DesignerInfo)
                        .Returns(designerInfoRoot);

                    Assert.True(
                        EdmUpdateSolutionEvents.ShouldValidateArtifactDuringBuild(entityDesignArtifactMock.Object));
                }
            }
        }
Пример #10
0
        private DesignerInfo SetupOptionsDesignerInfo(string designerPropertyName, string designerPropertyValue)
        {
            var designerInfo =
                new OptionsDesignerInfo(
                    null,
                    XElement.Parse(
                        "<Options xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));
            var designerInfoPropertySet =
                new DesignerInfoPropertySet(
                    designerInfo,
                    XElement.Parse(
                        "<DesignerInfoPropertySet xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));

            if (designerPropertyName != null)
            {
                var designerProperty =
                    new DesignerProperty(
                        designerInfoPropertySet,
                        XElement.Parse(
                            "<DesignerProperty Name='" + designerPropertyName + "' Value='" +
                            designerPropertyValue +
                            "' xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));
                designerInfoPropertySet.AddDesignerProperty(designerPropertyName, designerProperty);
            }

            designerInfo.PropertySet = designerInfoPropertySet;
            return(designerInfo);
        }
Пример #11
0
        public static void GenerateCode(object obj, StreamWriter stream, string indent, string var, object parent, string paramName)
        {
            Debug.Check(obj != null);

            Type type = obj.GetType();

            Debug.Check(Plugin.IsCustomClassType(type));

            MethodDef method = parent as MethodDef;
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type);

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    object member = property.GetValue(obj);

                    Type memberType = member.GetType();

                    if (Plugin.IsArrayType(memberType))
                    {
                        string memberNativeType = Plugin.GetNativeTypeName(memberType);
                        string nativeTypeStr    = DataCppExporter.GetGeneratedNativeType(memberNativeType);
                        int    startIndex       = nativeTypeStr.IndexOf('<');
                        int    endIndex         = nativeTypeStr.LastIndexOf('>');
                        string itemType         = nativeTypeStr.Substring(startIndex + 1, endIndex - startIndex - 1);

                        ArrayCppExporter.GenerateCode(member, stream, indent, itemType, paramName);
                    }
                    else
                    {
                        if (property.Attribute is DesignerStruct)
                        {
                            GenerateCode(member, stream, indent, var + "." + property.Property.Name, parent, paramName);
                        }
                        else
                        {
                            bool bStructProperty = false;
                            if (method != null)
                            {
                                MethodDef.Param param = method.GetParam(paramName, property);
                                if (param != null)
                                {
                                    bStructProperty = true;
                                    ParameterCppExporter.GenerateCode(param, stream, indent, string.Empty, var + "." + property.Property.Name, string.Empty);
                                }
                            }

                            if (!bStructProperty)
                            {
                                DataCppExporter.GenerateCode(member, stream, indent, string.Empty, var + "." + property.Property.Name, string.Empty);
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
 public Param(Param other)
 {
     _paramInfo   = other._paramInfo;
     _attribute   = other._attribute;
     _nativeType  = other._nativeType;
     _displayName = other._displayName;
     _description = other._description;
     _value       = Plugin.CloneValue(other._value);
 }
Пример #13
0
        protected object GetProperty(object obj, string propertyName)
        {
            if (obj != null)
            {
                DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName);
                return(propInfo.GetValue(obj));
            }

            return(null);
        }
Пример #14
0
 private static bool TryReadDesignerProperty(DesignerProperty prop, bool defaultValue)
 {
     if (prop != null &&
         prop.ValueAttr != null)
     {
         bool v;
         if (Boolean.TryParse(prop.ValueAttr.Value, out v))
         {
             return(v);
         }
     }
     return(defaultValue);
 }
Пример #15
0
 // <summary>
 //     Returns a Command to update a value of a designer property
 // </summary>
 private static void AddUpdateDesignerPropertyCommand(
     DesignerProperty property, string propertyName, bool checkBoxValue, OptionsDesignerInfo optionsDesignerInfo,
     List <Command> commands)
 {
     if (property == null ||
         property.ValueAttr == null ||
         checkBoxValue != bool.Parse(property.ValueAttr.Value))
     {
         var value = checkBoxValue ? Boolean.TrueString : Boolean.FalseString;
         var cmd   = new ChangeDesignerPropertyCommand(propertyName, value, optionsDesignerInfo);
         commands.Add(cmd);
     }
 }
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (oplProp.Property != null)
                {
                    RightValueDef rv = oplProp.GetValue(_obj) as RightValueDef;

                    if (rv != null && rv.IsMethod && rv.Method != null)
                    {
                        return(property.Property != opr1Prop.Property &&
                               property.Property != operatorProp.Property &&
                               property.Property != opr2Prop.Property);
                    }
                }

                OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

                // action
                if (this.isAction())
                {
                    return(property.Property != opr1Prop.Property &&
                           property.Property != operatorProp.Property &&
                           property.Property != opr2Prop.Property);
                }

                // assign
                else if (operatorType == OperatorTypes.Assign)
                {
                    return(property.Property != opr1Prop.Property);
                }

                // compute
                else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
                {
                }

                // compare
                else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(base.ShouldAddProperty(property));
        }
Пример #17
0
        protected bool SetProperty(object obj, string propertyName, object value)
        {
            if (obj != null)
            {
                DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName);
                if (propInfo.Property != null)
                {
                    propInfo.Property.SetValue(obj, value, null);
                    return(true);
                }
            }

            return(false);
        }
Пример #18
0
            public Param(DesignerPropertyInfo property, object obj)
            {
                _paramInfo  = null;
                _property   = property;
                _object     = obj;
                _value      = property.GetValue(obj);
                _nativeType = (_value != null) ? Plugin.GetNativeTypeName(_value.GetType()) : string.Empty;
                DesignerProperty pattr = property.Attribute;

                _displayName = pattr.DisplayName;
                _description = pattr.Description;
                _attribute   = pattr;

                _bParamFromStruct = true;
            }
Пример #19
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                if (Plugin.IsQueryFiltered)
                {
                    DesignerPropertyInfo domainsProp        = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Domains");
                    DesignerPropertyInfo descriptorRefsProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "DescriptorRefs");

                    return(property.Property != domainsProp.Property &&
                           property.Property != descriptorRefsProp.Property);
                }
            }

            return(true);
        }
Пример #20
0
        public override string GetLabel(DesignerPropertyInfo property)
        {
            OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

            // compare
            if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");
                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            return(base.GetLabel(property));
        }
Пример #21
0
        public Param GetParam(string paramName, Type strutType, object obj, DesignerPropertyInfo param)
        {
            int indexInArray = -1;

            if (!_structParams.ContainsKey(paramName))
            {
                StructParam_t ps0 = new StructParam_t();
                _structParams[paramName] = ps0;
                ps0.type = obj.GetType();

                IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(strutType, DesignerProperty.SortByDisplayOrder);
                foreach (DesignerPropertyInfo property in properties)
                {
                    object member = property.GetValue(obj);

                    Param v = new Param(property, obj);
                    _structParams[paramName].AddParam(-1, v);
                }
            }

            StructParam_t ps1 = _structParams[paramName] as StructParam_t;

            Debug.Check(ps1 != null);

            if (ps1.type == obj.GetType())
            {
                List <Param> ps = _structParams[paramName].GetParams(indexInArray);
                if (ps != null)
                {
                    foreach (Param p in ps)
                    {
                        if (p.Name == param.Property.Name && p.Type == param.Property.PropertyType)
                        {
                            return(p);
                        }
                    }
                }
                else
                {
                    Debug.Check(true);
                }
            }

            return(null);
        }
Пример #22
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                DesignerPropertyInfo binaryOperator = DesignerProperty.GetDesignerProperty(_obj.GetType(), "BinaryOperator");
                if (property.Property == binaryOperator.Property)
                {
                    Attachments.Attachment attach = _obj as Attachments.Attachment;
                    if (attach != null && attach.Node != null && attach.Node.Attachments != null &&
                        attach.Node.Attachments.Count > 0 && attach.Node.Attachments[0] == attach)
                    {
                        return(false);
                    }
                }
            }

            return(base.ShouldAddProperty(property));
        }
Пример #23
0
 private static bool GetBoolValue(DesignerProperty designerProperty, bool defaultValue)
 {
     try
     {
         var rtrn = defaultValue;
         if (designerProperty != null &&
             designerProperty.ValueAttr != null)
         {
             rtrn = bool.Parse(designerProperty.ValueAttr.Value);
         }
         return(rtrn);
     }
     catch (FormatException)
     {
         // user has manually modified edmx file to illegal value; just assume default
         return(defaultValue);
     }
 }
        public override string GetLabel(DesignerPropertyInfo property)
        {
            OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

            // action
            if (this.isAction())
            {
                DesignerPropertyInfo oplProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");

                if (property.Property == oplProp.Property)
                {
                    return(Resources.Method);
                }
            }

            // assign
            else if (operatorType == OperatorTypes.Assign)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            // compute
            else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
            {
            }

            // compare
            else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
            {
                DesignerPropertyInfo opr2Prop = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (property.Property == opr2Prop.Property)
                {
                    return(Resources.Right);
                }
            }

            return(base.GetLabel(property));
        }
Пример #25
0
        protected DesignerPropertyEditor GetEditor(object obj, string propertyName)
        {
            if (obj != null)
            {
                DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(obj.GetType(), propertyName);
                if (propInfo.Property != null)
                {
                    foreach (DesignerPropertyEditor editor in _allPropertyEditors)
                    {
                        DesignerPropertyInfo prop = editor.GetProperty();
                        if (prop.Property == propInfo.Property)
                        {
                            return(editor);
                        }
                    }
                }
            }

            return(null);
        }
Пример #26
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                OperatorTypes        operatorType = (OperatorTypes)GetProperty(_obj, "Operator");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");


                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                // compare
                if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(true);
        }
Пример #27
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                OperatorTypes operatorType = (OperatorTypes)GetProperty(_obj, "Operator");

                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                // action
                if (this.isAction())
                {
                    return(property.Property != opr1Prop.Property &&
                           property.Property != operatorProp.Property &&
                           property.Property != opr2Prop.Property);
                }

                // assign
                else if (operatorType == OperatorTypes.Assign)
                {
                    return(property.Property != opr1Prop.Property);
                }

                // compute
                else if (operatorType >= OperatorTypes.Add && operatorType <= OperatorTypes.Div)
                {
                }

                // compare
                else if (operatorType >= OperatorTypes.Equal && operatorType <= OperatorTypes.LessEqual)
                {
                    return(property.Property != opr1Prop.Property);
                }
            }

            return(true);
        }
Пример #28
0
        public override bool ShouldAddProperty(DesignerPropertyInfo property)
        {
            if (_obj != null)
            {
                DesignerPropertyInfo oplProp      = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opl");
                DesignerPropertyInfo opr1Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr1");
                DesignerPropertyInfo operatorProp = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Operator");
                DesignerPropertyInfo opr2Prop     = DesignerProperty.GetDesignerProperty(_obj.GetType(), "Opr2");

                if (oplProp.Property != null)
                {
                    RightValueDef rv = oplProp.GetValue(_obj) as RightValueDef;
                    if (rv != null && rv.IsMethod && rv.Method != null)
                    {
                        return(property.Property != opr1Prop.Property &&
                               property.Property != operatorProp.Property &&
                               property.Property != opr2Prop.Property);
                    }
                }
            }

            return(base.ShouldAddProperty(property));
        }
Пример #29
0
 /// <summary>
 /// Returns a list of all properties which have a designer attribute attached.
 /// </summary>
 /// <param name="comparison">The comparison used to sort the design properties.</param>
 /// <returns>A list of all properties relevant to the designer.</returns>
 public IList <DesignerPropertyInfo> GetDesignerProperties(Comparison <DesignerPropertyInfo> comparison)
 {
     return(DesignerProperty.GetDesignerProperties(GetType(), comparison));
 }
Пример #30
0
        private DesignerInfo SetupOptionsDesignerInfo(string designerPropertyName, string designerPropertyValue)
        {
            var designerInfo =
                new OptionsDesignerInfo(
                    null,
                    XElement.Parse(
                        "<Options xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));
            var designerInfoPropertySet =
                new DesignerInfoPropertySet(
                    designerInfo,
                    XElement.Parse(
                        "<DesignerInfoPropertySet xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));
            if (designerPropertyName != null)
            {
                var designerProperty =
                    new DesignerProperty(
                        designerInfoPropertySet,
                        XElement.Parse(
                            "<DesignerProperty Name='" + designerPropertyName + "' Value='" +
                            designerPropertyValue +
                            "' xmlns='http://schemas.microsoft.com/ado/2009/11/edmx' />"));
                designerInfoPropertySet.AddDesignerProperty(designerPropertyName, designerProperty);
            }

            designerInfo.PropertySet = designerInfoPropertySet;
            return designerInfo;
        }
 internal bool TryGetDesignerProperty(string propertyName, out DesignerProperty designerProperty)
 {
     return _designerProperties.TryGetValue(propertyName, out designerProperty);
 }
Пример #32
0
 /// <summary>
 /// Returns a list of all properties which have a designer attribute attached.
 /// </summary>
 /// <returns>A list of all properties relevant to the designer.</returns>
 public IList <DesignerPropertyInfo> GetDesignerProperties()
 {
     return(DesignerProperty.GetDesignerProperties(GetType()));
 }
 internal void AddDesignerProperty(string propertyName, DesignerProperty prop)
 {
     _designerProperties.Add(propertyName, prop);
 }
Пример #34
0
 /// <summary>
 /// Returns a list of all properties which have a designer attribute attached.
 /// </summary>
 /// <returns>A list of all properties relevant to the designer.</returns>
 public virtual IList <DesignerPropertyInfo> GetDesignerProperties(bool bCustom = false)
 {
     return(DesignerProperty.GetDesignerProperties(this.GetType()));
 }
Пример #35
0
        protected DesignerProperty SafeGetDesignerProperty(DesignerProperty designerProperty, string propertyName)
        {
            // Check if the object is already disposed, we should try to get a new value if it is true.
            if (designerProperty != null
                && designerProperty.IsDisposed)
            {
                designerProperty = null;
            }

            if (designerProperty == null
                && PropertySet != null)
            {
                PropertySet.TryGetDesignerProperty(propertyName, out designerProperty);
            }
            return designerProperty;
        }
Пример #36
0
 protected void AddDesignerProperty(string propertyName, DesignerProperty prop)
 {
     PropertySet.AddDesignerProperty(propertyName, prop);
 }
        internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem)
        {
            // we leave the parsing of properties to the subclasses of BaseDesignerModel
            if (elem.Name.LocalName == "DesignerProperty")
            {
                var propertyName = elem.Attribute(EFNameableItem.AttributeName).Value;
                // Fix for bug 390580 - only include DesignerProperty if one with that name
                // does not already exist (otherwise Dictionary throws when you attempt to add
                // it which casues VS to crash)
                if (false == _designerProperties.ContainsKey(propertyName))
                {
                    var prop = new DesignerProperty(this, elem);
                    prop.Parse(unprocessedElements);
                    AddDesignerProperty(propertyName, prop);
                }
            }
            else
            {
                return base.ParseSingleElement(unprocessedElements, elem);
            }

            return true;
        }
Пример #38
0
        //if there is a 'Predicate' attachment, convert it to a Condition node and attach it to the '_custom_condition' connector.
        private void AutoRestruct(List <Node.ErrorCheck> result, int version, Behaviac.Design.Attachments.Attachment a, Node node)
        {
            if (version <= 1)
            {
                string attachClass = a.GetType().FullName;
                if (attachClass.IndexOf("PluginBehaviac.Events.Predicate") >= 0)
                {
                    DesignerPropertyInfo propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opl");
                    RightValueDef        opl      = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Opr");
                    RightValueDef opr = propInfo.GetValue(a) as RightValueDef;
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "Operator");
                    OperatorType  oprr    = (OperatorType)propInfo.GetValue(a);
                    OperatorTypes oprType = (OperatorTypes)((int)OperatorTypes.Equal - (int)OperatorType.Equal + (int)oprr);
                    propInfo = DesignerProperty.GetDesignerProperty(a.GetType(), "BinaryOperator");
                    Behaviac.Design.Attachments.BinaryOperator binaryOpr = (Behaviac.Design.Attachments.BinaryOperator)propInfo.GetValue(a);

                    string clss      = node.GetType().FullName;
                    bool   bIsSeqSel = (node.GetType().IsSubclassOf(typeof(Sequence)) ||
                                        node.GetType().IsSubclassOf(typeof(Selector)));

                    bool bCare = (bIsSeqSel ||
                                  node.GetType().IsSubclassOf(typeof(Impulse))
                                  );

                    if (bCare ||
                        clss == "PluginBehaviac.Nodes.Query" ||
                        clss == "PluginBehaviac.Nodes.DecoratorCountLimit")
                    {
                        node.RemoveAttachment(a);
                        node.Behavior.TriggerWasModified(node);

                        Type newType = Plugin.GetType("PluginBehaviac.Nodes.Condition");

                        Behaviac.Design.Nodes.Node           newNode   = Behaviac.Design.Nodes.Node.Create(newType);
                        Behaviac.Design.Nodes.Node.Connector connector = node.GetConnector(Node.Connector.kInterupt);

                        if (connector != null && connector.Identifier == Node.Connector.kInterupt && connector.ChildCount > 0)
                        {
                            //it has multiple Predicates, so insert all of them to a newly created Sequence
                            Node oldOne = (Node)connector.GetChild(0);
                            if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                            {
                                AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                            }
                            else
                            {
                                if (bIsSeqSel)
                                {
                                    Debug.Check(oldOne.GetType().IsSubclassOf(typeof(Decorator)));
                                    Decorator d = oldOne as Decorator;
                                    node      = oldOne;
                                    connector = node.GetConnector(BaseNode.Connector.kGeneric);
                                    oldOne    = (Node)d.Children[0];
                                }

                                if (oldOne.GetType() == typeof(PluginBehaviac.Nodes.And))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.Or)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.Or");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType() == typeof(PluginBehaviac.Nodes.Or))
                                {
                                    if (binaryOpr == Behaviac.Design.Attachments.BinaryOperator.And)
                                    {
                                        node.RemoveChild(connector, oldOne);
                                        Type selType1 = Plugin.GetType("PluginBehaviac.Nodes.And");

                                        Behaviac.Design.Nodes.Node sel = Behaviac.Design.Nodes.Node.Create(selType1);
                                        sel.AddChild(BaseNode.Connector.kGeneric, oldOne);
                                        sel.AddChild(BaseNode.Connector.kGeneric, newNode);

                                        node.AddChild(BaseNode.Connector.kInterupt, sel);
                                    }
                                    else
                                    {
                                        oldOne.AddChild(BaseNode.Connector.kGeneric, newNode);
                                    }
                                }
                                else if (oldOne.GetType().IsSubclassOf(typeof(Condition)))
                                {
                                    AddAfterConditions(node, binaryOpr, newNode, connector, oldOne);
                                }
                                else
                                {
                                    Debug.Check(false);
                                }
                            }
                        }
                        else
                        {
                            //the first condition
                            Behaviac.Design.Nodes.Node notNode = null;
                            if (bIsSeqSel)
                            {
                                //for sequence/selector, it is reverted
                                Type notType = Plugin.GetType("PluginBehaviac.Nodes.DecoratorNot");

                                notNode = Behaviac.Design.Nodes.Node.Create(notType);
                                node.AddChild(BaseNode.Connector.kInterupt, notNode);
                                notNode.AddChild(BaseNode.Connector.kGeneric, newNode);
                            }
                            else
                            {
                                node.AddChild(BaseNode.Connector.kInterupt, newNode);
                            }
                        }

                        // initialise the attachments properties
                        IList <DesignerPropertyInfo> lp = newNode.GetDesignerProperties();
                        for (int p = 0; p < lp.Count; ++p)
                        {
                            if (lp[p].Property.Name == "Opl")
                            {
                                lp[p].Property.SetValue(newNode, opl, null);
                            }
                            else if (lp[p].Property.Name == "Opr")
                            {
                                lp[p].Property.SetValue(newNode, opr, null);
                            }
                            else if (lp[p].Property.Name == "Operator")
                            {
                                lp[p].Property.SetValue(newNode, oprr, null);
                            }
                        }

                        // update attacheent with attributes
                        newNode.OnPropertyValueChanged(false);
                    }
                    else if (clss == "PluginBehaviac.Nodes.Action")
                    {
                        Type newType = Plugin.GetType("PluginBehaviac.Events.Precondition");

                        Behaviac.Design.Attachments.Attachment newNode = Behaviac.Design.Attachments.Attachment.Create(newType, node);
                        node.AddAttachment(newNode);
                        node.RemoveAttachment(a);
                        node.Behavior.TriggerWasModified(node);

                        // initialise the attachments properties
                        IList <DesignerPropertyInfo> lp = newNode.GetDesignerProperties();
                        for (int p = 0; p < lp.Count; ++p)
                        {
                            if (lp[p].Property.Name == "BinaryOperator")
                            {
                                lp[p].Property.SetValue(newNode, binaryOpr, null);
                            }
                            else if (lp[p].Property.Name == "Opl")
                            {
                                lp[p].Property.SetValue(newNode, opl, null);
                            }
                            else if (lp[p].Property.Name == "Opr2")
                            {
                                lp[p].Property.SetValue(newNode, opr, null);
                            }
                            else if (lp[p].Property.Name == "Operator")
                            {
                                lp[p].Property.SetValue(newNode, oprType, null);
                            }
                            else if (lp[p].Property.Name == "IsAlive")
                            {
                                lp[p].SetValueFromString(result, newNode, "true");
                            }
                        }

                        // update attacheent with attributes
                        newNode.OnPropertyValueChanged(false);
                    }
                    else
                    {
                        Debug.Check(false);
                    }
                }
            } // if (version <= 1)
        }
 // <summary>
 //     Returns a Command to update a value of a designer property
 // </summary>
 private static void AddUpdateDesignerPropertyCommand(
     DesignerProperty property, string propertyName, bool checkBoxValue, OptionsDesignerInfo optionsDesignerInfo,
     List<Command> commands)
 {
     if (property == null
         || property.ValueAttr == null
         || checkBoxValue != bool.Parse(property.ValueAttr.Value))
     {
         var value = checkBoxValue ? Boolean.TrueString : Boolean.FalseString;
         var cmd = new ChangeDesignerPropertyCommand(propertyName, value, optionsDesignerInfo);
         commands.Add(cmd);
     }
 }