/// <summary> /// 把值转成字符串 /// </summary> /// <param name="value"></param> /// <returns></returns> private static object JsonValueToValue(object value, Type realType) { if (value == null) { return(null); } realType = DefaultType.GetRealValueType(realType); if (value.GetType() == realType) { return(value); } if (DefaultType.IsInherit(realType, typeof(Enum))) { int ivalue = Convert.ToInt32(value); return(ivalue); } if (DefaultType.IsInherit(realType, typeof(byte[]))) { return(CommonMethods.HexStringToBytes(value as string)); } if (DefaultType.IsInherit(realType, typeof(bool))) { return(Convert.ToInt32(value) != 0); } return(Convert.ChangeType(value, realType)); }
public override object?ReadJson(JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } var jo = JObject.Load(reader); var designatingProperty = jo.GetValue(TypeDesignatingPropertyName); TypeInfo typeInfo; if (designatingProperty == null) { if (DefaultType == null) { throw new Exception($"Unable to determine type to deserialize. Missing property `{TypeDesignatingPropertyName}`"); } typeInfo = DefaultType.GetTypeInfo(); } else { var derivedType = designatingProperty.ToObject <string>() ?? string.Empty; typeInfo = GetTypeInfoFromDerivedType(derivedType); } var ctor = typeInfo.GetConstructors(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(); if (ctor == null) { throw new Exception($"Type {typeInfo.Name} must have a public constructor"); } var args = ctor.GetParameters() .Select(p => jo.GetValue(char.ToUpper(p.Name ![0]) + p.Name.Substring(1))?.ToObject(p.ParameterType, serializer))
///// <summary> ///// 此项的值 ///// </summary> //public object ItemValue //{ // get // { // return itemValue; // } //} internal override void FillInfo(KeyWordInfomation info) { if (_valueDbType == DbType.Object) { _valueDbType = DefaultType.ToDbType(itemValue.GetType());//自匹配类型 } }
/// <summary> /// 格式化值项 /// </summary> /// <param name="valueItem"></param> /// <returns></returns> private string FormatValueType(KeyWordInfomation info) { Type valueDataType = null; if (itemValue != null) { valueDataType = itemValue.GetType(); } if (DefaultType.EqualType(valueDataType, DefaultType.StringType) || DefaultType.EqualType(valueDataType, DefaultType.GUIDType)) { return(DataAccessCommon.FormatValue(itemValue, DbType.String, info.DBInfo)); } else if (DefaultType.EqualType(valueDataType, DefaultType.DateTimeType)) { return(DataAccessCommon.FormatValue(itemValue, DbType.DateTime, info.DBInfo)); } else if (DefaultType.EqualType(valueDataType, DefaultType.BytesType)) { return(DataAccessCommon.FormatValue(itemValue, DbType.Binary, info.DBInfo)); } else if (DefaultType.EqualType(valueDataType, DefaultType.BooleanType)) { return(DataAccessCommon.FormatValue(itemValue, DbType.Boolean, info.DBInfo)); } else if (DefaultType.EqualType(valueDataType, DefaultType.GUIDType)) { return(DataAccessCommon.FormatValue(itemValue, DbType.Guid, info.DBInfo)); } else if (valueDataType == null) { return("null"); } return(itemValue.ToString()); }
/// <summary> /// Constructor for the <c>FieldScanner</c> object. This is /// used to perform a scan on the specified class in order to find /// all fields that are labeled with an XML annotation. /// </summary> /// <param name="type"> /// this is the schema class that is to be scanned /// </param> /// <param name="access"> /// this is the access type for the class /// </param> public FieldScanner(Class type, DefaultType access) { this.factory = new AnnotationFactory(); this.hierarchy = new Hierarchy(type); this.done = new ContactMap(); this.access = access; this.Scan(type); }
public void ActivationEnd() { DefaultType temp = currentBehavior.GetComponent <DefaultType>(); temp.timer = 0; hold = false; }
/// <summary> /// 添加到数据层 /// </summary> /// <param name="doc"></param> private static void AppendDalLoader(Assembly ass, XmlDocument doc) { XmlNodeList nodes = doc.GetElementsByTagName("dataaccess"); if (nodes.Count <= 0) { return; } XmlAttribute att = nodes[0].Attributes["name"]; if (att == null) { return; } string name = att.InnerText; DBInfo db = null; if (!_dicDBInfo.TryGetValue(name, out db)) { return; } string[] namespaces = db.DataaccessNamespace; XmlNodeList dalNodes = nodes[0].ChildNodes; foreach (XmlNode dalNode in dalNodes) { att = dalNode.Attributes["type"]; if (att == null) { continue; } string typeName = att.InnerText; foreach (string allNameSpace in namespaces) { if (typeName.StartsWith(allNameSpace)) { Type dalType = ass.GetType(typeName); if (dalType != null) { att = dalNode.Attributes["interface"]; if (att == null) { break; } _dicLoaderConfig[att.InnerText] = dalType; Type[] gTypes = DefaultType.GetGenericType(dalType, true); if (gTypes != null && gTypes.Length > 0) { Type gType = gTypes[0]; _dicEntityLoaderConfig[gType.FullName] = dalType; } } break; } } } }
/// <summary> /// 加载真正的数据类型 /// </summary> private void LoadRealFieldType() { this._realFieldType = DefaultType.GetRealValueType(_fieldType); if (_realFieldType.IsEnum) { _realFieldType = typeof(int); } }
public UCDefaultCode() { InitializeComponent(); _Name = ""; TypeList = new List <DefaultType>(); SelectValue = new DefaultType(); }
/// <summary> /// 把该值转成指定类型 /// </summary> /// <param name="value">值</param> /// <param name="type">指定类型</param> /// <returns></returns> private static object ConvertTo(object value, Type type) { if (DefaultType.EqualType(type, DefaultType.BytesType)) { return(StringToBytes(value.ToString())); } return(Buffalo.Kernel.CommonMethods.ChangeType(value, type)); }
/// <summary> /// Constructor for the <c>MethodScanner</c> object. This is /// used to create an object that will scan the specified class /// such that all bean property methods can be paired under the /// XML annotation specified within the class. /// </summary> /// <param name="type"> /// this is the type that is to be scanned for methods /// </param> public MethodScanner(Class type, DefaultType access) { this.factory = new MethodPartFactory(); this.hierarchy = new Hierarchy(type); this.write = new PartMap(); this.read = new PartMap(); this.access = access; this.type = type; this.Scan(type); }
internal static string ToShaderLabString(DefaultType defaultType) { int index = (int)defaultType; if ((index >= 0) && (index < k_DefaultTypeNames.Length)) { return(k_DefaultTypeNames[index]); } return(string.Empty); }
public IActionResult Create([FromBody] DefaultType DefaultType) { var res = _DefaultType.add(DefaultType); if (res == true) { return(CreatedAtRoute("DefaultTypeById", new { Controller = "DefaultType", id = DefaultType.DefaultTypeId }, DefaultType)); } return(StatusCode(500)); }
internal void SetValue(DefaultType dt, string Name) { if (lbl_SelectDivision.Text.Equals(Name)) { _DefaultCodeController.SelectValue = dt; lbl_SelectValue.Text = dt.Value; lbl_No.Text = dt.No.ToString(); lbl_Value.Text = dt.Value; lbl_Sort.Text = dt.Sort.ToString(); } }
/// <summary> /// 把类型转换成字符串 /// </summary> /// <param name="value">类型</param> /// <returns></returns> public static string ValueToString(object value) { if (value == null) { return(""); } else if (DefaultType.EqualType(value.GetType(), DefaultType.BytesType)) { return(ToByteString((byte[])value)); } return(value.ToString()); }
public void ActivationStart() { x += 1; x = x % interactions.Count; currentBehavior = interactions[x]; DefaultType temp = currentBehavior.GetComponent <DefaultType>(); if (temp.GetTimer() <= 0) { temp.Action(); } hold = true; }
/// <summary> /// Resets the default Ham / Spam profile /// </summary> /// <param name="dftProfile">Which profile type to reset</param> public static void ResetDefaultProfile(DefaultType pdftProfile) { switch (pdftProfile) { case DefaultType.Ham: SGGlobals.SaveSetting(SGGlobals.BaseRegistryKey, "DefaultHamProfileId", string.Empty); break; case DefaultType.Spam: SGGlobals.SaveSetting(SGGlobals.BaseRegistryKey, "DefaultSpamProfileId", string.Empty); break; } }
public bool add(DefaultType DefaultType) { try { _context.DefaultTypes.Add(DefaultType); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
/// <summary> /// 更新实体 /// </summary> /// <param name="lstValue">强制设置值</param> /// <param name="optimisticConcurrency">是否并发控制</param> /// <returns></returns> public virtual int Update(ValueSetList lstValue, bool optimisticConcurrency) { DataAccessSetBase dal = GetBaseDataAccess(); foreach (EntityPropertyInfo epPk in dal.EntityInfo.PrimaryProperty) { object id = epPk.GetValue(this); if (DefaultType.IsDefaultValue(id)) { throw new Exception("主键:" + epPk.PropertyName + "的值不能为空"); } } return(dal.Update(this, null, lstValue, optimisticConcurrency)); }
/// <summary> /// 把字符串的值还原成原类型的值 /// </summary> /// <param name="value">字符串</param> /// <param name="type">源类型</param> /// <returns></returns> public static object StringToValue(string value, Type type) { //if (type.IsGenericType) //{ // Type[] types = type.GetGenericArguments(); // if (types.Length > 0) // { // type = types[0]; // } //} Type objType = DefaultType.GetRealValueType(type); return(ConvertTo(value, type)); }
private void lbl_ColorChange(DefaultType dt) { for (int i = 0; i < this.tableLayoutPanel1.Controls.Count; i++) { if (tableLayoutPanel1.Controls[i].Text == dt.Value) { tableLayoutPanel1.Controls[i].BackColor = System.Drawing.Color.GreenYellow; } else { tableLayoutPanel1.Controls[i].BackColor = System.Drawing.SystemColors.Control; } } }
/// <summary> /// This is used to scan all the methods of the class in order to /// determine if it should have a default annotation. If the method /// should have a default XML annotation then it is added to the /// list of contacts to be used to form the class schema. /// </summary> /// <param name="type"> /// this is the type to have its methods scanned /// </param> /// <param name="access"> /// this is the default access type for the class /// </param> public void Scan(Class type, DefaultType access) { Method[] list = type.getDeclaredMethods(); if (access == PROPERTY) { for (Method method : list) { Class value = factory.GetType(method); if (value != null) { Process(method); } } } }
public bool update(int id, DefaultType DefaultType) { DefaultType.DefaultTypeId = id; try { _context.DefaultTypes.Update(DefaultType); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(false); } return(true); }
private SettingsXml.DefaultScope MapDefaultScope(DefaultType defaultValue) { switch (defaultValue) { case DefaultType.Everywhere: return(SettingsXml.DefaultScope.Everywhere); case DefaultType.SystemUnderTest: return(SettingsXml.DefaultScope.SystemUnderTest); case DefaultType.Assert: return(SettingsXml.DefaultScope.Assert); case DefaultType.SetupCleanup: return(SettingsXml.DefaultScope.Decoration); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// This is used to scan all the fields of the class in order to /// determine if it should have a default annotation. If the field /// should have a default XML annotation then it is added to the /// list of contacts to be used to form the class schema. /// </summary> /// <param name="type"> /// this is the type to have its fields scanned /// </param> /// <param name="access"> /// this is the default access type for the class /// </param> public void Scan(Class type, DefaultType access) { Field[] list = type.getDeclaredFields(); if (access == FIELD) { for (Field field : list) { Class real = field.getType(); if (real != null) { Process(field, real); } } } }
/// <summary> /// 填充版本控制的信息 /// </summary> /// <param name="where"></param> /// <param name="where"></param> /// <param name="info"></param> /// <param name="list"></param> /// <param name="curValue"></param> protected internal void FillWhereConcurrency(StringBuilder where, EntityPropertyInfo info, ParamList list, object curValue, ref int index) { string paramValW = EntityInfo.DBInfo.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(info.ParamName, index)); string paramKeyW = EntityInfo.DBInfo.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(info.ParamName, index)); index++; if (DefaultType.IsDefaultValue(curValue)) { throw new Exception("版本控制字段:" + info.PropertyName + " 必须有当前版本值"); } where.Append(" and "); where.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName)); where.Append("="); where.Append(paramValW); list.AddNew(paramKeyW, info.SqlType, curValue); }
/// <summary> /// 并发删除 /// </summary> /// <param name="optimisticConcurrency">是否并发控制</param> /// <returns></returns> public virtual int Delete(bool optimisticConcurrency) { DataAccessSetBase dal = GetBaseDataAccess(); ScopeList lstScope = new ScopeList(); foreach (EntityPropertyInfo pInfo in dal.EntityInfo.PrimaryProperty) { object id = pInfo.GetValue(this); if (DefaultType.IsDefaultValue(id)) { throw new Exception("主键:" + pInfo.PropertyName + "的值不能为空"); } lstScope.AddEqual(pInfo.PropertyName, id); } return(dal.Delete(this, lstScope, optimisticConcurrency)); }
public void GatherXObjects(List <XObject> xobjects) { xobjects.Add(new XAttribute("name", Name)); if (SuperClass != null) { xobjects.Add(new XElement("superclass", new XElement("superclass", new XAttribute("name", SuperClass.ToString())))); } if (DefaultType != null) { xobjects.Add(new XAttribute("defaulttype", DefaultType.ToString())); } var conforming = new List <XObject> (); foreach (var spec in ConformingProtocols) { conforming.Add(new XElement("conformingprotocol", new XAttribute("name", spec.ToString()))); } xobjects.Add(new XElement("conformingprotocols", conforming.ToArray())); }
public override string ToString() { BQLValueItem qvalue = value1 as BQLValueItem; if (!CommonMethods.IsNull(qvalue)) { return(qvalue.DisplayValue(BQLValueItem.GetKeyInfo())); } else { string pName = propertyName; DbType dbType = DbType.AnsiString; if (value1 != null) { dbType = DefaultType.ToDbType(value1.GetType()); } return(DataAccessCommon.FormatScorp(this, null, pName, dbType, 0, null)); } return(base.ToString()); }
/// <summary> /// 根据Reader结构和实体属性的映射生成空的DataTable /// </summary> /// <param name="reader">Reader</param> /// <param name="datatableName">数据表名</param> /// <param name="entityType">实体类</param> /// <param name="isEmpty">是否生成空的DataTable</param> /// <returns></returns> public static DataTable GenerateDataTable(IDataReader reader, string datatableName, Type entityType, bool isEmpty) { DataTable dt = new DataTable(); EntityInfoHandle entityInfo = EntityInfoManager.GetEntityHandle(entityType); List <EntityPropertyInfo> lstParamNames = GenerateCache(reader, entityInfo); dt.BeginLoadData(); foreach (EntityPropertyInfo info in lstParamNames) { if (info != null) { Type fieldType = info.FieldType; if (DefaultType.EqualType(fieldType, DefaultType.BooleanType)) { fieldType = typeof(bool); } dt.Columns.Add(info.PropertyName, fieldType); } } if (!isEmpty) { while (reader.Read()) { DataRow dr = dt.NewRow(); for (int i = 0; i < lstParamNames.Count; i++) { if (!reader.IsDBNull(i) && lstParamNames[i] != null) { dr[i] = reader[i]; } } dt.Rows.Add(dr); dt.AcceptChanges(); } } dt.EndLoadData(); return(dt); }
/// <summary> /// This is used to scan all the fields of the class in order to /// determine if it should have a default annotation. If the field /// should have a default XML annotation then it is added to the /// list of contacts to be used to form the class schema. /// </summary> /// <param name="type"> /// this is the type to have its fields scanned /// </param> /// <param name="access"> /// this is the default access type for the class /// </param> public void Scan(Class type, DefaultType access) { Field[] list = type.getDeclaredFields(); if(access == FIELD) { for(Field field : list) { Class real = field.getType(); if(real != null) { Process(field, real); } } } }
public DefaultAction(DefaultType defaultType, string variable, string value) { DefaultType = defaultType; Variable= variable; Value = value; }
private static void ParseDefault(String text, String specifiedParameter, out String actualParameter, out DefaultType type, out String customParameter) { customParameter = String.Empty; //++ //TODO: Consider creating a markup extension system for this. //++ if (text.Equals("page", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Page; actualParameter = specifiedParameter; } else if (text.Equals("sequence", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Sequence; actualParameter = specifiedParameter; } else if (text.Equals("mvc", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Mvc; actualParameter = String.Empty; } else if (text.StartsWith("{page ", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Page; //+ Int32 indexOfSpace = text.IndexOf(' '); actualParameter = text.Substring(indexOfSpace + 1, text.Length - indexOfSpace - 2); } else if (text.StartsWith("{sequence ", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Sequence; //+ Int32 indexOfSpace = text.IndexOf(' '); actualParameter = text.Substring(indexOfSpace + 1, text.Length - indexOfSpace - 2); } else if (text.StartsWith("{handler ", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Handler; //+ Int32 indexOfSpace = text.IndexOf(' '); actualParameter = text.Substring(indexOfSpace + 1, text.Length - indexOfSpace - 2); } else if (text.EndsWith("}") && text.Contains(" ")) { type = DefaultType.Handler; //+ Int32 indexOfSpace = text.IndexOf(' '); customParameter = text.Substring(1, indexOfSpace - 1); actualParameter = text.Substring(indexOfSpace + 1, text.Length - indexOfSpace - 2); } else if (text.StartsWith("{", StringComparison.InvariantCultureIgnoreCase)) { type = DefaultType.Sequence; actualParameter = text; } else if (text.Contains("/")) { type = DefaultType.Page; actualParameter = text; } else { type = DefaultType.Unknown; actualParameter = String.Empty; } }