Пример #1
0
        public void Attach(PropertyAttribute property)
        {
            _selectedProperty = property;

            double defaultValue = double.NaN;
            bool valueChanged = false;
            if (property.PropertyInfo.CanRead)
            {
                var propertyValue = property.PropertyInfo.GetValue(property.SelectedObject, null);
                defaultValue = (propertyValue == null) ? double.NaN : Convert.ToDouble(propertyValue, CultureInfo.InvariantCulture);
            }
            try
            {
                if (property.DefaultValue != null)
                {
                    defaultValue = Convert.ToDouble(property.DefaultValue, CultureInfo.InvariantCulture);
                    valueChanged = true;
                }
            }
            catch { }

            if (double.IsNaN(property.MinimumValue) || double.IsNaN(property.MaximumValue))
            {
                PrepareNumeric(property, defaultValue, valueChanged);
                BindingHelper.BindEditor(this._numeric, C1NumericBox.ValueProperty, _selectedProperty, null/* new NumericValueConverter()*/);
            }
            else
            {
                PrepareSlider(property, defaultValue, valueChanged);
            }

            _numeric.ValueChanged += numeric_ValueChanged;
            _slider.ValueChanged += slider_ValueChanged;
        }
Пример #2
0
 //public TypeVisualProperty()
 //{
 //}
 public TypeVisualProperty(string name, string type, PropertyAttribute attribute, PropertyCollectionType collectionType, string collectionKey)
 {
     this.name = name;
     this.type = type;
     this.attribute = attribute;
     this.collectionType = collectionType;
     this.collectionKey = collectionKey;
 }
Пример #3
0
 public void Attach(PropertyAttribute property)
 {
     // Bind Property to SelectedItem
     Binding editorBinding = new Binding(property.MemberName);
     editorBinding.Mode = BindingMode.TwoWay;
     editorBinding.Source = property.SelectedObject;
     this.SetBinding(SelectedItemProperty, editorBinding);
 }
Пример #4
0
 public void Attach(PropertyAttribute property)
 {
     var binding = new Binding(property.PropertyInfo.Name)
     {
         Mode = BindingMode.TwoWay,
         Source = property.SelectedObject,
         ValidatesOnExceptions = true
     };
     this.SetBinding(C1TimeEditor.ValueProperty, binding);
 }
Пример #5
0
 public void Attach(PropertyAttribute property)
 {
     var binding = new Binding(property.PropertyInfo.Name)
     {
         Mode = BindingMode.TwoWay,
         Source = property.SelectedObject,
         ValidatesOnExceptions = true,
         Converter = new CornerRadiusConverter()
     };
     this.SetBinding(C1TextBoxBase.C1TextProperty, binding);
 }
Пример #6
0
 private static bool IsReadOnlySource(PropertyAttribute pa)
 {
     PropertyInfo propInfo = pa.PropertyInfo;
     if (!propInfo.CanWrite)
         return true;
     Type targetType = pa.SelectedObject != null ? pa.SelectedObject.GetType() : propInfo.DeclaringType;
     DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromName(
         propInfo.Name, targetType, targetType);
     if (dpd != null)
         return dpd.IsReadOnly;
     else
         return false;
 }
Пример #7
0
        private Property( PropertyInfo info,IActor actor )
        {
            // Get all attributes we need.
            propertyInfo            = info;
            propertyAttribute       = Attribute.GetCustomAttribute(info, typeof(PropertyAttribute)) as PropertyAttribute;
            propertyDocumentation   = Attribute.GetCustomAttribute(info, typeof(DocumentationAttribute)) as DocumentationAttribute;
            propertyOwner           = actor;

            if (propertyDocumentation == null)
            {
                propertyDocumentation = new DocumentationAttribute();
            }
        }
