コード例 #1
0
ファイル: ClassFactory.cs プロジェクト: reckcn/CSharp
        Type CreateDynamicClass( DynamicProperty[] properties ) 
        {
            LockCookie cookie = rwLock.UpgradeToWriterLock( Timeout.Infinite );
            try 
            {
                string typeName = "DynamicClass" + ( classCount + 1 );
#if ENABLE_LINQ_PARTIAL_TRUST
                new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
                try 
                {
                    TypeBuilder tb = this.module.DefineType( typeName, TypeAttributes.Class |
                        TypeAttributes.Public, typeof( DynamicClass ) );
                    FieldInfo[] fields = GenerateProperties( tb, properties );
                    GenerateEquals( tb, fields );
                    GenerateGetHashCode( tb, fields );
                    Type result = tb.CreateType();
                    classCount++;
                    return result;
                }
                finally 
                {
#if ENABLE_LINQ_PARTIAL_TRUST
                    PermissionSet.RevertAssert();
#endif
                }
            }
            finally 
            {
                rwLock.DowngradeFromWriterLock( ref cookie );
            }
        }
コード例 #2
0
        public CastSpellAction()
        {
            _spamControl = new Stopwatch();
            QueueIsRunning = false;
            Properties["Casted"] = new MetaProp("Casted", typeof(int), new ReadOnlyAttribute(true));
            Properties["SpellName"] = new MetaProp("SpellName", typeof(string), new ReadOnlyAttribute(true));
            Properties["Repeat"] = new MetaProp("Repeat", typeof(DynamicProperty<int>),
                new TypeConverterAttribute(typeof(DynamicProperty<int>.DynamivExpressionConverter)));
            Properties["Entry"] = new MetaProp("Entry", typeof(uint));
            Properties["CastOnItem"] = new MetaProp("CastOnItem", typeof(bool), new DisplayNameAttribute("Cast on Item"));
            Properties["ItemType"] = new MetaProp("ItemType", typeof(InventoryType), new DisplayNameAttribute("Item Type"));
            Properties["ItemId"] = new MetaProp("ItemId", typeof(uint));
            Properties["RepeatType"] = new MetaProp("RepeatType", typeof(RepeatCalculationType), new DisplayNameAttribute("Repeat Type"));
            // Properties["Recipe"] = new MetaProp("Recipe", typeof(Recipe), new TypeConverterAttribute(typeof(RecipeConverter)));

            Casted = 0;
            Repeat = new DynamicProperty<int>(this,"1");
            RegisterDynamicProperty("Repeat");
            Entry = 0u;
            RepeatType = RepeatCalculationType.Craftable;
            Recipe = null;
            CastOnItem = false;
            ItemType = InventoryType.Chest;
            ItemId = 0u;
            Properties["SpellName"].Value = SpellName;

            //Properties["Recipe"].Show = false;
            Properties["ItemType"].Show = false;
            Properties["ItemId"].Show = false;
            Properties["Casted"].PropertyChanged += OnCounterChanged;
            CheckTradeskillList();
            Properties["RepeatType"].PropertyChanged += CastSpellActionPropertyChanged;
            Properties["Entry"].PropertyChanged += OnEntryChanged;
            Properties["CastOnItem"].PropertyChanged += CastOnItemChanged;
        }
コード例 #3
0
ファイル: ClassFactory.cs プロジェクト: jstevenson81/wodgeaux
 Type CreateDynamicClass(DynamicProperty[] properties)
 {
     LockCookie cookie = rwLock.UpgradeToWriterLock(Timeout.Infinite);
     try
     {
         string typeName = "DynamicClass" + (classCount + 1);
         try
         {
             TypeBuilder tb = this.module.DefineType(typeName, TypeAttributes.Class |
                 TypeAttributes.Public, typeof(DynamicClass));
             FieldInfo[] fields = GenerateProperties(tb, properties);
             GenerateEquals(tb, fields);
             GenerateGetHashCode(tb, fields);
             Type result = tb.CreateType();
             classCount++;
             return result;
         }
         finally
         {
         }
     }
     finally
     {
         rwLock.DowngradeFromWriterLock(ref cookie);
     }
 }
