示例#1
0
        public Field_Common_System(ICLRSharp_Environment env, System.Reflection.FieldInfo field)
        {
            info = field;

            FieldType = env.GetType(field.FieldType);
            DeclaringType = env.GetType(field.DeclaringType);
        }
 public UndoSetField(object obj, string fieldname, object newValue)
 {
     Object = obj;
     FieldName = fieldname;
     field = Object.GetType().GetField(fieldname);
     NewValue = newValue;
 }
        public MultiPropertyAttributePropertyHandler(System.Reflection.FieldInfo fieldInfo, PropertyAttribute[] attribs)
        {
            if (fieldInfo == null) throw new System.ArgumentNullException("fieldInfo");
            if (attribs == null) throw new System.ArgumentNullException("attribs");
            _fieldInfo = fieldInfo;

            this.Init(attribs);
        }
        public SPPropertyAttributePropertyHandler(System.Reflection.FieldInfo fieldInfo, SPPropertyAttribute attrib)
        {
            if (fieldInfo == null) throw new System.ArgumentNullException("fieldInfo");
            if (attrib == null) throw new System.ArgumentNullException("attrib");

            _fieldInfo = fieldInfo;
            _attrib = attrib;
        }
示例#5
0
 public static IEnumerable<System.Reflection.FieldInfo> GetAllFields(Object obj)
 {
     System.Reflection.BindingFlags fieldFlags =
         //System.Reflection.BindingFlags.FlattenHierarchy |
         System.Reflection.BindingFlags.DeclaredOnly |
         System.Reflection.BindingFlags.GetField |
         System.Reflection.BindingFlags.Instance |
         System.Reflection.BindingFlags.NonPublic |
         System.Reflection.BindingFlags.Public |
         System.Reflection.BindingFlags.Static;
     System.Reflection.FieldInfo[] fields = new System.Reflection.FieldInfo[] { };
     //fields.Concat(fields);
     // move up through hierarchy to look for field
     Type objType = obj.GetType();
     while (objType != null)
     {
         fields = fields.Concat(objType.GetFields(fieldFlags)).ToArray();
         objType = objType.BaseType;
     }
     return fields;
 }
        public ProgramOption(System.Reflection.FieldInfo fieldInfo, OptionBase optionBase, ShortNameAttribute shortNameAttribute, LongNameAttribute longNameAttribute)
        {
            this.fieldInfo = fieldInfo;
            this.optionAttribute = optionBase;
            if (shortNameAttribute != null) {
                shortNames = shortNameAttribute.Names.AsReadOnly();
            }
            else {
                shortNames = new List<string>().AsReadOnly();
            }
            if (longNameAttribute != null) {
                longNames = longNameAttribute.Names.AsReadOnly();
            }
            else {
                longNames = new List<string>().AsReadOnly();
            }

            if (longNames.Count == 0 && shortNames.Count == 0)
            {
                throw new InvalidDefinitionException(fieldInfo.Name, "Options must have at least one name. Add ShortName and/or LongName attribute.");
            }
        }
 private static bool EditorStylesReady()
 {
     if(_sCurFi == null)
         _sCurFi = typeof(EditorStyles).GetField ("s_Current", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
     return (_sCurFi.GetValue (null) != null);
 }
示例#8
0
        //TODO: Сделать поля одиночками.
		public compiled_variable_definition(System.Reflection.FieldInfo fi) :
			base(fi.Name,compiled_type_node.get_type_node(fi.FieldType))
		{
			_fi=fi;
			_cont_type=compiled_type_node.get_type_node(fi.DeclaringType);
		}
示例#9
0
 private bool GetFieldValue(FieldInfo fi, PropertyLookupParams paramBag, ref object @value)
 {
     try
     {
         @value = fi.GetValue(paramBag.instance);
         return true;
     }
     catch(Exception ex)
     {
         paramBag.self.Error("Can't get property " + fi.Name
             + " using direct field access from " + paramBag.prototype.FullName
             + " instance", ex
             );
     }
     return false;
 }
示例#10
0
 public virtual System.Reflection.FieldInfo GetFieldInfo()
 {
     if(this.fieldInfo == null)
     {
         TypeNode tn = this.DeclaringType;
         if(tn == null)
             return null;
         Type t = tn.GetRuntimeType();
         if(t == null)
             return null;
         System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.DeclaredOnly;
         if(this.IsPublic)
             flags |= System.Reflection.BindingFlags.Public;
         else
             flags |= System.Reflection.BindingFlags.NonPublic;
         if(this.IsStatic)
             flags |= System.Reflection.BindingFlags.Static;
         else
             flags |= System.Reflection.BindingFlags.Instance;
         this.fieldInfo = t.GetField(this.Name.ToString(), flags);
     }
     return this.fieldInfo;
 }
示例#11
0
 private void cacheControllable()
 {
     if (commNetParams == null)
         commNetParams = HighLogic.CurrentGame.Parameters.CustomParams<CommNet.CommNetParams>();
     if (!parentVessel.IsControllable && commNetParams != null && commNetParams.requireSignalForControl)
     {
         // HACK: Get around inability to affect throttle if connection is lost and require
         if (isControllableField == null)
             isControllableField = parentVessel.GetType().GetField("isControllable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
         isControllableField.SetValue(parentVessel, true);
         workAroundControllable = true;
     }
     else
     {
         workAroundControllable = false;
     }
 }
示例#12
0
 static ListViewUtil()
 {
     listViewVirtualListSizeField = typeof(ListView).GetField("virtualListSize", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
     System.Diagnostics.Debug.Assert(listViewVirtualListSizeField != null, "System.Windows.Forms.ListView class no longer has a virtualListSize field.");
 }
 public SPPropertyAttributePropertyHandler(System.Reflection.FieldInfo fieldInfo, SPPropertyAttribute[] attribs)
 {
     _fieldInfo = fieldInfo;
     _attribs = attribs;
 }
示例#14
0
        private static System.Func<object, object> BuildAccessor(FieldInfo field)
        {
            ParameterExpression obj = Expression.Parameter(typeof(object), "obj");
            UnaryExpression instance = !field.IsStatic ? Expression.Convert(obj, field.DeclaringType) : null;
            Expression<System.Func<object, object>> expr = Expression.Lambda<System.Func<object, object>>(
                Expression.Convert(
                    Expression.Field(instance, field),
                    typeof(object)),
                obj);

            return expr.Compile();
        }
示例#15
0
        public StyleListBox()
        {
            // Initialize Components
            InitializeComponent();
            DoubleBuffered = true;
            Sorted = true;
            SetStyle(ControlStyles.ResizeRedraw, true);
            UpdateStyles();

            this.HorizontalScrollbar = true;
            this.maxWidthFieldInfo = typeof(ListBox).GetField("maxWidth", System.Reflection.BindingFlags.GetField
                                                                    | System.Reflection.BindingFlags.NonPublic
                                                                    | System.Reflection.BindingFlags.Instance);
            this.matrix = new Matrix();

            this.styleItemFormatter = new StringFormat(StringFormatFlags.NoWrap);
            this.styleItemFormatter.Trimming = StringTrimming.Character;
            this.styleItemFormatter.Alignment = StringAlignment.Near;
            this.styleItemFormatter.LineAlignment = StringAlignment.Center;

            this.specialItemFormatter = new StringFormat(StringFormatFlags.NoWrap);
            this.specialItemFormatter.Trimming = StringTrimming.Character;
            this.specialItemFormatter.Alignment = StringAlignment.Center;
            this.specialItemFormatter.LineAlignment = StringAlignment.Center;
        }
 /// <summary>
 /// Конструктор класса.
 /// </summary>
 public compiled_class_constant_definition(System.Reflection.FieldInfo fi, constant_node cn)
     : base(fi.Name, cn, null)
 {
     _comprehensive_type = compiled_type_node.get_type_node(fi.DeclaringType);
     _fi = fi;
 }
示例#17
0
        /// <summary>
        /// Copies the contents of the <see cref="FTBitmap"/> to a GDI+ <see cref="Bitmap"/>.
        /// </summary>
        /// <param name="color">The color of the text.</param>
        /// <returns>A GDI+ <see cref="Bitmap"/> containing this bitmap's data with a transparent background.</returns>
        public Bitmap ToGdipBitmap(Color color)
        {
            if (disposed)
                throw new ObjectDisposedException("FTBitmap", "Cannot access a disposed object.");

            if (rec.width == 0 || rec.rows == 0)
                throw new InvalidOperationException("Invalid image size - one or both dimensions are 0.");

            //TODO deal with negative pitch
            switch (rec.pixel_mode)
            {
                case PixelMode.Mono:
                {
                    Bitmap bmp = new Bitmap(rec.width, rec.rows, PixelFormat.Format1bppIndexed);
                    var locked = bmp.LockBits(new Rectangle(0, 0, rec.width, rec.rows), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed);

                    for (int i = 0; i < rec.rows; i++)
                        PInvokeHelper.Copy(Buffer, i * rec.pitch, locked.Scan0, i * locked.Stride, locked.Stride);

                    bmp.UnlockBits(locked);

                    ColorPalette palette = bmp.Palette;
                    palette.Entries[0] = Color.FromArgb(0, color);
                    palette.Entries[1] = Color.FromArgb(255, color);

                    bmp.Palette = palette;
                    return bmp;
                }

                case PixelMode.Gray4:
                {
                    Bitmap bmp = new Bitmap(rec.width, rec.rows, PixelFormat.Format4bppIndexed);
                    var locked = bmp.LockBits(new Rectangle(0, 0, rec.width, rec.rows), ImageLockMode.ReadWrite, PixelFormat.Format4bppIndexed);

                    for (int i = 0; i < rec.rows; i++)
                        PInvokeHelper.Copy(Buffer, i * rec.pitch, locked.Scan0, i * locked.Stride, locked.Stride);

                    bmp.UnlockBits(locked);

                    ColorPalette palette = bmp.Palette;
                    for (int i = 0; i < palette.Entries.Length; i++)
                    {
                        float a = (i * 17) / 255f;
                        palette.Entries[i] = Color.FromArgb(i * 17, (int)(color.R * a), (int)(color.G * a), (int)(color.B * a));
                    }

                    bmp.Palette = palette;
                    return bmp;
                }

                case PixelMode.Gray:
                {
                    Bitmap bmp = new Bitmap(rec.width, rec.rows, PixelFormat.Format8bppIndexed);
                    var locked = bmp.LockBits(new Rectangle(0, 0, rec.width, rec.rows), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);

                    for (int i = 0; i < rec.rows; i++)
                        PInvokeHelper.Copy(Buffer, i * rec.pitch, locked.Scan0, i * locked.Stride, locked.Stride);

                    bmp.UnlockBits(locked);

                    ColorPalette palette = bmp.Palette;
                    for (int i = 0; i < palette.Entries.Length; i++)
                    {
                        float a = i / 255f;
                        palette.Entries[i] = Color.FromArgb(i, (int)(color.R * a), (int)(color.G * a), (int)(color.B * a));
                    }

                    //HACK There's a bug in Mono's libgdiplus requiring the "PaletteHasAlpha" flag to be set for transparency to work properly
                    //See https://github.com/Robmaister/SharpFont/issues/62
                    if (!hasCheckedForMono)
                    {
                        hasCheckedForMono = true;
                        isRunningOnMono = Type.GetType("Mono.Runtime") != null;
                        if (isRunningOnMono)
                        {
                            monoPaletteFlagsField = typeof(ColorPalette).GetField("flags", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                        }
                    }

                    if (isRunningOnMono)
                        monoPaletteFlagsField.SetValue(palette, palette.Flags | 1);

                    bmp.Palette = palette;
                    return bmp;
                }

                case PixelMode.Lcd:
                {
                    //TODO apply color
                    int bmpWidth = rec.width / 3;
                    Bitmap bmp = new Bitmap(bmpWidth, rec.rows, PixelFormat.Format24bppRgb);
                    var locked = bmp.LockBits(new Rectangle(0, 0, bmpWidth, rec.rows), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

                    for (int i = 0; i < rec.rows; i++)
                        PInvokeHelper.Copy(Buffer, i * rec.pitch, locked.Scan0, i * locked.Stride, locked.Stride);

                    bmp.UnlockBits(locked);

                    return bmp;
                }
                /*case PixelMode.VerticalLcd:
                {
                    int bmpHeight = rec.rows / 3;
                    Bitmap bmp = new Bitmap(rec.width, bmpHeight, PixelFormat.Format24bppRgb);
                    var locked = bmp.LockBits(new Rectangle(0, 0, rec.width, bmpHeight), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
                    for (int i = 0; i < bmpHeight; i++)
                        PInvokeHelper.Copy(Buffer, i * rec.pitch, locked.Scan0, i * locked.Stride, rec.width);
                    bmp.UnlockBits(locked);

                    return bmp;
                }*/

                default:
                    throw new InvalidOperationException("System.Drawing.Bitmap does not support this pixel mode.");
            }
        }
示例#18
0
        /// <summary>
        /// Static initializer to read the deflateLevelField
        /// </summary>
        static FileArchiveZip()
        {
            System.Reflection.FieldInfo fi = null;

            try { fi = typeof(ZipWriter).GetField("deflateCompressionLevel", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); }
            catch { }

            _deflateLevelField = fi;

            if (fi == null)
                Logging.Log.WriteMessage("DeflateCompressionLevel is not supported, please report to developers", Duplicati.Library.Logging.LogMessageType.Warning);
        }
示例#19
0
 public ToolBoxPane()
 {
     InitializeComponent();
     listAll = new List<ToolboxItem>[] {
         listData_ti,
         listCustomControls_ti,
         listWindowsForms_ti,
         listComponents_ti };
     pointer = new ToolboxItem();
     pointer.DisplayName = "<Pointer>";
     pointer.Bitmap = global::VisualPascalABC.Properties.Resources.Pointer; //new Bitmap(16, 16);
     pointer.Bitmap.MakeTransparent(pointer.Bitmap.GetPixel(0, 0));
     pointerItem = new ListBarItem(pointer.DisplayName);
     pointerItem.Image = pointer.Bitmap;
     pointerItem.Tag = pointer;
     FillToolbox();
     listData.Tag = listData_ti;
     listWindowsForms.Tag = listWindowsForms_ti;
     listComponents.Tag = listComponents_ti;
     thisMouseTrack = typeof(ListBar).GetField("mouseTrack",
         System.Reflection.BindingFlags.Instance |
         System.Reflection.BindingFlags.NonPublic);
     foreach (ListBarGroup lg in listBar1.Groups)
     {
         lg.Caption = PascalABCCompiler.StringResources.Get(lg.Caption);
     }
     //listBar1.SelectedGroup.Items.
 }
示例#20
0
        private static void GetRealFuelsTypes()
        {
            hasCheckedForRealFuels = true;

            foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies)
            {
                MonoBehaviour.print("Assembly:" + assembly.assembly.ToString());

                if (assembly.assembly.ToString().Split(',')[0] == "RealFuels")
                {
                    MonoBehaviour.print("Found RealFuels mod");

                    Type RF_ModuleEngineConfigs_Type = assembly.assembly.GetType("RealFuels.ModuleEngineConfigs");
                    if (RF_ModuleEngineConfigs_Type != null)
                        RF_ModuleEngineConfigs_locaCorrectThrust = RF_ModuleEngineConfigs_Type.GetField("localCorrectThrust");

                    Type RF_ModuleHybridEngine_Type = assembly.assembly.GetType("RealFuels.ModuleHybridEngine");
                    if (RF_ModuleHybridEngine_Type != null)
                        RF_ModuleHybridEngine_locaCorrectThrust = RF_ModuleHybridEngine_Type.GetField("localCorrectThrust");

                    Type RF_ModuleHybridEngines_Type = assembly.assembly.GetType("RealFuels.ModuleHybridEngines");
                    if (RF_ModuleHybridEngines_Type != null)
                        RF_ModuleHybridEngines_locaCorrectThrust = RF_ModuleHybridEngines_Type.GetField("localCorrectThrust");

                    hasInstalledRealFuels = true;
                    break;
                }

            }
        }
示例#21
0
 public AnonymousClassPrivilegedAction(System.Reflection.FieldInfo field)
 {
     InitBlock(field);
 }
 bool isPropertyAutoField(FieldInfo fi)
 {
     return fi.Name.IndexOf("k__BackingField") >= 0;
 }
示例#23
0
文件: Symbol.cs 项目: chenzuo/blue
 public virtual void SetInfo(ICLRtypeProvider provider)
 {
     Debug.Assert(m_info == null);
     m_info = provider.CreateCLRField(this);
 }
示例#24
0
 static ExceptionHelperRefs() {
     CurrentExceptionRef = typeof(ExceptionHelper).GetField("CurrentException");
 }
 public ClassField(System.Reflection.FieldInfo field)
 {
     this._Field = field;
 }
示例#26
0
文件: NLS.cs 项目: sinsay/SSE
 private void InitBlock(System.Reflection.FieldInfo field)
 {
     this.field = field;
 }
示例#27
0
        static Func<object, object> BuildAccessor( FieldInfo field )
        {
            ParameterExpression obj = Expression.Parameter(typeof(object), "obj");
            Expression<Func<object, object>> expr = Expression.Lambda<Func<object, object>>(
                Expression.Convert(
                    Expression.Field(
                        Expression.Convert(obj, field.DeclaringType),
                        field),
                    typeof(object)),
                obj);

            return expr.Compile();
        }
示例#28
0
 internal FieldInfoImpl(System.Reflection.FieldInfo field)
 {
     Debug.Assert(field != null);
     this.Field = field;
 }
示例#29
0
        /** Deserializes an object of type tp.
         * Will load all fields into the \a populate object if it is set (only works for classes).
         */
        System.Object Deserialize(Type tp, System.Object populate = null)
        {
            var tpInfo = WindowsStoreCompatibility.GetTypeInfo(tp);

            if (tpInfo.IsEnum)
            {
                return(Enum.Parse(tp, EatField()));
            }
            else if (TryEat('n'))
            {
                Eat("ull");
                TryEat(',');
                return(null);
            }
            else if (Type.Equals(tp, typeof(float)))
            {
                return(float.Parse(EatField(), numberFormat));
            }
            else if (Type.Equals(tp, typeof(int)))
            {
                return(int.Parse(EatField(), numberFormat));
            }
            else if (Type.Equals(tp, typeof(uint)))
            {
                return(uint.Parse(EatField(), numberFormat));
            }
            else if (Type.Equals(tp, typeof(bool)))
            {
                return(bool.Parse(EatField()));
            }
            else if (Type.Equals(tp, typeof(string)))
            {
                return(EatField());
            }
            else if (Type.Equals(tp, typeof(Version)))
            {
                return(new Version(EatField()));
            }
            else if (Type.Equals(tp, typeof(Vector2)))
            {
                Eat("{");
                var result = new Vector2();
                EatField();
                result.x = float.Parse(EatField(), numberFormat);
                EatField();
                result.y = float.Parse(EatField(), numberFormat);
                Eat("}");
                return(result);
            }
            else if (Type.Equals(tp, typeof(Vector3)))
            {
                Eat("{");
                var result = new Vector3();
                EatField();
                result.x = float.Parse(EatField(), numberFormat);
                EatField();
                result.y = float.Parse(EatField(), numberFormat);
                EatField();
                result.z = float.Parse(EatField(), numberFormat);
                Eat("}");
                return(result);
            }
            else if (Type.Equals(tp, typeof(Pathfinding.Util.Guid)))
            {
                Eat("{");
                EatField();
                var result = Pathfinding.Util.Guid.Parse(EatField());
                Eat("}");
                return(result);
            }
            else if (Type.Equals(tp, typeof(LayerMask)))
            {
                Eat("{");
                EatField();
                var result = (LayerMask)int.Parse(EatField());
                Eat("}");
                return(result);
            }
            else if (Type.Equals(tp, typeof(List <string>)))
            {
                System.Collections.IList result = new List <string>();

                Eat("[");
                while (!TryEat(']'))
                {
                    result.Add(Deserialize(typeof(string)));
                    TryEat(',');
                }
                return(result);
            }
            else if (tpInfo.IsArray)
            {
                List <System.Object> ls = new List <System.Object>();
                Eat("[");
                while (!TryEat(']'))
                {
                    ls.Add(Deserialize(tp.GetElementType()));
                    TryEat(',');
                }
                var arr = Array.CreateInstance(tp.GetElementType(), ls.Count);
                ls.ToArray().CopyTo(arr, 0);
                return(arr);
            }
            else if (Type.Equals(tp, typeof(Mesh)) || Type.Equals(tp, typeof(Texture2D)) || Type.Equals(tp, typeof(Transform)) || Type.Equals(tp, typeof(GameObject)))
            {
                return(DeserializeUnityObject());
            }
            else
            {
                var obj = populate ?? Activator.CreateInstance(tp);
                Eat("{");
                while (!TryEat('}'))
                {
                    var name    = EatField();
                    var tmpType = tp;
                    System.Reflection.FieldInfo field = null;
                    while (field == null && tmpType != null)
                    {
                        field   = tmpType.GetField(name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
                        tmpType = tmpType.BaseType;
                    }

                    if (field == null)
                    {
                        SkipFieldData();
                    }
                    else
                    {
                        field.SetValue(obj, Deserialize(field.FieldType));
                    }
                    TryEat(',');
                }
                return(obj);
            }
        }