Пример #8
0
        /// <summary>
        /// Returns the bonus to an attribute from enchantments
        /// </summary>
        public override int GetAttributeMod(PropertyAttribute attribute)
        {
            if (attributeModCache.TryGetValue(attribute, out var value))
            {
                return(value);
            }

            value = base.GetAttributeMod(attribute);

            attributeModCache[attribute] = value;

            return(value);
        }
    public static PropertyDrawer CreatePropertyDrawerInstance(PropertyAttribute propertyAttribute, FieldInfo fieldInfo, PropertyAttribute attribute)
    {
        Type drawerType     = GetDrawerTypeForType(propertyAttribute.GetType());
        var  propertyDrawer = Activator.CreateInstance(drawerType) as PropertyDrawer;

        if (propertyDrawer == null)
        {
            return(null);
        }
        typeof(PropertyDrawer).GetField("m_FieldInfo", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(propertyDrawer, fieldInfo);
        typeof(PropertyDrawer).GetField("m_Attribute", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(propertyDrawer, attribute);
        return(propertyDrawer);
    }
Пример #10
0
 public static Type GetPropertyAttribute(object[] attributes)
 {
     object[] objArray = attributes;
     for (int i = 0; i < (int)objArray.Length; i++)
     {
         PropertyAttribute propertyAttribute = objArray[i] as PropertyAttribute;
         if (propertyAttribute != null)
         {
             return(propertyAttribute.GetType());
         }
     }
     return(null);
 }
Пример #11
0
        /// <summary>
        /// Returns the bonus to an attribute from enchantments
        /// </summary>
        public int GetAttributeMod(PropertyAttribute attribute)
        {
            var enchantments = GetEnchantments(EnchantmentTypeFlags.Attribute, (uint)attribute);

            var attributeMod = 0;

            foreach (var enchantment in enchantments)
            {
                attributeMod += (int)enchantment.StatModValue;
            }

            return(attributeMod);
        }
Пример #12
0
        public void CanGenerateProperty()
        {
            Type type = Assembly.GetExecutingAssembly().GetType("Debugging.Tests.ClassWithProperties");

            PropertyInfo property = type.GetProperty("SimpleProperty");

            Assert.IsNotNull(property, "Property not generated");
            object[] propertyAttributes = property.GetCustomAttributes(typeof(PropertyAttribute), false);
            Assert.IsTrue(propertyAttributes.Length == 1, "Did not generate PropertyAttribute for property.");
            PropertyAttribute propertyAttribute = propertyAttributes[0] as PropertyAttribute;

            Assert.IsNotNull(propertyAttribute, "Did not generate PropertyAttribute for property.");
        }
Пример #13
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            _dictionary = PropertyHelper.GetObject <IEditableDictionary>(property);

            if (_dictionary == null)
            {
                Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath);
            }
            else
            {
                _dictionaryControl.Setup(property, _dictionary);

                if (attribute is DictionaryDisplayAttribute display)
                {
                    if (display.AssetType != null)
                    {
                        _dictionaryControl.MakeDrawable(ListItemDisplayType.AssetPopup, display.AssetType);
                    }
                    else if (display.ItemDisplay != ListItemDisplayType.Normal)
                    {
                        _dictionaryControl.MakeDrawable(display.ItemDisplay, null);
                    }

                    if (display.AllowAdd)
                    {
                        _dictionaryControl.MakeAddable(_addButton, display.AddLabel == null ? new GUIContent("Add Item") : (display.AddLabel == "" ? GUIContent.none : new GUIContent(display.AddLabel)));
                    }

                    if (display.AllowRemove)
                    {
                        _dictionaryControl.MakeRemovable(_removeButton);
                    }

                    if (display.AllowCollapse)
                    {
                        _dictionaryControl.MakeCollapsable(GetOpenPreference(property));
                    }

                    if (display.ShowEditButton)
                    {
                        _dictionaryControl.MakeEditable(_editButton);
                    }

                    if (display.EmptyText != null)
                    {
                        _dictionaryControl.MakeEmptyLabel(new GUIContent(display.EmptyText));
                    }
                }
            }
        }
Пример #14
0
        //public static T[] QueryWithStoredProc2(string storedProc, params object[] storedProcParameters)
        //{
        //    List<T> all = new List<T>();
        //    DataTable dt = DatabaseHandler.ExecuteStoredProc(storedProc, storedProcParameters);
        //    List<dynamic> dys = dt.AsDynamicEnumerable().ToList();
        //    foreach (dynamic dr in dys)
        //    {

        //        string columnName = dr.Username;
        //    }

        //    return all.ToArray();
        //}

        private static void CopyParentArrayToChildProperty(DataRow parent, object child)
        {
            var childProperties = child.GetType().GetProperties();



            foreach (var childProperty in childProperties)
            {
                try
                {
                    object[] attrs      = childProperty.GetCustomAttributes(false);
                    bool     hasBeenSet = false;

                    foreach (object attr in attrs)
                    {
                        PrimaryKeyAttribute pkAttribute = attr as PrimaryKeyAttribute;
                        if (pkAttribute != null)
                        {
                            string column = pkAttribute.Column;
                            if (column != null)
                            {
                                childProperty.SetValue(child, parent[column]);
                                hasBeenSet = true;
                                break;
                            }
                        }

                        PropertyAttribute propertyAttribute = attr as PropertyAttribute;
                        if (propertyAttribute != null)
                        {
                            string column = propertyAttribute.Column;
                            if (column != null)
                            {
                                childProperty.SetValue(child, parent[column]);
                                hasBeenSet = true;
                                break;
                            }
                        }
                    }
                    if (hasBeenSet)
                    {
                        continue;
                    }
                    childProperty.SetValue(child, parent[childProperty.Name]);
                }
                catch (Exception)
                {
                }
            }
        }
Пример #15
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            base.Setup(property, fieldInfo, attribute);

            if (attribute is SnapAttribute snap)
            {
                _snapValue = snap.SnapValue;
            }

            if (property.propertyType != SerializedPropertyType.Float && property.propertyType != SerializedPropertyType.Integer)
            {
                Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath);
            }
        }
Пример #16
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            base.Setup(property, fieldInfo, attribute);

            if (attribute is MinimumAttribute minimum)
            {
                _minimum = minimum.MinimumValue;
            }

            if (property.propertyType != SerializedPropertyType.Float && property.propertyType != SerializedPropertyType.Integer)
            {
                Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath);
            }
        }
        public PropertyDrawer GetPropertyDrawer(Type propertyAttributeType, params object[] arguments)
        {
            Type propertyDrawerType = GetPropertyDrawerMethod.Invoke(null, new object[] { propertyAttributeType }) as Type;

            if (propertyDrawerType != null)
            {
                PropertyAttribute propertyAttribute = Activator.CreateInstance(propertyAttributeType, arguments) as PropertyAttribute;
                PropertyDrawer    propertyDrawer    = Activator.CreateInstance(propertyDrawerType) as PropertyDrawer;
                propertyDrawer.SetValueToMember("m_Attribute", propertyAttribute);
                propertyDrawer.SetValueToMember("m_FieldInfo", fieldInfo);
                return(propertyDrawer);
            }
            return(null);
        }