コード例 #4
0
ファイル: ColumnAttribute.cs プロジェクト: supuy-ruby/Aoite
 /// <summary>
 /// 指定一个实例,设置指定属性的值。
 /// </summary>
 /// <param name="property">动态属性。</param>
 /// <param name="instance">一个实例,null 值表示静态属性。</param>
 /// <param name="value">属性的值。</param>
 public void SetValue(DynamicProperty property, object instance, object value)
 {
     if(value is string)
     {
         value = ObjectFactory.Context.Get<IJsonProvider>().Deserialize(value.ToString(), property.Property.PropertyType);
     }
     property.SetValue(instance, value, false);
 }
コード例 #5
0
 /// <summary>
 /// Adds a property into the CustomClass.
 /// </summary>
 /// <param name="propName">Name of the property that needs to be added.</param>
 /// <param name="propValue">Value of the property that needs to be added.</param>
 /// <param name="propDesc">Description of the property that needs to be added.</param>
 /// <param name="propCat">The category to display this property in.</param>
 /// <param name="isReadOnly">Sets the property value to readonly in the property grid.</param>
 /// <param name="isExpandable">Tells the property grid that this property is expandable.</param>
 /// <param name="propType">DataType of the property that needs to be added.</param>
 public void AddProperty(string propName, object propValue, string propDesc,
     string propCat, System.Type propType, bool isReadOnly, bool isExpandable)
 {
     DynamicProperty p = new DynamicProperty(propName, propValue, propDesc, propCat,
         propType, isReadOnly, isExpandable);
     propertyCollection.Add(p);
     //Set our layout helper value.
     this.MaxLength = propName.Length;
     this.MaxLength = propValue.ToString().Length;
 }
コード例 #6
0
 public CastSpellAction(Recipe recipe, int repeat, RepeatCalculationType repeatType)
     : this()
 {
     Recipe = recipe;
     Repeat = new DynamicProperty<int>(this,repeat.ToString(CultureInfo.InvariantCulture));
     Entry = recipe.ID;
     RepeatType = repeatType;
     //Properties["Recipe"].Show = true;
     Properties["SpellName"].Value = SpellName;
     Pb.UpdateMaterials();
 }
コード例 #7
0
ファイル: WaitAction.cs プロジェクト: Asphodan/Alphabuddy
        public WaitAction()
            : base(CsharpCodeType.BoolExpression)
        {
            Properties["Timeout"] = new MetaProp("Timeout", typeof (DynamicProperty<int>),
                                                 new TypeConverterAttribute(
                                                     typeof (DynamicProperty<int>.DynamivExpressionConverter)),
                                                 new DisplayNameAttribute(Pb.Strings["Action_Common_Timeout"]));

            Properties["Condition"] = new MetaProp("Condition", typeof (string),
                                                   new EditorAttribute(typeof (MultilineStringEditor),
                                                                       typeof (UITypeEditor)),
                                                   new DisplayNameAttribute(Pb.Strings["Action_WaitAction_Condition"]));

            Timeout = new DynamicProperty<int>(this, "2000");

            Condition = "false";
            CanRunDelegate = u => false;
        }
