本文整理汇总了C#中TypeInfo类的典型用法代码示例。如果您正苦于以下问题:C# TypeInfo类的具体用法?C# TypeInfo怎么用?C# TypeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeInfo类属于命名空间,在下文中一共展示了TypeInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumDCInterfaceMembers
private void EnumDCInterfaceMembers(TypeInfo info, EnumMembersHandler handler) {
var generatedEntityInfo = info.FindDCXPClassInfo();
var dcPropertyInfos = DCPropertyInfos(generatedEntityInfo);
foreach (DCPropertyInfo dcPropertyInfo in dcPropertyInfos){
handler(dcPropertyInfo, dcPropertyInfo.Name);
}
}
示例2: ShowDialog
/// <summary>
/// Prompts the user to edit a value.
/// </summary>
public Variant ShowDialog(Session session, NodeId nodeId)
{
m_session = session;
m_nodeId = nodeId;
#region Task #B2 - Write Value
// generate a default value based on the data type.
m_value = Variant.Null;
m_sourceType = GetExpectedType(session, nodeId);
if (m_sourceType != null)
{
m_value = new Variant(TypeInfo.GetDefaultValue(m_sourceType.BuiltInType), m_sourceType);
}
// cast the value to a string.
ValueTB.Text = (string)TypeInfo.Cast(m_value.Value, m_value.TypeInfo, BuiltInType.String);
#endregion
if (ShowDialog() != DialogResult.OK)
{
return Variant.Null;
}
return m_value;
}
示例3: ShouldSetTypePropertyWhenPassingTypeInfoToConstructor
public void ShouldSetTypePropertyWhenPassingTypeInfoToConstructor()
{
var typeInfo = new TypeInfo(typeof(CustomClass));
var dynamicObject = new DynamicObject(typeInfo);
dynamicObject.Type.ShouldBe(typeInfo);
}
示例4: LocalInfo
LocalInfo(TypeInfo type, String name, int index, Label beginLabel, Label endLabel) {
this.type = type;
this.name = name;
this.index = index;
this.beginLabel = beginLabel;
this.endLabel = endLabel;
}
示例5: Resolve
public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
{
FlatOperand fop_subject;
if (expression is IdentifierNameSyntax)
{
// typeof this
fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
}
else if (expression is MemberAccessExpressionSyntax)
{
MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;
fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
}
else
{
throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
}
if (into_lvalue == null)
{
FlatOperand fop_register = function.AllocateRegister("");
into_lvalue = fop_register.GetLValue(function, instructions);
}
instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
return into_lvalue.AsRValue(FlatValue.Table());
}
示例6: It_can_create_a_deep_clone_of_itself
public void It_can_create_a_deep_clone_of_itself()
{
var type1 = new TypeInfo
{
Name = "MyType",
Kind = TypeKind.Class,
Obsolete = true,
ObsoleteMessage = "I'm obsolete!",
Members =
{
new MemberInfo
{
Changes = { new MemberChangeInfo() }
}
},
Changes =
{
new TypeChangeInfo()
}
};
var type2 = type1.Clone();
Assert.AreNotSame(type1, type2);
Assert.AreEqual(type1.Name, type2.Name);
Assert.AreEqual(type1.Kind, type2.Kind);
Assert.AreEqual(type1.Obsolete, type2.Obsolete);
Assert.AreEqual(type1.ObsoleteMessage, type2.ObsoleteMessage);
Assert.AreNotSame(type1.Members, type2.Members);
Assert.AreNotSame(type1.Members.Single(), type2.Members.Single());
Assert.AreNotSame(type1.Members.Single().Changes.Single(), type2.Members.Single().Changes.Single());
Assert.AreNotSame(type1.Changes, type2.Changes);
Assert.AreNotSame(type1.Changes.Single(), type2.Changes.Single());
}
示例7: It_detects_Obsolete_attributes
public void It_detects_Obsolete_attributes()
{
var typeInfo = new TypeInfo();
typeInfo.ReadType(Compiler.GetType(
@"namespace MyNamespace
{
[System.Obsolete(""This class is obsolete!"")]
public class MyClass
{
[System.Obsolete(""This constructor is obsolete!"")]
public MyClass() { }
[System.Obsolete(""This method is obsolete!"")]
public void MyMethod() { }
[System.Obsolete(""This property is obsolete!"")]
public int MyProperty { get; set; }
[System.Obsolete(""This event is obsolete!"")]
public event System.EventHandler MyEvent;
[System.Obsolete(""This field is obsolete!"")]
public int MyField;
}
}"));
Assert.IsTrue(typeInfo.Obsolete);
Assert.AreEqual("This class is obsolete!", typeInfo.ObsoleteMessage);
Assert.IsTrue(typeInfo.Members.Single(m => m.Name == ".ctor").Obsolete);
Assert.AreEqual("This constructor is obsolete!", typeInfo.Members.Single(m => m.Name == ".ctor").ObsoleteMessage);
Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyMethod").Obsolete);
Assert.AreEqual("This method is obsolete!", typeInfo.Members.Single(m => m.Name == "MyMethod").ObsoleteMessage);
Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyProperty").Obsolete);
Assert.AreEqual("This property is obsolete!", typeInfo.Members.Single(m => m.Name == "MyProperty").ObsoleteMessage);
Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyEvent").Obsolete);
Assert.AreEqual("This event is obsolete!", typeInfo.Members.Single(m => m.Name == "MyEvent").ObsoleteMessage);
Assert.IsTrue(typeInfo.Members.Single(m => m.Name == "MyField").Obsolete);
Assert.AreEqual("This field is obsolete!", typeInfo.Members.Single(m => m.Name == "MyField").ObsoleteMessage);
}
示例8: Create
public static TypeInfo Create(Type rootType, Func<Type, IEntityMetaDataProvider> provider)
{
if (null == rootType)
throw new ArgumentNullException(nameof(rootType));
if (null == provider)
throw new ArgumentNullException(nameof(provider));
TypeInfo typeInfo = new TypeInfo();
typeInfo.Id = rootType.FullName; //NosQL Id.
typeInfo.Pageable = rootType.GetCustomAttribute<GridPageableAttribute>();
typeInfo.Sortable = rootType.GetCustomAttribute<GridSortableAttribute>();
typeInfo.Filterable = rootType.GetCustomAttribute<GridFilterableAttribute>();
typeInfo.Editable = rootType.GetCustomAttribute<GridEditableAttribute>();
GridAttribute ga = rootType.GetCustomAttribute<GridAttribute>();
if (null != ga)
{
typeInfo.Groupable = ga.Groupable;
typeInfo.Height = ga.Height;
}
LoadFields(typeInfo, null, rootType, provider);
return typeInfo;
}
示例9: ExpressionInfo
ExpressionInfo(TypeInfo type, Object value) {
this.Type = type;
this.Value = value;
this.IsConstant = true;
this.BoxingKind = BoxingKind.None;
this.Negate = true;
}
示例10: CheckSemantic
public override void CheckSemantic(Scope scope, List<Error> errors)
{
countLoop++;
//chekeo la semantica de la expr inicial
ExprFor.CheckSemantic(scope, errors);
//si el tipo de retorno no es int lanzo un error
if (ExprFor.ReturnType!= null && ExprFor.ReturnType.BaseType.Name != "int")
errors.Add(new Error(Row, Col, "The first expression of <for> must be an int"));
//chekeo la semantica de la expr final
ExprTo.CheckSemantic(scope, errors);
//si no tiene errores esa expr
//si el tipo de retorno no es int lanzo un error
if (ExprTo.ReturnType != null && ExprTo.ReturnType.BaseType.Name != "int")
errors.Add(new Error(Row, Col, "The To'expression of <for> must be an int"));
//creo un nuevo scope
Scope for_scope = new Scope(scope);
//agrego la var de ciclo
for_scope.Variables.Add(IdLoop, new VarInfo(IdLoop, scope.ExistType("int")));
for_scope.IdLoop = IdLoop;
ExprDo.CheckSemantic(for_scope, errors);
ReturnType = new TypeInfo("void", null, TypeDecl.Base);
countLoop--;
}
示例11: ConventionInfo
public ConventionInfo()
{
Source = new TypeInfo();
Target = new TypeInfo();
SourceProp = new PropInfo();
TargetProp = new PropInfo();
}
示例12: GetTypeInfo
public TypeInfo GetTypeInfo(Type type)
{
if (!_typeInfos.ContainsKey(type))
{
var typeInfo = new TypeInfo
{
Id = _typeInfos.Count,
TypeName = type.AssemblyQualifiedName,
IsEnumerable = type.IsImplOf<IEnumerable>()
};
if (!typeInfo.IsEnumerable)
{
var propertyInfos = type.GetProperties();
var propertyNames = new SimpleList<string>();
foreach (var propertyInfo in propertyInfos)
{
if (!IsAValidProperty(propertyInfo)) continue;
propertyNames.Add(propertyInfo.Name);
}
typeInfo.PropertyNames = propertyNames;
}
_typeInfos.Add(type, typeInfo);
return typeInfo;
}
return _typeInfos[type];
}
示例13: TypeInfo_CustomAttributes
public static void TypeInfo_CustomAttributes(TypeInfo typeInfo)
{
String typeName = typeInfo.NameString();
if (typeName == null)
return;
ReflectionEventSource.Log.TypeInfo_CustomAttributes(typeName);
}
示例14: When_resolving_two_types_with_same_name
public When_resolving_two_types_with_same_name()
{
var a = new A { Int32Value = 0, StringValue = "" };
var b = new { Int32Value = 0, StringValue = "" };
var typeInfoA = new TypeInfo(a.GetType());
var typeInfoB = new TypeInfo(b.GetType());
typeInfoA.Name = "TestTypeName";
typeInfoB.Name = "TestTypeName";
typeInfoA.Namespace = "TestNamespace";
typeInfoB.Namespace = "TestNamespace";
typeInfoA.DeclaringType = null;
typeInfoB.DeclaringType = null;
var typeResolver = new TypeResolver();
resolvedTypeA1 = typeResolver.ResolveType(typeInfoA);
resolvedTypeB1 = typeResolver.ResolveType(typeInfoB);
resolvedTypeA2 = typeResolver.ResolveType(typeInfoA);
resolvedTypeB2 = typeResolver.ResolveType(typeInfoB);
}
示例15: CheckSemantic
public override void CheckSemantic(Scope scope, List<Error> errors)
{
string id_var = "";
//chekeo la semantica del lvalue
LeftExpr.CheckSemantic(scope, errors);
TypeInfo t = LeftExpr.ReturnType;
//en el caso de q sea una variable guardo
//su valor para despues compararlo con el id del ciclo
if (LeftExpr is VariableNode)
id_var = ((VariableNode)LeftExpr).Value;
//chekeo la semantica del rvalue
RigthExpr.CheckSemantic(scope, errors);
TypeInfo t1 = RigthExpr.ReturnType;
if (t != null && t1 != null && t.Name != t1.Name)
{
if (t1.Name == "nil")
{
if (t.Name == "int")
errors.Add(new Error(Row, Col, string.Format("Cannot assign nil to an int")));
}
else if(t1.Name == "void")
errors.Add(new Error(Row, Col, string.Format("The expression that try assign to \"{0}\" not return value", t.Name)));
else
errors.Add(new Error(Row, Col, string.Format("Cannot asssign \"{0}\" to \"{1}\"", t1.Name, t.Name)));
}
else
{
if (countLoop >0 && id_var == scope.IdLoop)
errors.Add(new Error(Row, Col, string.Format("Cannot assign any value to variable \"{0}\" of <for>", scope.IdLoop)));
}
ReturnType = new TypeInfo("void", null, TypeDecl.Base);
}