Пример #18
0
 protected override void HandleAttribute(PropertyAttribute attribute, System.Reflection.FieldInfo field, System.Type propertyType)
 {
     if (attribute is PropertyModifierAttribute)
     {
         var mtp = ScriptAttributeUtility.GetDrawerTypeForType(attribute.GetType());
         if (TypeUtil.IsType(mtp, typeof(PropertyModifier)))
         {
             var modifier = PropertyDrawerActivator.Create(mtp, attribute, field) as PropertyModifier;
             if (_modifiers == null)
             {
                 _modifiers = new List <PropertyModifier>();
             }
             _modifiers.Add(modifier);
         }
     }
     else if (attribute is TooltipAttribute)
     {
         _customTooltip = (attribute as TooltipAttribute).tooltip;
         base.HandleAttribute(attribute, field, propertyType);
     }
     else if (attribute is ContextMenuItemAttribute)
     {
         base.HandleAttribute(attribute, field, propertyType);
     }
     else
     {
         var drawerTypeForType = ScriptAttributeUtility.GetDrawerTypeForType(attribute.GetType());
         if (drawerTypeForType == null)
         {
             return;
         }
         else if (typeof(PropertyDrawer).IsAssignableFrom(drawerTypeForType))
         {
             base.HandleAttribute(attribute, field, propertyType);
             var drawer = this.InternalDrawer; //this retrieves the drawer that was selected by called 'base.HandleAttribute'
             this.AppendDrawer(drawer);
         }
         else if (typeof(DecoratorDrawer).IsAssignableFrom(drawerTypeForType))
         {
             DecoratorDrawer instance = (DecoratorDrawer)System.Activator.CreateInstance(drawerTypeForType);
             com.spacepuppy.Dynamic.DynamicUtil.SetValue(instance, "m_Attribute", attribute);
             if (this.DecoratorDrawers == null)
             {
                 this.DecoratorDrawers = new List <DecoratorDrawer>();
             }
             this.DecoratorDrawers.Add(instance);
         }
     }
 }
Пример #19
0
        public void RaiseAttributeGameAction(PropertyAttribute attribute, uint amount)
        {
            var creatureAttribute = new CreatureAttribute(this, attribute);

            uint result = SpendAttributeXp(creatureAttribute, amount);

            if (result > 0u)
            {
                GameMessage abilityUpdate = new GameMessagePrivateUpdateAttribute(this, attribute, creatureAttribute.Ranks, creatureAttribute.StartingValue, result);

                // checks if max rank is achieved and plays fireworks w/ special text
                string messageText;

                if (IsAttributeMaxRank(creatureAttribute.Ranks))
                {
                    // fireworks
                    PlayParticleEffect(ACE.Entity.Enum.PlayScript.WeddingBliss, Guid);
                    messageText = $"Your base {attribute} is now {creatureAttribute.Base} and has reached its upper limit!";
                }
                else
                {
                    messageText = $"Your base {attribute} is now {creatureAttribute.Base}!";
                }

                var soundEvent = new GameMessageSound(Guid, Sound.RaiseTrait, 1f);
                var message    = new GameMessageSystemChat(messageText, ChatMessageType.Advancement);

                // This seems to be needed to keep health up to date properly.
                // Needed when increasing health and endurance.
                if (attribute == PropertyAttribute.Endurance)
                {
                    var healthUpdate = new GameMessagePrivateUpdateVital(this, PropertyAttribute2nd.MaxHealth, Health.Ranks, Health.StartingValue, Health.ExperienceSpent, Health.Current);
                    Session.Network.EnqueueSend(abilityUpdate, soundEvent, message, healthUpdate);
                }
                else if (attribute == PropertyAttribute.Self)
                {
                    var manaUpdate = new GameMessagePrivateUpdateVital(this, PropertyAttribute2nd.MaxMana, Mana.Ranks, Mana.StartingValue, Mana.ExperienceSpent, Mana.Current);
                    Session.Network.EnqueueSend(abilityUpdate, soundEvent, message, manaUpdate);
                }
                else
                {
                    Session.Network.EnqueueSend(abilityUpdate, soundEvent, message);
                }
            }
            else
            {
                ChatPacket.SendServerMessage(Session, $"Your attempt to raise {attribute} has failed.", ChatMessageType.Broadcast);
            }
        }