コード例 #8
0
        public MailItemAction()
        {
            Properties["ItemID"] = new MetaProp("ItemID", typeof(string));
            Properties["AutoFindMailBox"] = new MetaProp("AutoFindMailBox", typeof(bool), new DisplayNameAttribute("Automatically find Mailbox"));
            Properties["Location"] = new MetaProp("Location", typeof(string), new EditorAttribute(typeof(PropertyBag.LocationEditor), typeof(UITypeEditor)));
            Properties["UseCategory"] = new MetaProp("UseCategory", typeof(bool), new DisplayNameAttribute("Use Category"));
            Properties["Category"] = new MetaProp("Category", typeof(WoWItemClass), new DisplayNameAttribute("Item Category"));
            Properties["SubCategory"] = new MetaProp("SubCategory", typeof(WoWItemTradeGoodsClass), new DisplayNameAttribute("Item SubCategory"));
            Properties["Amount"] = new MetaProp("Amount", typeof(DynamicProperty<int>),
                new TypeConverterAttribute(typeof(DynamicProperty<int>.DynamivExpressionConverter)));

            ItemID = "";
            AutoFindMailBox = true;
            _loc = WoWPoint.Zero;
            Location = _loc.ToInvariantString();
            UseCategory = true;
            Category = WoWItemClass.TradeGoods;
            SubCategory = WoWItemTradeGoodsClass.None;
            Amount = new DynamicProperty<int>(this, "0");
            RegisterDynamicProperty("Amount");

            Properties["Location"].Show = false;
            Properties["ItemID"].Show = false;
            Properties["AutoFindMailBox"].PropertyChanged += AutoFindMailBoxChanged;
            Properties["Location"].PropertyChanged += LocationChanged;
            Properties["UseCategory"].PropertyChanged += UseCategoryChanged;
            Properties["Category"].PropertyChanged += CategoryChanged;
        }
コード例 #9
0
		/// <summary>
		/// 删除 placeholder 与 dynamic 的对应关系
		/// </summary>
		/// <param name="dynamic"> </param>
		private void removeDynamic(DynamicProperty dynamic)
		{
			IList<string> placeholders = dynamic.placeholders;
			foreach (string placeholder in placeholders)
			{
				IList<DynamicProperty> l = placeholderToDynamics[placeholder];
				l.Remove(dynamic);
			}
			dynamic.placeholders.Clear();
			dynamicProperties.Remove(dynamic);
		}
コード例 #10
0
ファイル: ClassFactory.cs プロジェクト: jstevenson81/wodgeaux
 FieldInfo[] GenerateProperties(TypeBuilder tb, DynamicProperty[] properties)
 {
     FieldInfo[] fields = new FieldBuilder[properties.Length];
     for (int i = 0; i < properties.Length; i++)
     {
         DynamicProperty dp = properties[i];
         FieldBuilder fb = tb.DefineField("_" + dp.Name, dp.Type, FieldAttributes.Private);
         PropertyBuilder pb = tb.DefineProperty(dp.Name, PropertyAttributes.HasDefault, dp.Type, null);
         MethodBuilder mbGet = tb.DefineMethod("get_" + dp.Name,
             MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig,
             dp.Type, Type.EmptyTypes);
         ILGenerator genGet = mbGet.GetILGenerator();
         genGet.Emit(OpCodes.Ldarg_0);
         genGet.Emit(OpCodes.Ldfld, fb);
         genGet.Emit(OpCodes.Ret);
         MethodBuilder mbSet = tb.DefineMethod("set_" + dp.Name,
             MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig,
             null, new Type[] { dp.Type });
         ILGenerator genSet = mbSet.GetILGenerator();
         genSet.Emit(OpCodes.Ldarg_0);
         genSet.Emit(OpCodes.Ldarg_1);
         genSet.Emit(OpCodes.Stfld, fb);
         genSet.Emit(OpCodes.Ret);
         pb.SetGetMethod(mbGet);
         pb.SetSetMethod(mbSet);
         fields[i] = fb;
     }
     return fields;
 }
コード例 #11
0
 /// <summary>
 /// Update existing dynamic property 
 /// </summary>
 /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="typeName"></param>
 /// <param name="propertyId"></param>
 /// <param name="property"></param>
 /// <returns></returns>
 public void DynamicPropertiesUpdateProperty(string typeName, string propertyId, DynamicProperty property)
 {
      DynamicPropertiesUpdatePropertyWithHttpInfo(typeName, propertyId, property);
 }
