Пример #1
0
 public VolumeDescriptor(Hardware.Devices.DiskDevice disk, uint startBlock, uint numBlocks, byte[] data)
     : base(disk, 0, 0)
 {
     Code    = (TypeCodes)data[0];
     Id      = ByteConverter.GetASCIIStringFromASCII(data, 1, 5);
     Version = data[6];
 }
Пример #2
0
 /// <summary> 表示一个可以获取或者设置其内容的对象属性
 /// </summary>
 /// <param name="property">属性信息</param>
 public ObjectProperty(PropertyInfo property)
 {
     Field = false;
     MemberInfo = property; //属性信息
     OriginalType = property.PropertyType;
     var get = property.GetGetMethod(true); //获取属性get方法,不论是否公开
     var set = property.GetSetMethod(true); //获取属性set方法,不论是否公开
     if (set != null) //set方法不为空
     {
         CanWrite = true; //属性可写
         Static = set.IsStatic; //属性是否为静态属性
         IsPublic = set.IsPublic;
     }
     if (get != null) //get方法不为空
     {
         CanRead = true; //属性可读
         Static = get.IsStatic; //get.set只要有一个静态就是静态
         IsPublic = IsPublic || get.IsPublic;
     }
     ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence);
     UID = Guid.NewGuid();
     Init();
     TypeCodes = TypeInfo.TypeCodes;
     Attributes = new AttributeCollection(MemberInfo);
     var mapping = Attributes.First<IMemberMappingAttribute>();
     if (mapping != null)
     {
         MappingName = mapping.Name;
     }
 }
Пример #3
0
 public VolumeDescriptor(Hardware.Devices.DiskDevice disk, uint startBlock, uint numBlocks, byte[] data)
     : base(disk, 0, 0)
 {
     Code = (TypeCodes)data[0];
     Id = ByteConverter.GetASCIIStringFromASCII(data, 1, 5);
     Version = data[6];
 }
Пример #4
0
        internal Literacy(TypeInfo info, bool ignoreCase)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            TypeInfo       = info;
            Type           = info.Type;
            _CallNewObject = PreNewObject;
            Property       = new ObjectPropertyCollection(ignoreCase);
            foreach (var p in Type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (p.GetIndexParameters().Length == 0) //排除索引器
                {
                    if (!Property.ContainsKey(p.Name))
                    {
                        var a = new ObjectProperty(p);
                        Property.Add(a);
                    }
                }
            }
            ID        = Interlocked.Increment(ref Sequence);
            UID       = Guid.NewGuid();
            TypeCodes = info.TypeCodes;
        }
Пример #5
0
 /// <summary> 表示一个可以获取或者设置其内容的对象字段
 /// </summary>
 /// <param name="field">字段信息</param>
 internal ObjectProperty(FieldInfo field)
 {
     Field = true; //是一个字段
     MemberInfo = field; //字段信息
     OriginalType = field.FieldType; //字段值类型
     Static = field.IsStatic; //字段是否是静态的
     IsPublic = field.IsPublic; //字段是否是公开的
     CanWrite = !field.IsLiteral; // !field.IsInitOnly; //是否可写取决于ReadOnly
     CanRead = true; //字段一定可以读
     Init();
     ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence);
     UID = Guid.NewGuid();
     TypeCodes = TypeInfo.TypeCodes;
     AutoField = (field.Name[0] == '<') || field.Name.Contains("<");
 }
Пример #6
0
        public void Test()
        {
            int       ia       = 12;
            TypeCodes typeCode = TypeReflector.GetTypeCodes(ia);

            Assert.IsTrue(typeCode == TypeCodes.int32);


            typeCode = TypeReflector.GetTypeCodes("i");
            Assert.IsTrue(typeCode == TypeCodes.String);


            typeCode = TypeReflector.GetTypeCodes(new Student()
            {
                ID = 23
            });
            System.Console.WriteLine(typeCode.ToString());
            Assert.IsTrue(typeCode == TypeCodes.complexclass);
        }
