public void AddValueChanged(object component, EventHandler handler)
        {
            var objType = component.GetType();

            if (objType.GetInterface(typeof(IEnumerable).FullName) != null)
            {
                foreach (var objIns in (IEnumerable)component)
                {
                    if (objIns == null)
                    {
                        continue;
                    }
                    var tempType = objIns.GetType();
                    PropertyDescriptor pd;
                    if (Propertys.TryGetValue(tempType, out pd))
                    {
                        pd.AddValueChanged(objIns, handler);
                    }
                }
            }
            else
            {
                PropertyDescriptor pd;
                if (Propertys.TryGetValue(objType, out pd))
                {
                    pd.AddValueChanged(component, handler);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 活動物件每回合動作
        /// </summary>
        public override void Action()
        {
            Skills.AllDoAutoCast();
            // 回合前
            Skills.AllDoBeforeAction();
            Propertys.AllDoBeforeAction();
            // 能量調整前
            Skills.AllDoBeforeActionEnergyGet();
            Propertys.AllDoBeforeActionEnergyGet();
            // 能量調整
            ActionEnergyGet();
            // 移動規劃前
            Skills.AllDoBeforeActionPlan();
            Propertys.AllDoBeforeActionPlan();
            // 移動規劃
            MoveObject.Plan();
            // 移動動作前
            Skills.AllDoBeforeActionMove();
            Propertys.AllDoBeforeActionMove();
            // 移動動作
            MoveObject.Move();
            // 回合後
            Skills.AllDoAfterAction();
            Propertys.AllDoAfterAction();
            // 結算
            Settlement();
            Skills.AllSettlement();
            Propertys.AllSettlement();

            OnAfterAction();
            Propertys.ClearAllDisabled();
        }
Exemplo n.º 3
0
        /// <summary>
        ///     When alternating the Configuration you have to call this method to renew the property enumerations.
        ///     This also happens after the usage of the config attribute
        /// </summary>
        public void Refresh(bool withSubProperty)
        {
            if (withSubProperty)
            {
                foreach (var propertyInfoCach in Propertys)
                {
                    propertyInfoCach.Value.Refresh();
                }
            }

            ForModel = DbAttributeInfoCache <ForModelAttribute> .WrapperOrNull(Attributes);

            SelectFactory = DbAttributeInfoCache <SelectFactoryAttribute> .WrapperOrNull(Attributes);

            var preConfig = MethodProxyAttribute == null;

            MethodProxyAttribute = DbAttributeInfoCache <MethodProxyAttribute> .WrapperOrNull(Attributes);

            HasRelations = Attributes.Any(s => s.Attribute is ForeignKeyAttribute);

            RowVersionProperty = Propertys.FirstOrDefault(s => s.Value.RowVersionAttribute != null).Value;
            PrimaryKeyProperty = Propertys.FirstOrDefault(s => s.Value.PrimaryKeyAttribute != null).Value;

            CreateSchemaMapping();
        }
Exemplo n.º 4
0
 private void SetPropertys()
 {
     for (int i = 0; i < MaxPropertyCount; i++)
     {
         Propertys.Add(null);
     }
 }
Exemplo n.º 5
0
        <DbPropertyInfoCache, DbAttributeInfoCache, DbMethodInfoCache, DbConstructorInfoCache, DbMethodArgument> Init(
            Type type, bool anon = false)
        {
            var item = base.Init(type, anon);

            //.ToDictionary(s => s.Key);
            Propertys = new Dictionary <string, DbPropertyInfoCache>(Propertys
                                                                     .Where(f => f.Value.Attributes.All(e => !(e.Attribute is IgnoreReflectionAttribute)))
                                                                     .ToDictionary(s => s.Key, f => f.Value));
            Mehtods =
                new HashSet <DbMethodInfoCache>(
                    Mehtods.Where(f => f.Attributes.All(d => !(d.Attribute is IgnoreReflectionAttribute))));
            Constructors =
                new HashSet <DbConstructorInfoCache>(
                    Constructors.Where(f => f.Attributes.All(e => !(e.Attribute is IgnoreReflectionAttribute))));
            foreach (var dbPropertyInfoCach in Propertys)
            {
                dbPropertyInfoCach.Value.DeclaringClass = this;
            }
            foreach (var dbPropertyInfoCach in Mehtods)
            {
                dbPropertyInfoCach.DeclaringClass = this;
            }
            foreach (var dbPropertyInfoCach in Constructors)
            {
                dbPropertyInfoCach.DeclaringClass = this;
            }

            Refresh(true);
            return(item);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 封装为实体对象
        /// </summary>
        /// <param name="reader">数据库读取器</param>
        /// <returns>实体对象的泛型集合</returns>
        protected List <TModel> GetModels(IDataReader reader)
        {
            var list = new List <TModel>();

            while (reader.Read())
            {
                TModel entry = new TModel();
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    string       name = reader.GetName(i);
                    PropertyInfo property;
                    if (Propertys.TryGetValue(name, out property))
                    {
                        SetValue(entry, property.Name, IsNull(property, reader[property.Name]));
                    }
                    else
                    {
                        //对象包含此属性时添加到基类集合中
                        SetValue(entry, "Item", reader[name], new object[] { name });
                    }
                }
                list.Add(entry);
            }
            reader.Close();
            return(list);
        }
Exemplo n.º 7
0
 public void Clear()
 {
     Propertys.Clear();
     Cache.ClearCache();
     //PropertyNames.Clear();
     DataArray = null;
     //PropertyNames = null;
     Propertys = null;
 }
Exemplo n.º 8
0
 /// <summary>
 /// 殺死此物件
 /// </summary>
 /// <param name="killer">殺手物件</param>
 /// <param name="deadType">死亡類型</param>
 public virtual void Kill(ObjectBase killer, ObjectDeadType deadType)
 {
     if (Status == ObjectStatus.Alive)
     {
         Status = ObjectStatus.Dead;
         Propertys.AllDoAfterDead(killer, deadType);
         OnDead(this, killer, deadType);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 釋放物件時執行動作
        /// </summary>
        protected virtual void OnDispose()
        {
            if (DrawObject != null)
            {
                DrawObject.Dispose();
            }

            Propertys.Clear();
            MoveObject = MoveNull.Value;
        }
Exemplo n.º 10
0
 public override void Draw(Graphics g)
 {
     if (Visible)
     {
         Propertys.AllDoBeforeDraw(g);
         DrawObject.Draw(g, Layout.Rectangle);
         UIObjects.AllDrawSelf(g);
         Propertys.AllDoAfterDraw(g);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 繪製物件
 /// </summary>
 /// <param name="g">Graphics物件</param>
 public virtual void Draw(Graphics g)
 {
     if (Visible)
     {
         UIOffSetY = 0;
         Propertys.AllDoBeforeDraw(g);
         DrawObject.Draw(g, Layout.Rectangle);
         Propertys.AllDoAfterDraw(g);
     }
 }
        public object GetPropertyOwner(ICustomTypeDescriptor ins)
        {
            PropertyDescriptor pd;

            if (Propertys.TryGetValue(ins.GetType(), out pd))
            {
                return(ins.GetPropertyOwner(pd));
            }
            return(null);
        }
Exemplo n.º 13
0
 /// <summary>
 /// 新增虛擬物件,會逐漸縮小(放大)並淡出後消失
 /// </summary>
 /// <param name="x">物件位置X</param>
 /// <param name="y">物件位置Y</param>
 /// <param name="width">物件寬度</param>
 /// <param name="height">物件高度</param>
 /// <param name="fadeTime">淡出時間(毫秒),小於0為永久</param>
 /// <param name="finelScale">計時器結束時大小比例</param>
 /// <param name="finelOpacity">計時器結束時透明度</param>
 /// <param name="drawObject">繪製物件</param>
 /// <param name="moveObject">移動物件</param>
 public ObjectSmoke(float x, float y, int width, int height, int fadeTime, float finelScale, float finelOpacity, DrawBase drawObject, MoveBase moveObject) :
     base(drawObject, moveObject)
 {
     Layout.CollisonShape = ShapeType.Ellipse;
     Layout.Anchor        = DirectionType.Center;
     Layout.X             = x;
     Layout.Y             = y;
     Layout.Width         = width;
     Layout.Height        = height;
     Propertys.Add(new PropertyDeadSmoke(fadeTime, finelScale, finelOpacity, ObjectDeadType.All));
     Kill(null, ObjectDeadType.LifeEnd);
 }
Exemplo n.º 14
0
 /// <summary>
 /// 繪製物件
 /// </summary>
 /// <param name="g">Graphics物件</param>
 public override void Draw(Graphics g)
 {
     if (Visible)
     {
         UIOffSetY = 0;
         Skills.AllDoBeforeDraw(g);
         Propertys.AllDoBeforeDraw(g);
         DrawObject.Draw(g, Layout.Rectangle);
         Propertys.AllDoAfterDraw(g);
         Skills.AllDoAfterDraw(g);
     }
 }
Exemplo n.º 15
0
        public string BuyersOptions(Propertys estate)
        {
            if (estate.CanBeSold)
            {
                return("for sale");
            }

            else
            {
                return("for rent");
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 指定されたインデックスパラメータを使用するインデクサへのアクセスを提供する<see cref="IndexerReflector{T}"/>を返します
        /// </summary>
        /// <param name="indexes">インデクサインデックスのパラメータ</param>
        /// <exception cref="System.MemberAccessException">指定されたインデクサは存在しません</exception>
        public IndexerReflector <T> IndexerExact <T>(params ReflectionParameter[] indexes)
        {
            PropertyInfo info = null;
            var          key  = ("Indexer:" + string.Join(",", indexes.Select(t => { return(t.Type.Name); }))).GetHashCode();

            if (!Propertys.TryGetValue(key, out info))
            {
                if (!PropertyReflector <T> .TryGetIndexerInfo(m_Reflector.Flags, m_Type, indexes.Select(i => i.Type).ToArray(), out info))
                {
                    throw new MemberAccessException("指定されたインデクサは存在しません");
                }
                Propertys.Add(key, info);
            }
            return(new IndexerReflector <T>(info, m_InstanceObject, indexes));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 指定された名前のプロパティへのアクセスを提供する<see cref="PropertyReflector{T}"/>を返します。
        /// </summary>
        /// <param name="name">プロパティの名前を表す文字列</param>
        /// <typeparam name="T">プロパティの型</typeparam>
        /// <returns></returns>
        /// <exception cref="System.MemberAccessException">指定されたプロパティは存在しません</exception>
        public PropertyReflector <T> Property <T>(string name)
        {
            PropertyInfo info = null;
            var          key  = name.GetHashCode();

            if (!Propertys.TryGetValue(key, out info))
            {
                if (!PropertyReflector <T> .TryGetPropertyInfo(m_Reflector.Flags, m_Type, name, out info))
                {
                    throw new MemberAccessException("指定されたプロパティは存在しません");
                }
                Propertys.Add(key, info);
            }
            return(new PropertyReflector <T>(info, m_InstanceObject));
        }
Exemplo n.º 18
0
 public override void Init()
 {
     base.Init();
     TextAsset constXmlAsset = Resources.Load<TextAsset>("PlatformConst");
     if(constXmlAsset == null)
     {
         Debug.logger.LogError("PlatformHelper", "PlatformConst加载失败");
         return;
     }
     Propertys constProp = Propertys.LoadXml(constXmlAsset.text);
     string sdkList = constProp.GetProperty("SdkList");
     if (!string.IsNullOrEmpty(sdkList))
     {
         LoadAllSdk(sdkList);
     }
 }
Exemplo n.º 19
0
 public T this[string propertyName]//索引器
 {
     get
     {
         if (!Propertys.ContainsKey(propertyName))
         {
             return(default(T));
         }
         return((T)Propertys[propertyName].GetValue(this));
     }
     set
     {
         if (!Propertys.ContainsKey(propertyName))
         {
             return;
         }
         Propertys[propertyName].SetValue(this, value);
     }
 }
 public object GetValue(object ins, bool useProvider = true)
 {
     if (ins == null)
     {
         return(null);
     }
     if (ins.GetType().GetInterface(typeof(IEnumerable).FullName) != null)
     {
         var multiVals = new PropertyMultiValue();
         foreach (var objIns in (IEnumerable)ins)
         {
             PropertyDescriptor dicPro;
             if (Propertys.TryGetValue(objIns.GetType(), out dicPro))
             {
                 var val = _ProGetValue(dicPro, objIns, useProvider);
                 multiVals.Values.Add(val);
             }
             System.Reflection.FieldInfo field;
             if (Fields.TryGetValue(objIns.GetType(), out field))
             {
                 var val = _FieldGetValue(field, objIns, useProvider);
                 multiVals.Values.Add(val);
             }
         }
         return(multiVals.GetValue());
     }
     else
     {
         PropertyDescriptor dicPro;
         if (Propertys.TryGetValue(ins.GetType(), out dicPro))
         {
             return(_ProGetValue(dicPro, ins, useProvider));
         }
         System.Reflection.FieldInfo field;
         if (Fields.TryGetValue(ins.GetType(), out field))
         {
             return(_FieldGetValue(field, ins, useProvider));
         }
     }
     return(null);
 }
Exemplo n.º 21
0
        /// <summary>
        /// 物件在1回合內進行的活動
        /// </summary>
        public virtual void Action()
        {
            // 回合前
            Propertys.AllDoBeforeAction();
            // 移動規劃前
            Propertys.AllDoBeforeActionPlan();
            // 移動規劃
            MoveObject.Plan();
            // 移動動作前
            Propertys.AllDoBeforeActionMove();
            // 移動動作
            MoveObject.Move();
            // 回合後
            Propertys.AllDoAfterAction();
            // 結算
            Settlement();
            Propertys.AllSettlement();

            OnAfterAction();
            Propertys.ClearAllDisabled();
        }
 public void SetValue(ref object ins, ref object value)
 {
     if (ins == null)
     {
         return;
     }
     if (ins.GetType().GetInterface(typeof(IEnumerable).FullName) != null)
     {
         foreach (var objIns in (IEnumerable)ins)
         {
             var obj = objIns;
             PropertyDescriptor dicPro;
             if (Propertys.TryGetValue(obj.GetType(), out dicPro))
             {
                 _ProSetValue(dicPro, ref obj, ref value);
             }
             System.Reflection.FieldInfo field;
             if (Fields.TryGetValue(ins.GetType(), out field))
             {
                 _FieldSetValue(field, ref obj, ref value);
             }
         }
     }
     else
     {
         PropertyDescriptor dicPro;
         if (Propertys.TryGetValue(ins.GetType(), out dicPro))
         {
             _ProSetValue(dicPro, ref ins, ref value);
         }
         System.Reflection.FieldInfo field;
         if (Fields.TryGetValue(ins.GetType(), out field))
         {
             _FieldSetValue(field, ref ins, ref value);
         }
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// 物件移動中進行的活動
 /// </summary>
 public virtual void Moving()
 {
     Propertys.AllDoActionMoving();
 }
Exemplo n.º 24
0
        public ObjectUIHighScore(DirectionType anchor, int x, int y, MoveBase moveObject, ISceneInfo sceneInfo)
            : base(anchor, x, y, 380, 390, new DrawUIFrame(Color.AliceBlue, Color.CornflowerBlue, 2, 20), moveObject)
        {
            Propertys.Add(new PropertyShadow(0, 6, 0.95F, 1));

            DrawUIText drawCommandClose      = new DrawUIText(Color.RoyalBlue, Color.Gray, Color.FromArgb(175, 220, 230, 255), Color.FromArgb(100, 140, 255), 1, 10, "關 閉", new Font("微軟正黑體", 14), GlobalFormat.MiddleCenter);
            DrawUIText drawCommandCloseHover = new DrawUIText(Color.RoyalBlue, Color.Gray, Color.FromArgb(220, 255, 250, 235), Color.FromArgb(100, 140, 255), 1, 10, "關 閉", new Font("微軟正黑體", 14), GlobalFormat.MiddleCenter);

            _CommandClose = new ObjectUI(285, 10, 75, 30, drawCommandClose)
            {
                DrawObjectHover = drawCommandCloseHover
            };
            _CommandClose.Propertys.Add(new PropertyShadow(2, 2)
            {
                RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F
            });
            _CommandClose.Layout.Depend.Anchor = DirectionType.TopLeft;
            _CommandClose.Layout.Depend.SetObject(this);
            _CommandClose.Click += (s, e) => { OnClose(); };
            UIObjects.Add(_CommandClose);

            if (sceneInfo == null)
            {
                return;
            }
            _SceneInfo = sceneInfo;
            int itemWidth  = 40;
            int itemHeight = 25;
            int left       = 15;
            int top        = 15;

            _SceneButtons = new ObjectUI[sceneInfo.MaxLevel];
            for (int i = 0; i < sceneInfo.MaxLevel; i++)
            {
                int         idx        = i + 1;
                DrawUIFrame drawObject = new DrawUIFrame(Color.FromArgb(175, 255, 255, 255), Color.FromArgb(100, 140, 255), 1, 8)
                {
                    Scale = 0.8F
                };
                ObjectUI newObject = new ObjectUI(left, top, itemWidth, itemHeight, drawObject);
                newObject.Layout.Depend.SetObject(this);
                newObject.Layout.Depend.Anchor = DirectionType.TopLeft;
                newObject.Propertys.Add(new PropertyShadow(3, 3)
                {
                    Opacity = 0.2F, ScaleX = 0.95F, ScaleY = 0.95F
                });
                UIObjects.Add(newObject);
                left += itemWidth;

                drawObject.AfterDraw += (s, g, r) =>
                {
                    g.DrawString(idx.ToString(), _ItemFont, Brushes.RoyalBlue, r, GlobalFormat.MiddleCenter);
                };

                newObject.GetFocus += (s, e) =>
                {
                    (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.Red);
                    _HoverLevel = idx;
                };

                newObject.LostFocus += (s, e) =>
                {
                    (s as ObjectUI).DrawObject.Colors.SetColor("Border", Color.FromArgb(100, 140, 255));
                    _HoverLevel = 0;
                };

                newObject.Click += (s, e) =>
                {
                    SelectedIndex = _HoverLevel;
                };

                _SceneButtons[i] = newObject;
            }
            SelectedIndex = 1;

            DrawUIFrame drawPanel = new DrawUIFrame(Color.FromArgb(180, 220, 240, 250), Color.Empty, 0, 0);
            ObjectUI    panel     = new ObjectUI(10, 50, Layout.Width - 20, Layout.Height - 60, drawPanel);

            panel.Propertys.Add(new PropertyShadow(-2, -2));
            panel.Layout.Depend.SetObject(this);
            panel.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top;
            UIObjects.Add(panel);

            _DrawRects = new DrawUIText[3, 10];
            _DrawInfos = new string[3, 10];
            int rectLeft = 5, rectTop = 5;
            int rectHeight = 27;

            for (int i = 0; i < 10; i++)
            {
                _DrawRects[0, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.AliceBlue, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleCenter);
                _DrawRects[1, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.WhiteSmoke, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleLeft);
                _DrawRects[2, i] = new DrawUIText(Color.RoyalBlue, Color.Empty, Color.WhiteSmoke, Color.Empty, 0, 0, "", _ItemFont2, GlobalFormat.MiddleRight);

                ObjectUI object1 = new ObjectUI(rectLeft, rectTop, 35, rectHeight, _DrawRects[0, i]);
                ObjectUI object2 = new ObjectUI(rectLeft + 40, rectTop, 210, rectHeight, _DrawRects[1, i]);
                ObjectUI object3 = new ObjectUI(rectLeft + 255, rectTop, 90, rectHeight, _DrawRects[2, i]);

                object1.Propertys.Add(new PropertyShadow(2, 2));
                object2.Propertys.Add(new PropertyShadow(2, 2));
                object3.Propertys.Add(new PropertyShadow(2, 2));
                object1.Layout.Depend.SetObject(panel);
                object2.Layout.Depend.SetObject(panel);
                object3.Layout.Depend.SetObject(panel);
                object1.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top;
                object2.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top;
                object3.Layout.Depend.Anchor = DirectionType.Left | DirectionType.Top;
                UIObjects.Add(object1);
                UIObjects.Add(object2);
                UIObjects.Add(object3);

                rectTop += rectHeight + 5;
            }

            _DrawCommandMessage = new DrawUIText(Color.Red, Color.Gray, Color.LightYellow, Color.Black, 1, 0, "連線中...", new Font("微軟正黑體", 20), GlobalFormat.MiddleCenter);
            _CommandMessage     = new ObjectUI(DirectionType.Center, 0, 0, 200, 60, _DrawCommandMessage);
            _CommandMessage.Layout.Depend.SetObject(this);
            _CommandMessage.Layout.Depend.Anchor = DirectionType.Center;
            _CommandMessage.Propertys.Add(new PropertyShadow(2, 4));
            UIObjects.Add(_CommandMessage);
            LoadData();
        }
Exemplo n.º 25
0
        public virtual IClassInfoCache <TProp, TAttr, TMeth, TCtor, TArg> Init(Type type, bool anon = false)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (!String.IsNullOrEmpty(Name))
            {
                throw new InvalidOperationException("The object is already Initialed. A Change is not allowed");
            }

            Name = type.FullName;
            Type = type;

            if (Type.IsInterface)
            {
                anon = true;
            }

            foreach (var attributeInfoCach in type
                     .GetCustomAttributes(true)
                     .Where(s => s is Attribute)
                     .Select(s => new TAttr().Init(s as Attribute) as TAttr))
            {
                Attributes.Add(attributeInfoCach);
            }
            foreach (var propertyInfoCach in type
                     .GetProperties(BindingFlags.Public | BindingFlags.Static |
                                    BindingFlags.NonPublic | BindingFlags.Instance)
                     .Where(e => !e.GetIndexParameters().Any())
                     .Select(s => new TProp().Init(s, anon) as TProp)
                     .ToDictionary(s => s.PropertyName, s => s))
            {
                Propertys.Add(propertyInfoCach.Key, propertyInfoCach.Value);
            }

            foreach (var methodInfoCach in type
                     .GetMethods(BindingFlags.Public | BindingFlags.Static |
                                 BindingFlags.NonPublic | BindingFlags.Instance)
                     .Select(s => new TMeth().Init(s) as TMeth))
            {
                Mehtods.Add(methodInfoCach);
            }

            foreach (var constructor in type
                     .GetConstructors(BindingFlags.Public | BindingFlags.Static |
                                      BindingFlags.NonPublic | BindingFlags.Instance)
                     .Select(s => new TCtor().Init(s) as TCtor))
            {
                Constructors.Add(constructor);
            }
            var defaultConstructor = Constructors.FirstOrDefault(f => !f.Arguments.Any());

            IsMsCoreFrameworkType = type.Assembly == MsCoreLibAssembly;

            //if (type.IsValueType)
            //{
            //	var dm = new DynamicMethod("InvokeDefaultCtorFor" + ClassName, Type, System.Type.EmptyTypes, Type, true);
            //	var il = dm.GetILGenerator();
            //	il.Emit(OpCodes.Initobj, type);
            //	var ctorDelegate = dm.CreateDelegate(typeof(Func<>).MakeGenericType(type));
            //	DefaultFactory = new TMeth().Init(ctorDelegate.Method, type) as TMeth;
            //}
            //else if (defaultConstructor != null)
            //{
            //	var dm = new DynamicMethod("InvokeDefaultCtorFor" + ClassName, Type, System.Type.EmptyTypes, Type, true);
            //	var il = dm.GetILGenerator();
            //	il.Emit(OpCodes.Newobj);
            //	var ctorDelegate = dm.CreateDelegate(typeof(Func<>).MakeGenericType(type));
            //	DefaultFactory = new TMeth().Init(ctorDelegate.Method, type) as TMeth;
            //}

            if (type.IsValueType || defaultConstructor != null)
            {
                Expression defaultExpression = null;

                if (type.IsValueType)
                {
                    defaultExpression = Expression.Default(type);
                }
                else if (defaultConstructor != null)
                {
                    defaultExpression = Expression.New(defaultConstructor.MethodInfo as ConstructorInfo);
                }

                var expressionInvoker = MetaInfoStoreExtentions.GetExpressionLambda();

                var createLambda = expressionInvoker
                                   .MakeGenericMethod(typeof(Func <>).MakeGenericType(type))
                                   .Invoke(null, new object[] { defaultExpression, new List <ParameterExpression>() });

                DefaultFactory = MetaInfoStoreExtentions.GetCompileMethodFromExpression(createLambda.GetType())
                                 .Invoke(createLambda, null);
            }

            return(this);
        }
Exemplo n.º 26
0
 public void Clear()
 {
     Cache.ClearCache();
     Propertys.Clear();
     DataArray = null;
 }
Exemplo n.º 27
0
        public ObjectUINameSetting(DirectionType anchor, int x, int y, MoveBase moveObject)
            : base(anchor, x, y, 310, 125, new DrawUIFrame(Color.AliceBlue, Color.CornflowerBlue, 2, 20), moveObject)
        {
            Propertys.Add(new PropertyShadow(0, 6, 0.95F, 1));

            // 玩家姓名
            _DrawPlayerName = new DrawUITextScroll(Color.Maroon, Color.LightGray, Color.FromArgb(230, 255, 245), Color.CornflowerBlue, 1, 10, GlobalPlayer.PlayerName, new Font("細明體", 12), GlobalFormat.MiddleLeft, 120)
            {
                TextPadding = new Padding(10, 10, 0, 5)
            };
            ObjectUI uiPlayerName = new ObjectUI(20, 60, 270, 40, _DrawPlayerName);

            // 重新選取
            DrawUIText drawCommandBuildName = new DrawUIText(Color.CornflowerBlue, Color.Empty, Color.Empty, Color.Empty, 0, 0, "↻", new Font("標楷體", 22, FontStyle.Bold), GlobalFormat.MiddleCenter)
            {
                TextPadding = new Padding(0, 10, 0, 0)
            };
            DrawUIText drawCommandBuildNameHover = new DrawUIText(Color.Orange, Color.Empty, Color.Empty, Color.Empty, 0, 0, "↻", new Font("標楷體", 22, FontStyle.Bold), GlobalFormat.MiddleCenter)
            {
                TextPadding = new Padding(0, 10, 0, 0)
            };
            ObjectUI uiCommandBuildName = new ObjectUI(250, 60, 40, 40, drawCommandBuildName)
            {
                DrawObjectHover = drawCommandBuildNameHover
            };

            DrawUIText drawCommandOK      = new DrawUIText(Color.FromArgb(100, 220, 100), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✔", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter);
            DrawUIText drawCommandOKHover = new DrawUIText(Color.FromArgb(0, 180, 0), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✔", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter);

            _CommandOK = new ObjectUI(230, 15, 30, 30, drawCommandOK)
            {
                Visible = false, DrawObjectHover = drawCommandOKHover
            };
            _CommandOK.Propertys.Add(new PropertyShadow(2, 2)
            {
                RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F
            });

            DrawUIText drawCommandClose      = new DrawUIText(Color.FromArgb(255, 150, 150), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✘", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter);
            DrawUIText drawCommandCloseHover = new DrawUIText(Color.FromArgb(255, 70, 70), Color.Empty, Color.Empty, Color.Empty, 0, 0, "✘", new Font("微軟正黑體", 16, FontStyle.Bold), GlobalFormat.MiddleCenter);

            _CommandClose = new ObjectUI(260, 15, 30, 30, drawCommandClose)
            {
                Visible = !string.IsNullOrWhiteSpace(GlobalPlayer.PlayerName), DrawObjectHover = drawCommandCloseHover
            };
            _CommandClose.Propertys.Add(new PropertyShadow(2, 2)
            {
                RFix = -0.5F, GFix = -0.5F, BFix = -0.5F, Opacity = 0.2F
            });

            uiPlayerName.Layout.Depend.Anchor       = DirectionType.TopLeft;
            uiCommandBuildName.Layout.Depend.Anchor = DirectionType.TopLeft;
            _CommandOK.Layout.Depend.Anchor         = DirectionType.TopLeft;
            _CommandClose.Layout.Depend.Anchor      = DirectionType.TopLeft;

            uiCommandBuildName.Layout.Depend.SetObject(this);
            uiPlayerName.Layout.Depend.SetObject(this);
            _CommandOK.Layout.Depend.SetObject(this);
            _CommandClose.Layout.Depend.SetObject(this);

            uiCommandBuildName.Click += (s, e) =>
            {
                _DrawPlayerName.Text = Function.GetRandName();
                _CommandOK.Visible   = true;
            };

            _CommandOK.Click += (s, e) =>
            {
                GlobalPlayer.PlayerName = _DrawPlayerName.Text;
                GlobalPlayer.WriteRegistry();
                OnClose();
            };

            _CommandClose.Click += (s, e) => { OnClose(); };

            UIObjects.Add(uiPlayerName);
            UIObjects.Add(uiCommandBuildName);
            UIObjects.Add(_CommandOK);
            UIObjects.Add(_CommandClose);
        }