Пример #20
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            _property   = property.FindPropertyRelative("_items");
            _itemDrawer = PropertyHelper.GetNextDrawer(fieldInfo, attribute);

            if (_property == null || !_property.isArray)
            {
                Debug.LogWarningFormat(_invalidTypeWarning, property.propertyPath);
                _property = null;
            }
            else
            {
                _listControl.Setup(_property);

                if (attribute is ListDisplayAttribute display)
                {
                    if (_itemDrawer != null)
                    {
                        _listControl.MakeDrawable(DrawItem);
                        _listControl.MakeCustomHeight(GetItemHeight);
                    }

                    if (display.AllowAdd)
                    {
                        _listControl.MakeAddable(_addButton);
                    }

                    if (display.AllowRemove)
                    {
                        _listControl.MakeRemovable(_removeButton);
                    }

                    if (display.AllowReorder)
                    {
                        _listControl.MakeReorderable();
                    }

                    if (display.AllowCollapse)
                    {
                        _listControl.MakeCollapsable();
                    }

                    if (display.EmptyText != null)
                    {
                        _listControl.MakeEmptyLabel(new GUIContent(display.EmptyText));
                    }
                }
            }
        }
Пример #21
0
        public void CreateProperty()
        {
            var categoryService = GetCategoryService();
            var propertyService = GetPropertyService();
            var category        = categoryService.GetById("a8bfc7cd-4363-4f12-976e-3f236433b6cf");
            var property        = new Property
            {
                Id         = "testProperty",
                CatalogId  = category.CatalogId,
                CategoryId = category.Id,
                Name       = "testProperty2",
                Type       = PropertyType.Product,
                ValueType  = PropertyValueType.ShortText,
                Dictionary = true
            };

            property.Attributes       = new List <PropertyAttribute>();
            property.DictionaryValues = new List <PropertyDictionaryValue>();

            var attribute = new PropertyAttribute
            {
                Name  = "attr1",
                Value = "val1"
            };

            property.Attributes.Add(attribute);

            property.DictionaryValues.Add(new PropertyDictionaryValue {
                Value = "ss", Property = property
            });
            property.DictionaryValues.Add(new PropertyDictionaryValue {
                Value = "ddd", Property = property
            });

            //property = propertyService.Create(property);

            property = propertyService.GetById(property.Id);

            property.DictionaryValues.Remove(property.DictionaryValues.First());
            property.DictionaryValues.Add(new PropertyDictionaryValue {
                Value = "fff", Property = property
            });

            propertyService.Update(new Property[] { property });

            property = propertyService.GetById(property.Id);

            propertyService.Delete(new string[] { property.Id });
        }
Пример #22
0
        /// <summary>
        /// If the creatures biota does not contain this attribute, a new record will be created.
        /// </summary>
        public CreatureAttribute(Creature creature, PropertyAttribute attribute)
        {
            this.creature = creature;
            Attribute     = attribute;

            biotaPropertiesAttribute = creature.Biota.GetAttribute(Attribute);

            if (biotaPropertiesAttribute == null)
            {
                creature.Biota.BiotaPropertiesAttribute.Add(new BiotaPropertiesAttribute {
                    ObjectId = creature.Biota.Id, Type = (ushort)Attribute
                });
                biotaPropertiesAttribute = creature.Biota.GetAttribute(Attribute);
            }
        }
Пример #23
0
        /// <summary>
        /// If the creatures biota does not contain this attribute, a new record will be created.
        /// </summary>
        public CreatureAttribute(Creature creature, PropertyAttribute attribute)
        {
            this.creature = creature;
            Attribute     = attribute;

            biotaPropertiesAttribute = creature.Biota.BiotaPropertiesAttribute.FirstOrDefault(x => x.Type == (uint)Attribute);

            if (biotaPropertiesAttribute == null)
            {
                biotaPropertiesAttribute = new BiotaPropertiesAttribute {
                    ObjectId = creature.Biota.Id, Type = (ushort)Attribute
                };
                creature.Biota.BiotaPropertiesAttribute.Add(biotaPropertiesAttribute);
            }
        }
Пример #24
0
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            _type           = property.FindPropertyRelative(nameof(Path.Type));
            _absolute       = property.FindPropertyRelative(nameof(Path.UseAbsolutePositioning));
            _usePathfinding = property.FindPropertyRelative(nameof(Path.UsePathfinding));
            _findAlternate  = property.FindPropertyRelative(nameof(Path.FindAlternateRoutes));
            _repeatCount    = property.FindPropertyRelative(nameof(Path.RepeatCount));

            _nodesControl.Setup(property.FindPropertyRelative(nameof(Path.Nodes)))
            .MakeDrawable(DrawNode)
            .MakeAddable(_addButton)
            .MakeRemovable(_removeButton, RemoveNode)
            .MakeCollapsable(property.serializedObject.targetObject.GetType() + "." + property.propertyPath + ".IsOpen")
            .MakeCustomHeight(GetNodeHeight);
        }