コード例 #12
0
ファイル: TotemType.cs プロジェクト: Alxandr/IronTotem
        private void PopulateProperties(Type type, Dictionary<string, DynamicProperty> properties, Dictionary<string, DynamicProperty> staticProps)
        {
            var methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            foreach (var method in methods)
            {
                DynamicProperty prop;
                DynamicFlags flags;
                ParameterInfo[] parameters;
                var attr = method.GetCustomAttribute<TotemPropertyAttribute>();
                if (attr != null)
                {
                    var dict = attr.IsStatic ? staticProps : properties;

                    string name = method.Name.Substring(3),
                        prefix = method.Name.Substring(0, 3);
                    name = name[0].ToString().ToLower() + name.Substring(1);
                    if (attr.Name != null)
                        name = attr.Name;

                    var preParams = new List<Expression>();
                    if (attr.RequiresContext)
                        preParams.Add(Expression.Constant(_context));

                    parameters = method.GetParameters();

                    if (!dict.TryGetValue(name, out prop))
                    {
                        prop = dict[name] = new DynamicProperty();
                    }

                    if (prefix == "Get")
                    {
                        if (parameters.Length != preParams.Count + (attr.IsStatic ? 0 : 1))
                            throw new Exception("Invalid number of arguments for getter-property");
                        for (var i = 0; i < preParams.Count; i++)
                            if (!parameters[i].ParameterType.IsAssignableFrom(preParams[i].Type))
                                throw new Exception("Invalid param");

                        prop.Methods = null;
                        if (prop.Getters == null)
                            prop.Getters = new List<DynamicProperty.Getter>();
                        prop.Getters.Add(
                            attr.IsStatic ?
                            MakeStaticProperty(method, preParams.ToArray()) :
                            MakeGetProperty(method, preParams.ToArray(), parameters[preParams.Count])
                        );
                    }
                    else if (prefix == "Set")
                    {
                        if(parameters.Length != preParams.Count + 2)
                            throw new Exception("Invalid number of arguments for setter-property");
                        for (var i = 0; i < preParams.Count; i++)
                            if (!parameters[i].ParameterType.IsAssignableFrom(preParams[i].Type))
                                throw new Exception("Invalid param");

                        if (prop.Setters == null)
                            prop.Setters = new List<DynamicProperty.Setter>();
                        prop.Setters.Add(MakeSetProperty(method, preParams.ToArray(), parameters[preParams.Count], parameters[preParams.Count+1]));
                    }
                    else
                    {
                        throw new Exception("Bad property name");
                    }
                }

                var attr2 = method.GetCustomAttribute<TotemMethodAttribute>();
                if (attr2 != null)
                {
                    flags = DynamicFlags.None;
                    if (attr2.StaticOnly)
                        flags |= DynamicFlags.StaticOnly;
                    if (attr2.RequiresType)
                        flags |= DynamicFlags.RequiresType;

                    var dict = attr2.StaticOnly ? staticProps : properties;

                    string name = method.Name[0].ToString().ToLower() + method.Name.Substring(1);

                    if (!dict.TryGetValue(name, out prop))
                    {
                        prop = dict[name] = new DynamicProperty();
                    }

                    parameters = method.GetParameters();
                    if (!attr2.StaticOnly && parameters.Length < 1)
                        throw new Exception("Invalid number of arguments for method-property");
                    //if (!attr2.StaticOnly && !Handles(parameters[0].ParameterType))
                    //    throw new Exception("Invalid first argument for method-property");

                    prop.Getters = null;
                    if (prop.Methods == null)
                        prop.Methods = new List<Tuple<MethodInfo, DynamicFlags>>();

                    prop.Methods.Add(new Tuple<MethodInfo, DynamicFlags>(method, flags));

                    if (!attr2.StaticOnly)
                    {
                        dict = staticProps;
                        if (!dict.TryGetValue(name, out prop))
                        {
                            prop = dict[name] = new DynamicProperty();
                        }
                        prop.Getters = null;
                        if (prop.Methods == null)
                            prop.Methods = new List<Tuple<MethodInfo, DynamicFlags>>();

                        prop.Methods.Add(new Tuple<MethodInfo, DynamicFlags>(method, flags));
                    }
                }
            }
        }