Пример #7
0
 /// <summary> 表示一个可以获取或者设置其内容的对象属性
 /// </summary>
 /// <param name="property">属性信息</param>
 internal ObjectProperty(PropertyInfo property)
 {
     Field = false;
     MemberInfo = property; //属性信息
     OriginalType = property.PropertyType;
     var get = property.GetGetMethod(true); //获取属性get方法,不论是否公开
     var set = property.GetSetMethod(true); //获取属性set方法,不论是否公开
     if (set != null) //set方法不为空
     {
         CanWrite = true; //属性可写
         Static = set.IsStatic; //属性是否为静态属性
         IsPublic = set.IsPublic;
     }
     if (get != null) //get方法不为空
     {
         CanRead = true; //属性可读
         Static = get.IsStatic; //get.set只要有一个静态就是静态
         IsPublic = IsPublic || get.IsPublic;
     }
     ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence);
     UID = Guid.NewGuid();
     Init();
     TypeCodes = TypeInfo.TypeCodes;
 }
Пример #8
0
        public static bool IsComplextClass(object o)
        {
            TypeCodes code = GetTypeCodes(o);

            return(code == TypeCodes.complexclass);
        }
Пример #9
0
 public static bool IsReferenceTypeCode(TypeCodes typeCode)
 {
     return(typeCode == TypeCodes.Type || typeCode == TypeCodes.AnimationCurve || typeCode == TypeCodes.Array || typeCode == TypeCodes.List);
 }
Пример #10
0
 public bool UpdateTypeForSymID(int symId, TypeCodes code)
 {
     var SymbolTypeDAL = new SymbolTypeDAL(testing);
     return SymbolTypeDAL.UpdateTypeForSymID(symId, code);
 }
Пример #11
0
 public bool SetLanguageForSymID(int symId, TypeCodes code)
 {
     var SymbolTypeDAL = new SymbolTypeDAL(testing);
     return SymbolTypeDAL.SetLanguageForSymID(symId, code);
 }
Пример #12
0
 public MapItem(TypeCodes type, uint size, uint offset)
 {
     Type = type;
     Size = size;
     Offset = offset;
 }