Пример #25
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (XamlType != null ? XamlType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Namespace != null ? Namespace.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)NodeType;
         hashCode = (hashCode * 397) ^ (PropertyAttribute != null ? PropertyAttribute.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Prefix != null ? Prefix.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PropertyElement != null ? PropertyElement.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PropertyAttributeText != null ? PropertyAttributeText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #26
0
        private void RaiseAttributeDeleteInteractionRequest(PropertyAttribute item)
        {
            var confirmation = new ConditionalConfirmation
            {
                Content = string.Format("Are you sure you want to delete Property attribute '{0}({1})'?".Localize(), item.PropertyAttributeName, item.PropertyAttributeValue),
                Title   = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };

            CommonConfirmRequest.Raise(confirmation, (x) =>
            {
                if (x.Confirmed)
                {
                    InnerItem.PropertyAttributes.Remove(item);
                }
            });
        }
Пример #27
0
        public static string GetColumnName(this PropertyInfo tEntityProperty, string tableName)
        {
            string propertyInfostring = "";
            //TODO:判断是否是复杂类型
            PropertyAttribute proAtt = tEntityProperty.GetCustomAttribute(typeof(PropertyAttribute)) as PropertyAttribute;

            if (proAtt == null)
            {
                propertyInfostring = tableName + ".[" + tEntityProperty.Name + "]";
            }
            else
            {
                propertyInfostring = tableName + ".[" + proAtt.ColumnName + "]";
            }
            return(propertyInfostring);
        }
Пример #28
0
        public static PropertyIdentifier GetPropertyIdentifier(Expression expr)
        {
            if (expr.NodeType != ExpressionType.MemberAccess)
            {
                throw new Exception();
            }
            MemberExpression member = (MemberExpression)expr;

            if (member.Member.MemberType != MemberTypes.Property)
            {
                throw new Exception();
            }
            PropertyAttribute attr = (PropertyAttribute)member.Member.GetCustomAttribute(typeof(PropertyAttribute));

            return((PropertyIdentifier)attr.PropertyIdentifier);
        }
Пример #29
0
 public static bool HasReorderableAttribute(SerializedProperty property)
 {
     PropertyAttribute[] propertyAttributes = ReorderableArrayEditor.GetPropertyAttributes <PropertyAttribute>(property);
     if (propertyAttributes != null)
     {
         PropertyAttribute[] array = propertyAttributes;
         for (int i = 0; i < array.Length; i++)
         {
             PropertyAttribute propertyAttribute = array[i];
             if (propertyAttribute.GetType().Name == "ReorderableAttribute")
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #30
0
        protected override void Draw(Rect position, SerializedProperty property, PropertyAttribute attribute, GUIContent label)
        {
            ShowRangeIfAttribute range = attribute as ShowRangeIfAttribute;

            if (property.propertyType == SerializedPropertyType.Float)
            {
                EditorGUI.Slider(position, property, range.min, range.max, label);
            }
            else if (property.propertyType == SerializedPropertyType.Integer)
            {
                EditorGUI.IntSlider(position, property, Convert.ToInt32(range.min), Convert.ToInt32(range.max), label);
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use Range with float or int.");
            }
        }
Пример #31
0
        public static bool DisableConfigClonedView(this Field field, View view)
        {
            if (!view.IsCloned || !((Database)field.View.Database).IsConfig)
            {
                return(false);
            }

            string viewName = view.Name;

            PropertyInfo property;

            if (field.View.Name == "View")
            {
                property = field.View.GetType().GetProperty(field.GetPropertyName(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            }
            else
            {
                property = typeof(Durados.Web.Mvc.ColumnField).GetProperty(field.GetPropertyName(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                if (property == null)
                {
                    property = typeof(Durados.Web.Mvc.ParentField).GetProperty(field.GetPropertyName(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                    if (property == null)
                    {
                        property = typeof(Durados.Web.Mvc.ChildrenField).GetProperty(field.GetPropertyName(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                    }
                }
            }

            if (property == null)
            {
                return(true);
            }


            object[] propertyAttributes = property.GetCustomAttributes(typeof(PropertyAttribute), true);
            if (propertyAttributes.Length == 1)
            {
                PropertyAttribute propertyAttribute = (PropertyAttribute)propertyAttributes[0];

                return(!propertyAttribute.DoNotCopy);
            }

            return(true);
        }
        public override void Setup(SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute)
        {
            base.Setup(property, fieldInfo, attribute);

            var callback = (attribute as ChangeTriggerAttribute).Callback;

            _object = PropertyHelper.GetAncestor <object>(property, 1);
            _method = fieldInfo.DeclaringType.GetMethod(callback, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, _types, _modifiers);

            if (_object == null)
            {
                Debug.LogWarningFormat(_missingObjectWarning, property.propertyPath);
            }
            else if (_method == null)
            {
                Debug.LogWarningFormat(_missingMethodWarning, property.propertyPath, callback);
            }
        }
Пример #33
0
        public static float GetAttributeMod(PropertyAttribute attribute, int current)
        {
            var attributeMod = 0.0f;

            switch (attribute)
            {
            case PropertyAttribute.Strength:
                attributeMod = StrengthMod;
                break;

            case PropertyAttribute.Coordination:
                attributeMod = CoordinationMod;
                break;
            }
            var attributeBonus = 1.0f + (current - 55) * attributeMod;

            return(attributeBonus);
        }
Пример #34
0
#pragma warning disable RCS1213 // Remove unused member declaration.
        private static PropertyDescription <T> CreatePropertyDescription <T>(
            PropertyInfo property,
            Type componentType,
            PropertyAttribute propertyAttribute,
            ComponentAttribute componentAttribute)
            where T : struct, IComparable <T>
        => new PropertyDescription <T>
        {
            ComponentId  = componentAttribute.Id,
            PropertyInfo = property,
            IsCalculated = propertyAttribute.IsCalculated,
            MinValue     = (T?)propertyAttribute.MinValue,
            MaxValue     = (T?)propertyAttribute.MaxValue,
            DefaultValue = (T?)propertyAttribute.DefaultValue
                           ?? (propertyAttribute.IsCalculated
                                   ? null
                                   : (T?)property.GetValue(Activator.CreateInstance(componentType)))
        };
        public GameMessagePrivateUpdateAbility(Session session, PropertyAttribute attribute, uint ranks, uint baseValue, uint totalInvestment)
            : base(GameMessageOpcode.PrivateUpdateAttribute, GameMessageGroup.UIQueue)
        {
            // TODO We shouldn't be passing session. Insetad, we should pass the value after session.UpdateSkillSequence++.

            //PropertyAttribute networkAbility;

            switch (attribute)
            {
            case PropertyAttribute.Strength:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeStrength));
                break;

            case PropertyAttribute.Endurance:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeEndurance));
                break;

            case PropertyAttribute.Coordination:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeCoordination));
                break;

            case PropertyAttribute.Quickness:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeQuickness));
                break;

            case PropertyAttribute.Focus:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeFocus));
                break;

            case PropertyAttribute.Self:
                Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttributeSelf));
                break;

            default:
                throw new ArgumentException("invalid ability specified");
            }

            //Writer.Write(session.Player.Sequences.GetNextSequence(Sequence.SequenceType.PrivateUpdateAttribute));
            Writer.Write((uint)attribute);
            Writer.Write(ranks);
            Writer.Write(baseValue);
            Writer.Write(totalInvestment);
        }