コード例 #13
0
ファイル: Irc.cs プロジェクト: vsrz/desbot_vsrz
 static void sendDelay_Changed(DynamicProperty<int, int> prop)
 {
     client.SendDelay = prop.Value;
 }
コード例 #14
0
        public SellItemOnAhAction()
        {
            Properties["ItemID"] = new MetaProp("ItemID", typeof(string),
                                                new DisplayNameAttribute(Pb.Strings["Action_Common_ItemEntries"]));

            Properties["RunTime"] = new MetaProp("RunTime", typeof(RunTimeType),
                                                 new DisplayNameAttribute(
                                                     Pb.Strings["Action_SellItemOnAhAction_AuctionDuration"]));

            Properties["MinBuyout"] = new MetaProp("MinBuyout", typeof(PropertyBag.GoldEditor),
                                                   new TypeConverterAttribute(typeof(PropertyBag.GoldEditorConverter)),
                                                   new DisplayNameAttribute(Pb.Strings["Action_Common_MinBuyout"]));

            Properties["MaxBuyout"] = new MetaProp("MaxBuyout", typeof(PropertyBag.GoldEditor),
                                                   new TypeConverterAttribute(typeof(PropertyBag.GoldEditorConverter)),
                                                   new DisplayNameAttribute(Pb.Strings["Action_Common_MaxBuyout"]));

            Properties["Amount"] = new MetaProp("Amount", typeof(DynamicProperty<int>),
                                                new TypeConverterAttribute(
                                                    typeof(DynamicProperty<int>.DynamivExpressionConverter)),
                                                new DisplayNameAttribute(Pb.Strings["Action_Common_Amount"]));

            Properties["StackSize"] = new MetaProp("StackSize", typeof(uint),
                                                   new DisplayNameAttribute(Pb.Strings["Action_Common_StackSize"]));

            Properties["IgnoreStackSizeBelow"] = new MetaProp("IgnoreStackSizeBelow", typeof(uint),
                                                              new DisplayNameAttribute(
                                                                  Pb.Strings["Action_Common_IgnoreStackSizeBelow"]));

            Properties["AmountType"] = new MetaProp("AmountType", typeof(AmountBasedType),
                                                    new DisplayNameAttribute(Pb.Strings["Action_Common_Sell"]));

            Properties["AutoFindAh"] = new MetaProp("AutoFindAh", typeof(bool),
                                                    new DisplayNameAttribute(Pb.Strings["Action_Common_AutoFindAH"]));

            Properties["Location"] = new MetaProp("Location", typeof(string),
                                                  new EditorAttribute(typeof(PropertyBag.LocationEditor),
                                                                      typeof(UITypeEditor)),
                                                  new DisplayNameAttribute(Pb.Strings["Action_Common_Location"]));

            Properties["BidPrecent"] = new MetaProp("BidPrecent", typeof(float),
                                                    new DisplayNameAttribute(
                                                        Pb.Strings["Action_SellItemOnAhAction_BidPercent"]));

            Properties["UndercutPrecent"] = new MetaProp("UndercutPrecent", typeof(double),
                                                         new DisplayNameAttribute(
                                                             Pb.Strings["Action_SellItemOnAhAction_UndercutPercent"]));

            Properties["UseCategory"] = new MetaProp("UseCategory", typeof(bool),
                                                     new DisplayNameAttribute(Pb.Strings["Action_Common_UseCategory"]));

            Properties["Category"] = new MetaProp("Category", typeof(WoWItemClass),
                                                  new DisplayNameAttribute(Pb.Strings["Action_Common_ItemCategory"]));

            Properties["SubCategory"] = new MetaProp("SubCategory", typeof(WoWItemTradeGoodsClass),
                                                     new DisplayNameAttribute(
                                                         Pb.Strings["Action_Common_ItemSubCategory"]));

            Properties["PostIfBelowMinBuyout"] = new MetaProp("PostIfBelowMinBuyout", typeof(bool),
                                                              new DisplayNameAttribute(
                                                                  Pb.Strings[
                                                                      "Action_SellItemOnAhAction_PostIfBelowMinBuyout"]));

            ItemID = "";
            MinBuyout = new PropertyBag.GoldEditor("0g10s0c");
            MaxBuyout = new PropertyBag.GoldEditor("100g0s0c");
            RunTime = RunTimeType._24_Hours;
            Amount = new DynamicProperty<int>(this, "10");
            RegisterDynamicProperty("Amount");
            StackSize = 20u;
            IgnoreStackSizeBelow = 1u;
            AmountType = AmountBasedType.Everything;
            AutoFindAh = true;
            BidPrecent = 95f;
            UndercutPrecent = 0.1;
            _loc = WoWPoint.Zero;
            Location = _loc.ToInvariantString();
            UseCategory = true;
            Category = WoWItemClass.TradeGoods;
            SubCategory = WoWItemTradeGoodsClass.None;
            PostIfBelowMinBuyout = true;

            Properties["AutoFindAh"].PropertyChanged += AutoFindAHChanged;
            Properties["AmountType"].PropertyChanged += SellItemToAhActionPropertyChanged;
            Properties["Location"].PropertyChanged += LocationChanged;
            Properties["UseCategory"].PropertyChanged += UseCategoryChanged;
            Properties["Category"].PropertyChanged += CategoryChanged;

            Properties["ItemID"].Show = false;
            Properties["Amount"].Show = false;
            Properties["Location"].Show = false;
        }