Пример #13
0
 /// <summary>
 /// Updates a SymID's TypeIndicator code. Does not set type for a SymID
 /// only updates.
 /// </summary>
 /// <param name="symId"></param>
 /// <param name="code"></param>
 /// <returns>true or false depending on success</returns>
 public bool UpdateTypeForSymID(int symId, TypeCodes code)
 {
     var toUpdate = GetExactRowBySymID(symId);
     try
     {
         using (var db = new BlissBaseContext(testing))
         {
             toUpdate.TypeIndicator = code;
             db.Entry(toUpdate).State = EntityState.Modified;
             db.SaveChanges();
             return true;
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("An exception was thrown when trying to update TypeIndicator code for " +
             "symId: " + symId);
         Debug.WriteLine(e.StackTrace);
         return false;
     }
 }
Пример #14
0
 internal MapItem(TypeCodes type, uint size, uint offset)
 {
     Type   = type;
     Size   = size;
     Offset = offset;
 }
Пример #15
0
        public ActionResult Edit(int symbolId, int symbolType)
        {
            if (Session["logged_in"] == null)
                return RedirectToAction("Index", "Index");

            if(symbolId != 0)
            {
                SymbolBLL symbols = new SymbolBLL();
                Symbol toEdit = symbols.GetExactByID(symbolId);

                if(toEdit != null)
                {
                    if(symbolType == 0)
                    {
                        SymbolTypeBLL types = new SymbolTypeBLL();
                        types.SetStandardForSymID(toEdit.symId);
                    }
                    else
                    {
                        TypeCodes type = new TypeCodes();

                        switch (symbolType)
                        {
                            case 1: type = TypeCodes.INDICATOR;
                                break;
                            case 2: type = TypeCodes.NUMERICAL;
                                break;
                            case 3: type = TypeCodes.LATIN;
                                break;
                        }

                        SymbolTypeBLL types = new SymbolTypeBLL();
                        if(types.GetExactBySymID(toEdit.symId) != null)
                        {
                            types.UpdateTypeForSymID(toEdit.symId, type);
                        }
                        else
                        {
                            types.SetLanguageForSymID(toEdit.symId, type);
                        }
                    }
                    TempData["msg"] = "Symbol with id " + symbolId + " was successfully edited!";
                }
                else
                {
                    TempData["msg"] = "Could find and edit symbol with id " + symbolId;
                }
            }
            else
            {
                TempData["msg"] = "SymbolId is not valid.";
            }
            return RedirectToAction("Index");
        }
Пример #16
0
        public static bool IsPrivateValue(object o)
        {
            TypeCodes code = GetTypeCodes(o);

            return(((int)code > 0) && ((int)code) < 20);
        }
Пример #17
0
        private JsonType(Type type, int i)
        {
            AreNull(type, "type");
            Type     = type;
            TypeInfo = TypesHelper.GetTypeInfo(type);
            _members = new Dictionary <string, JsonMember>(StringComparer.OrdinalIgnoreCase);
            var list = new List <JsonMember>();

            //枚举属性
            foreach (var p in Type.GetProperties())
            {
                var jm = JsonMember.Create(p);
                if (jm != null)
                {
                    AreTrue(_members.ContainsKey(jm.JsonName), "JsonName重复:" + jm.JsonName);
                    _members[jm.JsonName] = jm;
                    list.Add(jm);
                }
            }
            PropertyCount = list.Count;
            //枚举字段
            foreach (var p in Type.GetFields())
            {
                var jm = JsonMember.Create(p);
                if (jm != null)
                {
                    AreTrue(_members.ContainsKey(jm.JsonName), "JsonName重复:" + jm.JsonName);
                    _members[jm.JsonName] = jm;
                    list.Add(jm);
                }
            }
            Members = list.ToArray();
            //设置 TypeCodes ,ElementType ,KeyType
            switch (TypeCodes = TypeInfo.TypeCodes)
            {
            case TypeCodes.IListT:
                IsList = true;
                var args = SearchGenericInterface(type, typeof(IList <>)).GetGenericArguments();
                ElementType = JsonType.Get(args[0]);
                AddValue    = Literacy.CreateCaller(type.GetMethod("Add", args));
                break;

            case TypeCodes.IList:
                IsList = true;
                if (type.IsArray)
                {
                    ElementType = JsonType.Get(type.GetElementType());
                    AddValue    = (o, v) => ((System.Collections.ArrayList)o).Add(v[0]);
                }
                else
                {
                    ElementType = JsonType.Get(typeof(object));
                    AddValue    = (o, v) => ((System.Collections.IList)o).Add(v[0]);
                }
                break;

            case TypeCodes.IDictionary:
                IsDictionary = true;
                KeyType      = JsonType.Get(typeof(object));
                ElementType  = KeyType;
                AddKeyValue  = (o, v) => { ((System.Collections.IDictionary)o).Add(v[0], v[1]); return(null); };
                break;

            case TypeCodes.IDictionaryT:
                IsDictionary = true;
                var dictType = SearchGenericInterface(type, typeof(IDictionary <,>));
                args        = dictType.GetGenericArguments();
                KeyType     = JsonType.Get(args[0]);
                ElementType = JsonType.Get(args[1]);
                AddKeyValue = Literacy.CreateCaller(dictType.GetMethod("Add", args), type);
                break;

            default:
                break;
            }
        }
Пример #18
0
 /// <summary> 表示一个可以获取或者设置其内容的对象字段
 /// </summary>
 /// <param name="field">字段信息</param>
 public ObjectProperty(FieldInfo field)
 {
     Field = true; //是一个字段
     MemberInfo = field; //字段信息
     OriginalType = field.FieldType; //字段值类型
     Static = field.IsStatic; //字段是否是静态的
     IsPublic = field.IsPublic; //字段是否是公开的
     CanWrite = !field.IsLiteral; // !field.IsInitOnly; //是否可写取决于ReadOnly
     CanRead = true; //字段一定可以读
     Init();
     ID = System.Threading.Interlocked.Increment(ref Literacy.Sequence);
     UID = Guid.NewGuid();
     TypeCodes = TypeInfo.TypeCodes;
     AutoField = (field.Name[0] == '<') || field.Name.Contains("<");
     Attributes = new AttributeCollection(MemberInfo);
     var mapping = Attributes.First<IMemberMappingAttribute>();
     if (mapping != null)
     {
         MappingName = mapping.Name;
     }
 }
Пример #19
0
        internal Literacy(TypeInfo info, bool ignoreCase)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            TypeInfo = info;
            Type = info.Type;
            _CallNewObject = PreNewObject;
            Property = new ObjectPropertyCollection(ignoreCase);
            foreach (var p in Type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (p.GetIndexParameters().Length == 0) //排除索引器
                {
                    if (!Property.ContainsKey(p.Name))
                    {
                        var a = new ObjectProperty(p);
                        Property.Add(a);
                    }
                }
            }
            ID = Interlocked.Increment(ref Sequence);
            UID = Guid.NewGuid();
            TypeCodes = info.TypeCodes;
        }