Пример #36
0
        /// <summary>
        /// Returns the bonus to an attribute from enchantments
        /// </summary>
        public int GetAttributeMod(PropertyAttribute attribute)
        {
            var typeFlags    = EnchantmentTypeFlags.Attribute;
            var enchantments = WorldObject.Biota.BiotaPropertiesEnchantmentRegistry.Where(e => ((EnchantmentTypeFlags)e.StatModType).HasFlag(typeFlags) && e.StatModKey == (uint)attribute);

            if (enchantments == null)
            {
                return(0);
            }

            var attributeMod = 0;

            foreach (var enchantment in enchantments)
            {
                attributeMod += (int)enchantment.StatModValue;
            }

            return(attributeMod);
        }
Пример #37
0
        public static List <PropertyAttribute> GetFieldAttributes(Object obj)
        {
            List <PropertyAttribute> attributes = new List <PropertyAttribute>();
            Type t = obj.GetType();

            PropertyInfo[] fields = t.GetProperties();
            foreach (PropertyInfo item in fields)
            {
                PropertyAttribute attribute = new PropertyAttribute(obj, item);
                if (attribute.Colmun != null)
                {
                    attributes.Add(attribute);
                }
            }
            //将ID字段移动到最前面
            attributes.Insert(0, attributes[attributes.Count - 1]);
            attributes.RemoveAt(attributes.Count - 1);
            return(attributes);
        }
Пример #38
0
 public static void BindEditor(FrameworkElement editor, DependencyProperty dp, PropertyAttribute pa, IValueConverter converter)
 {
     Binding editorBinding = null;
     if (pa.PropertyBinding != null)
     {
         editorBinding = pa.PropertyBinding;
         if (pa.PropertyBinding.Source == null)
         {
             editor.DataContext = pa.SelectedObject;
         }
     }
     else
     {
         editorBinding = new Binding(pa.MemberName);
         editorBinding.Mode = IsReadOnlySource(pa) ? BindingMode.OneWay : BindingMode.TwoWay;
         editorBinding.NotifyOnValidationError = true;
         editorBinding.ValidatesOnExceptions = true;
         editorBinding.ValidatesOnDataErrors = true;
         editorBinding.Converter = converter;
         editorBinding.Source = pa.SelectedObject;
     }
     editor.SetBinding(dp, editorBinding);
 }
Пример #39
0
        public Property(JObject jObject, DebuggedProcess proc, string parentName = null)
        {
            this.jObject = jObject;
            this.proc = proc;

            m_name = (string)jObject["name"];
            m_fullName = m_name;
            if (parentName != null) {
                m_fullName = parentName;
                if (Tools.IsValidIdentifier(m_name)) {
                    m_fullName += "." + m_name;
                } else {
                    m_fullName += "[" + JsonConvert.SerializeObject(m_name) + "]";
                }
            }

            Attributes = (PropertyAttribute)(int)(jObject["attributes"] ?? new JValue(0));
            Types = (PropertyType)(int)(jObject["propertyType"] ?? new JValue(0));
            //m_name += "(" + Attributes + ") (" + Types + ")";
            var value = jObject["value"] ?? proc.dbg.LookupRef((int)jObject["ref"], 300);
            if (value != null)
                FillValue((JObject)value);
        }
Пример #40
0
 public void Detach(PropertyAttribute property)
 {
     ClearValue(SelectedItemProperty);
 }
Пример #41
0
 public bool Supports(PropertyAttribute Property)
 {
     return Property.PropertyInfo.PropertyType == typeof(TimeSpan);
 }
Пример #42
0
 public void Detach(PropertyAttribute property)
 {
 }
Пример #43
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PropertyModel"/> class.
		/// </summary>
		/// <param name="prop">The prop.</param>
		/// <param name="att">The att.</param>
		public PropertyModel(PropertyInfo prop, PropertyAttribute att)
		{
			this.prop = prop;
			this.att = att;
		}