コード例 #15
0
ファイル: TotemType.cs プロジェクト: Alxandr/IronTotem
        private Dictionary<string, DynamicProperty> EnsureProperties(Type type)
        {
            Dictionary<string, DynamicProperty> value;
            if (!_properties.TryGetValue(type, out value))
            {
                value = _properties[type] = new Dictionary<string, DynamicProperty>();
                var staticProps = _staticProperties[type] = new Dictionary<string, DynamicProperty>();
                if (type.BaseType != null)
                {
                    var seed = EnsureProperties(type.BaseType);
                    foreach (var entry in seed)
                    {
                        var dn = new DynamicProperty();
                        if (entry.Value.Getters != null)
                            dn.Getters = new List<DynamicProperty.Getter>(entry.Value.Getters);
                        if (entry.Value.Setters != null)
                            dn.Setters = new List<DynamicProperty.Setter>(entry.Value.Setters);
                        if (entry.Value.Methods != null)
                            dn.Methods = new List<Tuple<MethodInfo, DynamicFlags>>(entry.Value.Methods);
                        value.Add(entry.Key, dn);
                    }
                    foreach (var entry in _staticProperties[type.BaseType])
                    {
                        var dn = new DynamicProperty();
                        if (entry.Value.Getters != null)
                            dn.Getters = new List<DynamicProperty.Getter>(entry.Value.Getters);
                        if (entry.Value.Setters != null)
                            dn.Setters = new List<DynamicProperty.Setter>(entry.Value.Setters);
                        if (entry.Value.Methods != null)
                            dn.Methods = new List<Tuple<MethodInfo, DynamicFlags>>(entry.Value.Methods);
                        staticProps.Add(entry.Key, dn);
                    }
                }

                PopulateProperties(type, value, staticProps);
            }
            return value;
        }
コード例 #16
0
        /// <summary>
        /// Update existing dynamic property 
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="typeName"></param>
        /// <param name="propertyId"></param>
        /// <param name="property"></param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task DynamicPropertiesUpdatePropertyAsync(string typeName, string propertyId, DynamicProperty property)
        {
             await DynamicPropertiesUpdatePropertyAsyncWithHttpInfo(typeName, propertyId, property);

        }
コード例 #17
0
        /// <summary>
        /// Add new dynamic property 
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="typeName"></param>
        /// <param name="property"></param>
        /// <returns>Task of DynamicProperty</returns>
        public async System.Threading.Tasks.Task<DynamicProperty> DynamicPropertiesCreatePropertyAsync(string typeName, DynamicProperty property)
        {
             ApiResponse<DynamicProperty> localVarResponse = await DynamicPropertiesCreatePropertyAsyncWithHttpInfo(typeName, property);
             return localVarResponse.Data;

        }
