本文整理汇总了C#中IType.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IType.GetType方法的具体用法?C# IType.GetType怎么用?C# IType.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuscarHomePaginaRestrito
public IType BuscarHomePaginaRestrito(IType iType, int idUsuario, int idCampanha)
{
try
{
Cmd = DataBaseGeneric.CreateCommand(BaseType);
Cmd.Connection = Cn;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = "sp_SYS_BUSCA_HIERARQUIA_POR_CREDENCIAL";
DbParameter paran = Cmd.CreateParameter();
paran.ParameterName = "@idcredencial";
paran.Value = idUsuario;
Cmd.Parameters.Add(paran);
DbParameter paran1 = Cmd.CreateParameter();
paran1.ParameterName = "@idcampanha";
paran1.Value = idCampanha;
Cmd.Parameters.Add(paran1);
OpenConnection(iType);
DbDataReader dr = Cmd.ExecuteReader();
if (dr.Read())
return SetObject(dr, (IType)Activator.CreateInstance(iType.GetType()));
return null;
}
catch (Exception ex) { throw ex; }
finally
{
Cn.Close();
Cn.Dispose();
}
}
示例2: BuscarHomePagina
public IType BuscarHomePagina(IType iType, int idCliente)
{
Cn = DataBaseGeneric.CreateConnection(BaseType, iType.InstanceConectionString);
Cn.Open();
try
{
Cmd = DataBaseGeneric.CreateCommand(BaseType);
Cmd.Connection = Cn;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = "sp_SYS_BuscarHomePagina";
DbParameter paran2 = Cmd.CreateParameter();
paran2.ParameterName = "@idCliente";
paran2.Value = idCliente;
Cmd.Parameters.Add(paran2);
OpenConnection(iType);
DbDataReader dr = Cmd.ExecuteReader();
if (dr.Read())
return SetObject(dr, (IType)Activator.CreateInstance(iType.GetType()));
return null;
}
catch (Exception ex) { throw ex; }
finally
{
Cn.Close();
Cn.Dispose();
}
}
示例3: GetDependencyPropertyDescriptor
public IDependencyPropertyDescriptor GetDependencyPropertyDescriptor(string name, IType ownerType, IType targetType)
{
if (ownerType == null)
throw new ArgumentNullException("ownerType");
if (ownerType is CecilType)
return new CecilDependencyPropertyDescriptor(name, ((CecilType)ownerType).type);
if (ownerType is UnresolvableType)
return new UnresolvableDependencyPropertyDescriptor();
throw new ArgumentException("Invalid IType: " + ownerType.GetType());
}
示例4: CacheKey
public static string CacheKey(IType cType, string conditions)
{
string key = Cache.KeyForClass(cType) + "[" + HttpUtility.UrlEncode(conditions) + "]";
foreach (PropertyInfo pi in cType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
PropertyAttribute[] pAttProperty = (PropertyAttribute[])pi.GetCustomAttributes(typeof(PropertyAttribute), false);
if (pAttProperty != null && pAttProperty.Length > 0)
{
if (pAttProperty[0].IsFieldBase)
{
object value = pi.GetValue(cType, null);
value = value is DateTime ? ((DateTime)value).ToString("dd/MM/yyy") : value;
key += "[Param[" + pi.Name + "]Value[" + value + "]]";
}
}
}
return key;
}
示例5: NormalizeTypeReference
public override IType NormalizeTypeReference(IType type)
{
if (type == null)
{
return null;
}
var enumType = type as EnumType;
if (enumType != null && enumType.Name.Length == 0 && enumType.ModelAsString)
{
type = PrimaryType.String;
}
// Using Any instead of Contains since object hash is bound to a property which is modified during normalization
if (_normalizedTypes.Any(item => type.Equals(item)))
{
return _normalizedTypes.First(item => type.Equals(item));
}
_normalizedTypes.Add(type);
if (type is PrimaryType)
{
return NormalizePrimaryType(type as PrimaryType);
}
if (type is SequenceType)
{
return NormalizeSequenceType(type as SequenceType);
}
if (type is DictionaryType)
{
return NormalizeDictionaryType(type as DictionaryType);
}
if (type is CompositeType)
{
return NormalizeCompositeType(type as CompositeType);
}
if (type is EnumType)
{
return NormalizeEnumType(type as EnumType);
}
throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture,
"Type {0} is not supported.", type.GetType()));
}
示例6: Fresh
internal static IType Fresh(IType t, IType[] types, IDictionary<int, Var> vars)
{
if (t == null)
{
throw new ArgumentNullException("t", "cannot be null");
}
vars = vars ?? new Dictionary<int, Var>();
t = Prune(t);
Type type = t as Type;
Var var = t as Var;
if (var != null) // t is a Var
{
if (!OccursChecks(t, types))
{
if (!vars.ContainsKey(var.Id))
{
vars[var.Id] = new Var();
}
return vars[var.Id];
}
return t;
}
if (type != null) // t is a Type
{
return new Type(type.Constructor, type.Args.Select(arg => Fresh(arg, types, vars)).ToArray());
}
throw new ArgumentOutOfRangeException(nameof(t), $"unsupported symbol type ({t.GetType().Name})");
}
示例7: IsDatabaseGeneratedTimestamp
private static bool IsDatabaseGeneratedTimestamp(IType type)
{
// TODO NH: we should check the "generated" property
// currently only the Hibernate-supplied DbTimestampType is supported here
return typeof(TimestampType).IsAssignableFrom(type.GetType());
}
示例8: NormalizeTypeReference
/// <summary>
/// Returns language specific type reference name.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public override IType NormalizeTypeReference(IType type)
{
if (type == null)
{
return null;
}
// Return the normalized type if previously normalized
// go: Caching types is broken for Go and other generators since properties which contribute to the hash may change during normalization.
// Note:
// Go needs to manufacture new types in some cases (e.g., MapTypes replace basic DictionaryTypes).
// Go cannot, as a result, handle self-referential types (e.g., a DictionaryType whose value type is the same dictionary type).
// Normalization methods for each type family will inject the proper values into the normalized type collection, if the type is
// present and the value is null, it means normalization is incomplete.
IType normalizedType = null;
if (_normalizedTypes.ContainsKey(type))
{
normalizedType = _normalizedTypes[type];
if (normalizedType == null)
{
throw new NotSupportedException(string.Format("Type {0} is recursively defined in a manner Go cannot handle", type.GetType()));
}
return normalizedType;
}
// Note the incoming type is undergoing normalization
_normalizedTypes[type] = null;
if (type is PrimaryType)
{
normalizedType = NormalizePrimaryType(type as PrimaryType);
}
if (type is SequenceType)
{
normalizedType = NormalizeSequenceType(type as SequenceType);
}
if (type is DictionaryType)
{
normalizedType = NormalizeDictionaryType(type as DictionaryType);
}
if (type is CompositeType)
{
normalizedType = NormalizeCompositeType(type as CompositeType);
}
if (type is EnumType)
{
normalizedType = NormalizeEnumType(type as EnumType);
}
if (normalizedType == null)
{
throw new NotSupportedException(string.Format("Type {0} is not supported.", type.GetType()));
}
// Remember the normalized type
_normalizedTypes[type] = normalizedType;
return normalizedType;
}
示例9: SetNullPk
private void SetNullPk(IType iType)
{
foreach (PropertyInfo pi in iType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
PropertyAttribute[] pAttProperty = (PropertyAttribute[])pi.GetCustomAttributes(typeof(PropertyAttribute), false);
if (pAttProperty != null && pAttProperty.Length > 0 && pAttProperty[0].IsPk)
pi.SetValue(iType, null, null);
}
}
示例10: getConectionStringFromIType
private string getConectionStringFromIType(IType iType)
{
MemberInfo info = iType.GetType();
var tableAttributes = info.GetCustomAttributes(true);
if (tableAttributes.Length > 0)
{
TableAttribute pAttTable = (TableAttribute)tableAttributes[0];
if (pAttTable != null)
{
try
{
if (pAttTable.DynamicConectionString && !string.IsNullOrEmpty(iType.InstanceConectionString))
return iType.InstanceConectionString;
else if (pAttTable.ConnectionString != null)
return ConfigurationManager.ConnectionStrings[pAttTable.ConnectionString].ConnectionString;
return null;
}
catch (Exception ex) { throw new DidoxFrameworkError(ex.Message); }
}
}
return null;
}
示例11: Delete
/// <summary>
/// Exclui os dados na base através dos parâmetros
/// </summary>
public virtual void Delete(ref IType iType)
{
try
{
Cmd = DataBaseGeneric.CreateCommand(BaseType);
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.CommandText = "sp_SYS_" + iType.GetType().Name + "_Excluir";
SetParanDelete(iType);
OpenConnectionTrans(iType);
Cmd.ExecuteNonQuery();
}
catch (Exception ex) { throw ex; }
finally { CloseConnection(iType); }
}
示例12: CreateTable
/// <summary>
/// Cria tabela no banco de dados
/// </summary>
public void CreateTable(IType iType)
{
try
{
Cmd = DataBaseGeneric.CreateCommand(BaseType);
Cmd.CommandType = CommandType.Text;
string tableName = CType.GetTableName(iType);
string sqlCommand = "IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[" + tableName + "]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)" +
"DROP TABLE " + tableName;
OpenConnection(iType);
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
string pkField = null;
List<string> sqlCommandParam = new List<string>();
sqlCommand = "CREATE TABLE " + tableName + "(";
foreach (PropertyInfo pi in iType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
PropertyAttribute[] pAttProperty = (PropertyAttribute[])pi.GetCustomAttributes(typeof(PropertyAttribute), false);
if (pAttProperty != null && pAttProperty.Length > 0)
{
if (pAttProperty[0].IsField)
addSqlParam(ref sqlCommandParam, pi, false, true, pAttProperty[0].Size);
else if (pAttProperty[0].IsPk)
{
pkField = CType.GetPropertyName(pi);
sqlCommand += CType.GetPropertyName(pi) + " " + GetIntDataType(pi) + " IDENTITY(1,1) NOT NULL, ";
}
}
}
sqlCommand += string.Join(", ", sqlCommandParam.ToArray());
sqlCommand = sqlCommand.Replace("@", "");
sqlCommand += ") ON [PRIMARY]";
OpenConnection(iType);
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
}
catch (Exception ex) { throw ex; }
finally { CloseConnection(iType); }
}
示例13: CreateProcs
/// <summary>
/// Cria procedures no banco de dados
/// </summary>
public virtual void CreateProcs(IType iType)
{
try
{
Cmd = DataBaseGeneric.CreateCommand(BaseType);
Cmd.CommandType = CommandType.Text;
OpenConnection(iType);
string className = iType.GetType().Name;
string sqlCommand = " IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_SYS_" + className + "_Excluir]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)" +
"DROP PROCEDURE [dbo].[sp_SYS_" + className + "_Excluir] ";
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
sqlCommand = " IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_SYS_" + className + "_Buscar]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)" +
"DROP PROCEDURE [dbo].[sp_SYS_" + className + "_Buscar] ";
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
sqlCommand = " IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_SYS_" + className + "_BuscarConditions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)" +
"DROP PROCEDURE [dbo].[sp_SYS_" + className + "_BuscarConditions] ";
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
sqlCommand = " IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_SYS_" + className + "_Salvar]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)" +
"DROP PROCEDURE [dbo].[sp_SYS_" + className + "_Salvar] ";
Cmd.CommandText = sqlCommand;
Cmd.ExecuteNonQuery();
string pkField = null;
List<string> sqlCommandWhereDel = new List<string>();
List<string> sqlCommandParamDel = new List<string>();
List<ParamGetSql> sqlCommandWhereGet = new List<ParamGetSql>();
List<string> sqlCommandParamGet = new List<string>();
List<string> sqlCommandSave = new List<string>();
List<string> sqlCommandParamSave = new List<string>();
List<string> sqlCommandOrderGet = new List<string>();
foreach (PropertyInfo pi in iType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
PropertyAttribute[] pAttProperty = (PropertyAttribute[])pi.GetCustomAttributes(typeof(PropertyAttribute), false);
if (pAttProperty != null && pAttProperty.Length > 0)
{
if (pAttProperty[0].IsField)
{
OperationsAttribute[] pOpeProperty = (OperationsAttribute[])pi.GetCustomAttributes(typeof(OperationsAttribute), false);
if (pOpeProperty != null && pOpeProperty.Length > 0)
{
if (pOpeProperty[0].UseDelete)
{
addSqlParam(ref sqlCommandParamDel, pi, true, false, pAttProperty[0].Size);
sqlCommandWhereDel.Add(CType.GetPropertyName(pi));
}
if (pOpeProperty[0].UseSave)
{
addSqlParam(ref sqlCommandParamSave, pi, true, false, pAttProperty[0].Size);
sqlCommandSave.Add(CType.GetPropertyName(pi));
}
if (pOpeProperty[0].UseGet)
{
addSqlParam(ref sqlCommandParamGet, pi, true, false, pAttProperty[0].Size);
sqlCommandWhereGet.Add(
new ParamGetSql(CType.GetPropertyName(pi), (pi.PropertyType.Name == "String" && !pAttProperty[0].DontUseLikeWithStrings && !pAttProperty[0].IsText)));
}
if (pAttProperty[0].IsOrderField)
sqlCommandOrderGet.Insert(pAttProperty[0].OrderOfPriority, CType.GetPropertyName(pi) + " " + (pAttProperty[0].DescOrder ? "desc" : "asc"));
}
}
else if (pAttProperty[0].IsPk)
{
pkField = CType.GetPropertyName(pi);
string dataType = GetIntDataType(pi);
sqlCommandParamDel.Add("@" + pkField + " " + dataType + " = null");
sqlCommandWhereDel.Add(CType.GetPropertyName(pi));
sqlCommandParamGet.Add("@" + pkField + " " + dataType + " = null");
sqlCommandWhereGet.Add(new ParamGetSql(CType.GetPropertyName(pi), false));
sqlCommandParamSave.Add("@" + pkField + " " + dataType + " = null");
}
}
}
sqlCommand = "CREATE PROCEDURE sp_SYS_" + className + "_Excluir ";
sqlCommand += string.Join(", ", sqlCommandParamDel.ToArray()) + " ";
sqlCommand += "AS BEGIN ";
sqlCommand += "DELETE FROM " + CType.GetTableName(iType) + " ";
sqlCommand += "WHERE " + pkField + " IS NOT NULL AND ";
List<string> sqlCommandSetDel = new List<string>();
sqlCommandWhereDel.ForEach(c => sqlCommandSetDel.Add("( @" + c + " IS NULL OR " + c + " = @" + c + " )"));
sqlCommand += string.Join("AND ", sqlCommandSetDel.ToArray()) + " ";
sqlCommand += "END ";
Cmd.CommandText = sqlCommand;
//.........这里部分代码省略.........
示例14: GetTypeReferenceString
public string GetTypeReferenceString (IType type, bool highlight = true)
{
if (type == null)
throw new ArgumentNullException ("type");
AstType astType;
try {
astType = astBuilder.ConvertType (type);
} catch (Exception e) {
var compilation = GetCompilation (type);
if (compilation == null) {
Console.WriteLine ("type:"+type.GetType ());
Console.WriteLine ("got exception while conversion:" + e);
return "?";
}
astType = new TypeSystemAstBuilder (new CSharpResolver (compilation)).ConvertType (type);
}
if (astType is PrimitiveType) {
return Highlight (astType.GetText (formattingOptions), colorStyle.KeywordTypes);
}
var text = AmbienceService.EscapeText (astType.GetText (formattingOptions));
return highlight ? HighlightSemantically (text, colorStyle.UserTypes) : text;
}
示例15: validateFields
private static void validateFields(IType objiType)
{
string invalidFields = "";
foreach (PropertyInfo pi in objiType.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
{
ValidateAttribute[] pValProperty = (ValidateAttribute[])pi.GetCustomAttributes(typeof(ValidateAttribute), false);
PropertyAttribute[] pAttrProperty = (PropertyAttribute[])pi.GetCustomAttributes(typeof(PropertyAttribute), false);
if (pAttrProperty != null && pAttrProperty.Length > 0)
{
if (pAttrProperty[0].IsFieldBase)
{
var value = pi.GetValue(objiType, null);
if (pValProperty != null && pValProperty.Length > 0)
{
if (value == null) setDefaultValue(objiType, pAttrProperty, pi, ref invalidFields, ref value);
else if (value is string)
if (value.ToString() == "") setDefaultValue(objiType, pAttrProperty, pi, ref invalidFields, ref value);
}
if (!pAttrProperty[0].IsText && (value != null && value.ToString().Length > pAttrProperty[0].Size))
invalidFields += "O campo " + pi.Name + " está com o tamanho maior que o permitido. \n";
}
}
}
if (invalidFields.Length > 0)
throw new DidoxFrameworkError("Por favor corrija os campos abaixo:\n" + invalidFields);
}