Пример #44
0
 public bool Supports(PropertyAttribute Property)
 {
     return Property.PropertyInfo.PropertyType.GetNonNullableType().IsNumeric();
 }
Пример #45
0
	/// <summary>
	/// Instantiates the gameobject for the property
	/// </summary>
	/// <param name="prefabName">Name of the prefab</param>
	/// <param name="block">Block</param>
	/// <param name="info">PropertyInfo</param>
	/// <param name="attribute">PropertyAttribute</param>
	void InstantiateProperty(string prefabName, Block block, PropertyInfo info, PropertyAttribute attribute) {
		GameObject prefab = Resources.Load("UI/Properties/" + prefabName) as GameObject;
		GameObject instance = Instantiate(prefab);

		//Set parent
		instance.transform.SetParent(propertiesList);

		//Get property controller
		PropertyController controller = instance.GetComponent<PropertyController>();
		
		controller.Title = attribute.Title;
		controller.Description = attribute.Description;
		controller.Options = attribute.Options;
		controller.Object = block;
		controller.Property = info;

		controller.Create(controller.Property.GetValue(controller.Object, null));
	}
Пример #46
0
 public bool Supports(PropertyAttribute Property)
 {
     throw new NotImplementedException();
 }
Пример #47
0
 public bool Supports(PropertyAttribute Property)
 {
     return Property.PropertyInfo.PropertyType == typeof(CornerRadius);
 }
Пример #48
0
 public void Detach(PropertyAttribute property)
 {
     _slider.ValueChanged -= slider_ValueChanged;
     _numeric.ValueChanged -= numeric_ValueChanged;
 }
Пример #49
0
 private void PrepareSlider(PropertyAttribute property, double defaultValue, bool valueChanged)
 {
     _slider.Visibility = Visibility.Visible;
     _slider.MinimumValue = property.MinimumValue;
     _slider.MaximumValue = property.MaximumValue;
     _slider.checkNullable.IsChecked = !double.IsNaN(defaultValue);
     _slider.ShowCheck = Convert.ToBoolean(property.Tag);
     _slider.Value = defaultValue;
     if (valueChanged) slider_ValueChanged(null, null);
 }
Пример #50
0
        private void PrepareNumeric(PropertyAttribute property, double defaultValue, bool valueChanged)
        {
            _numeric.Visibility = Visibility.Visible;
            _numeric.AllowNull = property.PropertyInfo.PropertyType.IsNullableType();
            if (!double.IsNaN(property.MinimumValue))
            {
                _numeric.Minimum = property.MinimumValue;
            }
            if (!double.IsNaN(property.MaximumValue))
            {
                _numeric.Maximum = property.MaximumValue;
            }

            // set format
            if (property.PropertyInfo.PropertyType.GetNonNullableType() == typeof(double))
            {
                _numeric.Format = "F2";
            }
            else if (property.PropertyInfo.PropertyType.GetNonNullableType() == typeof(Int32))
            {
                _numeric.Format = "F0";
            }
            else
            {
                _numeric.Format = "F0";
            }
            _numeric.Value = defaultValue;
            if (valueChanged) numeric_ValueChanged(null, null);
        }
Пример #51
0
	public void AddProperty(Block block, PropertyInfo info, PropertyAttribute attribute) {
		if(info.PropertyType == typeof(float)) {
			InstantiateProperty("Float Property", block, info, attribute);
            return;
		}
		if (info.PropertyType == typeof(int)) {
			InstantiateProperty("Int Property", block, info, attribute);
			return;
		}
	}