コード例 #18
0
 public string AsEntityString(DynamicProperty p)
 {
     // see also EngineComponentManager::SetNativeComponentProperty:
       // note we are not checking p.PropertyType.IsEnum, which would be different
       if (p.PropertyType.NativeType.IsEnum)
       {
     int iAsInt = (int)p.Value;
     return iAsInt.ToString();
       }
       return SerializationHelper.GetEngineStringFromObject(p.Value);
 }
コード例 #19
0
		/// <summary>
		/// 建立 placeholder 与 dynamic 的对应关系
		/// </summary>
		/// <param name="dynamic"> </param>
		/// <param name="placeholder"> </param>
		private void addDependency(DynamicProperty dynamic, string placeholder)
		{
			IList<DynamicProperty> l = placeholderToDynamics[placeholder];
			if (l == null)
			{
				l = new List<DynamicProperty>();
				placeholderToDynamics[placeholder] = l;
			}
			if (!l.Contains(dynamic))
			{
				l.Add(dynamic);
			}
			dynamic.addPlaceholder(placeholder);
		}
コード例 #20
0
		/// <param name="currentBeanName">     当前的bean name </param>
		/// <param name="currentPropertyName"> 当前它的属性 </param>
		/// <param name="orgStrVal">           原来的值
		/// 
		/// @return </param>
		private DynamicProperty getDynamic(string currentBeanName, string currentPropertyName, string orgStrVal)
		{
			DynamicProperty dynamic = new DynamicProperty(currentBeanName, currentPropertyName, orgStrVal);
			DynamicProperty found = dynamicProperties[dynamic];
			if (found != null)
			{
				return found;
			}
			dynamicProperties[dynamic] = dynamic;
			return dynamic;
		}