Пример #20
0
        public static bool IsComplextClass(Type type)
        {
            TypeCodes code = GetTypeCodes(type);

            return(code == TypeCodes.complexclass);
        }
Пример #21
0
 public static bool IsPrivateValue(TypeCodes code)
 {
     return(((int)code > 0) && ((int)code) < 20);
 }
Пример #22
0
 public static bool IsGenericTypeCode(TypeCodes typeCode)
 {
     return(typeCode == TypeCodes.Array || typeCode == TypeCodes.List);
 }
Пример #23
0
        public static bool IsPrivateValue(Type type)
        {
            TypeCodes code = GetTypeCodes(type);

            return(((int)code > 0) && ((int)code) < 20);
        }
Пример #24
0
 public MapItem(TypeCodes type, uint count, uint offset)
 {
     Type   = type;
     Count  = count;
     Offset = offset;
 }
Пример #25
0
        /// <summary>
        /// Sets a non standard type: "TypeCodes code" for a SymID symId
        /// </summary>
        /// <param name="symId"></param>
        /// <param name="code"></param>
        /// <returns>true or false depending on success</returns>
        public bool SetLanguageForSymID(int symId, TypeCodes code)
        {
            var toAdd = new SymbolTypes
            {
                SymID = symId,
                TypeIndicator = code
            };

            try
            {
                using (var db = new BlissBaseContext(testing))
                {
                    db.SymbolTypes.Add(toAdd);
                    db.SaveChanges();
                    return true;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("An exception was thrown when trying to set TypeCode: " + code +
                    " for symId: " + symId);
                Debug.WriteLine(e.StackTrace);
                return false;
            }
        }
Пример #26
0
        public static Type ToType(TypeCodes typeCode)
        {
            Type type = null;

            switch (typeCode)
            {
            case TypeCodes.Bool:
                type = typeof(bool);
                break;

            case TypeCodes.SByte:
                type = typeof(sbyte);
                break;

            case TypeCodes.Byte:
                type = typeof(byte);
                break;

            case TypeCodes.Int16:
                type = typeof(short);
                break;

            case TypeCodes.UInt16:
                type = typeof(ushort);
                break;

            case TypeCodes.Int32:
                type = typeof(int);
                break;

            case TypeCodes.UInt32:
                type = typeof(uint);
                break;

            case TypeCodes.Int64:
                type = typeof(long);
                break;

            case TypeCodes.UInt64:
                type = typeof(ulong);
                break;

            case TypeCodes.Single:
                type = typeof(float);
                break;

            case TypeCodes.Double:
                type = typeof(double);
                break;

            case TypeCodes.Decimal:
                type = typeof(decimal);
                break;

            case TypeCodes.Char:
                type = typeof(char);
                break;

            case TypeCodes.String:
                type = typeof(string);
                break;

            case TypeCodes.Type:
                type = typeof(Type);
                break;

            case TypeCodes.Vector2:
                type = typeof(Vector2);
                break;

            case TypeCodes.Vector3:
                type = typeof(Vector3);
                break;

            case TypeCodes.Vector4:
                type = typeof(Vector4);
                break;

            case TypeCodes.Color:
                type = typeof(Color);
                break;

            case TypeCodes.Quaternion:
                type = typeof(Quaternion);
                break;

            case TypeCodes.Rect:
                type = typeof(Rect);
                break;

            case TypeCodes.Bounds:
                type = typeof(Bounds);
                break;

            case TypeCodes.AnimationCurve:
                type = typeof(AnimationCurve);
                break;

            case TypeCodes.Keyframe:
                type = typeof(Keyframe);
                break;
            }

            return(type);
        }