Пример #52
0
        /// <summary> Write a Property XML Element from attributes in a member. </summary>
        public virtual void WriteProperty(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, PropertyAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass)
        {
            writer.WriteStartElement( "property" );
            // Attribute: <name>
            writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_Property_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass));
            // Attribute: <node>
            if(attribute.Node != null)
            writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass));
            // Attribute: <access>
            if(attribute.Access != null)
            writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass));
            // Attribute: <type>
            if(attribute.Type != null)
            writer.WriteAttributeString("type", GetAttributeValue(attribute.Type, mappedClass));
            else
            {
                System.Type type = null;
                if(member is System.Reflection.PropertyInfo)
                    type = (member as System.Reflection.PropertyInfo).PropertyType;
                else if(member is System.Reflection.FieldInfo)
                    type = (member as System.Reflection.FieldInfo).FieldType;
                if(type != null) // Transform using RegularExpressions
                {
                    string typeName = type.FullName + ", " + type.Assembly.GetName().Name;
                    foreach(System.Collections.DictionaryEntry pattern in Patterns)
                    {
                        if(System.Text.RegularExpressions.Regex.IsMatch(typeName, pattern.Key as string))
                        {
                            writer.WriteAttributeString( "type",
                                System.Text.RegularExpressions.Regex.Replace(typeName,
                                    pattern.Key as string,
                                    pattern.Value as string) );
                            break;
                        }
                    }
                }
            }
            // Attribute: <column>
            if(attribute.Column != null)
            writer.WriteAttributeString("column", GetAttributeValue(attribute.Column, mappedClass));
            // Attribute: <length>
            if(attribute.Length != -1)
            writer.WriteAttributeString("length", attribute.Length.ToString());
            // Attribute: <precision>
            if(attribute.Precision != -1)
            writer.WriteAttributeString("precision", attribute.Precision.ToString());
            // Attribute: <scale>
            if(attribute.Scale != -1)
            writer.WriteAttributeString("scale", attribute.Scale.ToString());
            // Attribute: <not-null>
            if( attribute.NotNullSpecified )
            writer.WriteAttributeString("not-null", attribute.NotNull ? "true" : "false");
            // Attribute: <unique>
            if( attribute.UniqueSpecified )
            writer.WriteAttributeString("unique", attribute.Unique ? "true" : "false");
            // Attribute: <unique-key>
            if(attribute.UniqueKey != null)
            writer.WriteAttributeString("unique-key", GetAttributeValue(attribute.UniqueKey, mappedClass));
            // Attribute: <index>
            if(attribute.Index != null)
            writer.WriteAttributeString("index", GetAttributeValue(attribute.Index, mappedClass));
            // Attribute: <update>
            if( attribute.UpdateSpecified )
            writer.WriteAttributeString("update", attribute.Update ? "true" : "false");
            // Attribute: <insert>
            if( attribute.InsertSpecified )
            writer.WriteAttributeString("insert", attribute.Insert ? "true" : "false");
            // Attribute: <optimistic-lock>
            if( attribute.OptimisticLockSpecified )
            writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false");
            // Attribute: <formula>
            if(attribute.Formula != null)
            writer.WriteAttributeString("formula", GetAttributeValue(attribute.Formula, mappedClass));
            // Attribute: <lazy>
            if( attribute.LazySpecified )
            writer.WriteAttributeString("lazy", attribute.Lazy ? "true" : "false");
            // Attribute: <generated>
            if(attribute.Generated != PropertyGeneration.Unspecified)
            writer.WriteAttributeString("generated", GetXmlEnumValue(typeof(PropertyGeneration), attribute.Generated));

            WriteUserDefinedContent(writer, member, null, attribute);

            System.Collections.ArrayList memberAttribs = GetSortedAttributes(member);
            int attribPos; // Find the position of the PropertyAttribute (its <sub-element>s must be after it)
            for(attribPos=0; attribPos<memberAttribs.Count; attribPos++)
                if( memberAttribs[attribPos] is PropertyAttribute
                    && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position )
                    break; // found
            int i = attribPos + 1;

            // Element: <meta>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is PropertyAttribute )
                        break; // Following attributes are for this Property
                    if( memberAttrib is MetaAttribute )
                        WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute);
            // Element: <column>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(ColumnAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is PropertyAttribute )
                        break; // Following attributes are for this Property
                    if( memberAttrib is ColumnAttribute )
                        WriteColumn(writer, member, memberAttrib as ColumnAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(ColumnAttribute), attribute);
            // Element: <formula>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(FormulaAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is PropertyAttribute )
                        break; // Following attributes are for this Property
                    if( memberAttrib is FormulaAttribute )
                        WriteFormula(writer, member, memberAttrib as FormulaAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(FormulaAttribute), attribute);
            // Element: <type>
            for(; i<memberAttribs.Count; i++)
            {
                BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute;
                if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType())
                    || IsNextElement(memberAttrib, attribute, typeof(TypeAttribute)) )
                    break; // next attributes are 'elements' of the same level OR for 'sub-elements'
                else
                {
                    if( memberAttrib is PropertyAttribute )
                        break; // Following attributes are for this Property
                    if( memberAttrib is TypeAttribute )
                        WriteType(writer, member, memberAttrib as TypeAttribute, attribute, mappedClass);
                }
            }
            WriteUserDefinedContent(writer, member, typeof(TypeAttribute), attribute);

            writer.WriteEndElement();
        }
Пример #53
0
		public void CreateProperty()
		{
			var categoryService = GetCategoryService();
			var propertyService = GetPropertyService();
			var category = categoryService.GetById("a8bfc7cd-4363-4f12-976e-3f236433b6cf");
			var property = new Property
			{
				Id = "testProperty",
				CatalogId = category.CatalogId,
				CategoryId = category.Id,
				Name = "testProperty2",
				Type = PropertyType.Product,
				ValueType = PropertyValueType.ShortText,
				Dictionary = true
			};
			property.Attributes = new List<PropertyAttribute>();
			property.DictionaryValues = new List<PropertyDictionaryValue>();

			var attribute = new PropertyAttribute
			{
				 Name = "attr1",
				 Value = "val1"

			};
			property.Attributes.Add(attribute);

			property.DictionaryValues.Add(new PropertyDictionaryValue { Value = "ss", Property = property });
			property.DictionaryValues.Add(new PropertyDictionaryValue { Value = "ddd", Property = property });

			//property = propertyService.Create(property);

			property = propertyService.GetById(property.Id);

			property.DictionaryValues.Remove(property.DictionaryValues.First());
			property.DictionaryValues.Add(new PropertyDictionaryValue { Value = "fff", Property = property });

			propertyService.Update(new Property[] { property });

			property = propertyService.GetById(property.Id);

			propertyService.Delete(new string[] { property.Id });
		}