コード例 #21
0
        /// <summary>
        /// Update existing dynamic property 
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="typeName"></param>
        /// <param name="propertyId"></param>
        /// <param name="property"></param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<object>> DynamicPropertiesUpdatePropertyAsyncWithHttpInfo(string typeName, string propertyId, DynamicProperty property)
        {
            // verify the required parameter 'typeName' is set
            if (typeName == null)
                throw new ApiException(400, "Missing required parameter 'typeName' when calling VirtoCommercePlatformApi->DynamicPropertiesUpdateProperty");
            // verify the required parameter 'propertyId' is set
            if (propertyId == null)
                throw new ApiException(400, "Missing required parameter 'propertyId' when calling VirtoCommercePlatformApi->DynamicPropertiesUpdateProperty");
            // verify the required parameter 'property' is set
            if (property == null)
                throw new ApiException(400, "Missing required parameter 'property' when calling VirtoCommercePlatformApi->DynamicPropertiesUpdateProperty");

            var localVarPath = "/api/platform/dynamic/types/{typeName}/properties/{propertyId}";
            var localVarPathParams = new Dictionary<string, string>();
            var localVarQueryParams = new Dictionary<string, string>();
            var localVarHeaderParams = new Dictionary<string, string>(Configuration.DefaultHeader);
            var localVarFormParams = new Dictionary<string, string>();
            var localVarFileParams = new Dictionary<string, FileParameter>();
            object localVarPostBody = null;

            // to determine the Content-Type header
            string[] localVarHttpContentTypes = new string[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            string[] localVarHttpHeaderAccepts = new string[] {
            };
            string localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (typeName != null) localVarPathParams.Add("typeName", ApiClient.ParameterToString(typeName)); // path parameter
            if (propertyId != null) localVarPathParams.Add("propertyId", ApiClient.ParameterToString(propertyId)); // path parameter
            if (property.GetType() != typeof(byte[]))
            {
                localVarPostBody = ApiClient.Serialize(property); // http body (model) parameter
            }
            else
            {
                localVarPostBody = property; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await ApiClient.CallApiAsync(localVarPath,
                Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException(localVarStatusCode, "Error calling DynamicPropertiesUpdateProperty: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException(localVarStatusCode, "Error calling DynamicPropertiesUpdateProperty: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            
            return new ApiResponse<object>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
コード例 #22
0
ファイル: ColumnAttribute.cs プロジェクト: supuy-ruby/Aoite
        /// <summary>
        /// 指定一个实例,获取指定属性的值。
        /// </summary>
        /// <param name="property">动态属性。</param>
        /// <param name="instance">一个实例,null 值表示静态属性。</param>
        /// <returns>属性的值。</returns>
        public object GetValue(DynamicProperty property, object instance)
        {
            var s = property.GetValue(instance, false);

            return ObjectFactory.Context.Get<IJsonProvider>().Serialize(s);
        }
コード例 #23
0
        public override void OnValueChanged(DynamicProperty prop)
        {
            base.OnValueChanged(prop);

              EntityShape entity = Owner as EntityShape;
              Debug.Assert(entity != null);

              if (entity.HasEngineInstance())
              {
            string varValue = AsEntityString(prop);
            entity.EngineEntity.SetVariable(prop.PropertyType.Name, varValue);
            if (entity.ParentLayer != null)
              entity.ParentLayer.Modified = true;
              }
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: vsrz/desbot_vsrz
 static void OnQuoteIntervalChanged(DynamicProperty<int, int> prop)
 {
     quoteinterval = prop.Value;
     SetQuoteTimer();
 }
コード例 #25
0
        public BuyItemFromAhAction()
        {
            Properties["ItemID"] = new MetaProp("ItemID", typeof(string));
            Properties["MaxBuyout"] = new MetaProp("MaxBuyout", typeof(PropertyBag.GoldEditor),
                new DisplayNameAttribute("Max Buyout"), new TypeConverterAttribute(typeof(PropertyBag.GoldEditorConverter)));
            Properties["Amount"] = new MetaProp("Amount", typeof(DynamicProperty<int>),
                new TypeConverterAttribute(typeof(DynamicProperty<int>.DynamivExpressionConverter)));
            Properties["ItemListType"] = new MetaProp("ItemListType", typeof(ItemType), new DisplayNameAttribute("Buy ..."));
            Properties["AutoFindAh"] = new MetaProp("AutoFindAh", typeof(bool), new DisplayNameAttribute("Auto find AH"));
            Properties["BuyAdditively"] = new MetaProp("BuyAdditively", typeof(bool), new DisplayNameAttribute("Buy Additively"));

            Properties["BidOnItem"] = new MetaProp("BidOnItem", typeof(bool), new DisplayNameAttribute("Bid on Item"));
            Properties["Location"] = new MetaProp("Location", typeof(string), new EditorAttribute(typeof(PropertyBag.LocationEditor), typeof(UITypeEditor)));

            ItemID = "";
            Amount = new DynamicProperty<int>(this, "1");
            RegisterDynamicProperty("Amount");
            ItemListType = ItemType.Item;
            AutoFindAh = true;
            _loc = WoWPoint.Zero;
            Location = _loc.ToInvariantString();
            MaxBuyout = new PropertyBag.GoldEditor("100g0s0c");
            BidOnItem = false;
            BuyAdditively = true;

            Properties["AutoFindAh"].PropertyChanged += AutoFindAHChanged;
            Properties["ItemListType"].PropertyChanged += BuyItemFromAhActionPropertyChanged;
            Properties["Location"].PropertyChanged += LocationChanged;
            Properties["Amount"].Show = true;
            Properties["Location"].Show = false;
        }
コード例 #26
0
 /// <summary>
 /// Add new dynamic property 
 /// </summary>
 /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="typeName"></param>
 /// <param name="property"></param>
 /// <returns>DynamicProperty</returns>
 public DynamicProperty DynamicPropertiesCreateProperty(string typeName, DynamicProperty property)
 {
      ApiResponse<DynamicProperty> localVarResponse = DynamicPropertiesCreatePropertyWithHttpInfo(typeName, property);
      return localVarResponse.Data;
 }