本文整理汇总了C#中System.Type类的典型用法代码示例。如果您正苦于以下问题:C# System.Type类的具体用法?C# System.Type怎么用?C# System.Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Type类属于命名空间,在下文中一共展示了System.Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumConstantNotPresentException
/// <summary>
/// Constructs a new
/// <code>EnumConstantNotPresentException</code>
/// with the current
/// stack trace and a detail message based on the specified enum type and
/// missing constant name.
/// </summary>
/// <param name="enumType">the enum type.</param>
/// <param name="constantName">the missing constant name.</param>
public EnumConstantNotPresentException(System.Type enumType_1, string constantName_1
) : base("enum constant " + enumType_1.FullName + "." + constantName_1 + " is missing"
)
{
this._enumType = enumType_1;
this._constantName = constantName_1;
}
示例2: Given_an_OdcmClass_Entity_Derived
public Given_an_OdcmClass_Entity_Derived()
{
base.Init(m =>
{
var @namespace = m.Namespaces[0];
var derivedClass = @namespace.Classes.First();
_baseClass = Any.OdcmEntityClass(@namespace);
@namespace.Types.Add(_baseClass);
derivedClass.Base = _baseClass;
if (!_baseClass.Derived.Contains(derivedClass))
{
_baseClass.Derived.Add(derivedClass);
}
});
_baseConcreteType = Proxy.GetClass(_baseClass.Namespace, _baseClass.Name);
_baseConcreteInterface = Proxy.GetInterface(_baseClass.Namespace, "I" + _baseClass.Name);
_baseFetcherType = Proxy.GetClass(_baseClass.Namespace, _baseClass.Name + "Fetcher");
_baseFetcherInterface = Proxy.GetInterface(_baseClass.Namespace, "I" + _baseClass.Name + "Fetcher");
_baseCollectionType = Proxy.GetClass(_baseClass.Namespace, _baseClass.Name + "Collection");
_baseCollectionInterface = Proxy.GetInterface(_baseClass.Namespace, "I" + _baseClass.Name + "Collection");
_toDerivedMethodName = "To" + ConcreteType.Name;
}
示例3: WriteDataContextCtors
protected virtual void WriteDataContextCtors(CodeWriter writer, Database schema, Type contextBaseType, GenerationContext context)
{
// ctor taking a connections tring
WriteDataContextCtor(writer, schema, contextBaseType,
new[] { new ParameterDefinition { Name = "connectionString", Type = typeof(string) } },
new[] { "connectionString" },
new[] { typeof(string) },
context);
// the two constructors below have the same prototype, so they are mutually exclusive
// the base class requires a IVendor
if (!WriteDataContextCtor(writer, schema, contextBaseType,
new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
new[] { "connection", writer.GetNewExpression(writer.GetMethodCallExpression(writer.GetLiteralFullType(context.SchemaLoader.Vendor.GetType()))) },
new[] { typeof(IDbConnection), typeof(IVendor) },
context))
{
// OR the base class requires no IVendor
WriteDataContextCtor(writer, schema, contextBaseType,
new[] { new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) } },
new[] { "connection" },
new[] { typeof(IDbConnection) },
context);
}
// ctor(string, MappingSource)
WriteDataContextCtor(writer, schema, contextBaseType,
new[] {
new ParameterDefinition { Name = "connection", Type = typeof(string) },
new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
},
new[] { "connection", "mappingSource" },
new[] { typeof(string), typeof (MappingSource) },
context);
// ctor(IDbConnection, MappingSource)
WriteDataContextCtor(writer, schema, contextBaseType,
new[] {
new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
},
new[] { "connection", "mappingSource" },
new[] { typeof(IDbConnection), typeof(MappingSource) },
context);
// just in case you'd like to specify another vendor than the one who helped generating this file
WriteDataContextCtor(writer, schema, contextBaseType,
new[] {
new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
},
new[] { "connection", "vendor" },
new[] { typeof(IDbConnection), typeof(IVendor) },
context);
WriteDataContextCtor(writer, schema, contextBaseType,
new[] {
new ParameterDefinition { Name = "connection", Type = typeof(IDbConnection) },
new ParameterDefinition { Name = "mappingSource", Type = typeof(MappingSource) },
new ParameterDefinition { Name = "vendor", Type = typeof(IVendor) },
},
new[] { "connection", "mappingSource", "vendor" },
new[] { typeof(IDbConnection), typeof(MappingSource), typeof(IVendor) },
context);
}
示例4: LuceneWork
protected LuceneWork(object id, string idInString, System.Type entityClass, Document document)
{
this.id = id;
this.idInString = idInString;
this.entityClass = entityClass;
this.document = document;
}
示例5: StartOnGUI
private void StartOnGUI(SerializedProperty property, GUIContent label)
{
_currentProp = property;
_label = label;
_currentKeysProp = _currentProp.FindPropertyRelative("_keys");
_currentValuesProp = _currentProp.FindPropertyRelative("_values");
_currentValuesProp.arraySize = _currentKeysProp.arraySize;
_lst = CachedReorderableList.GetListDrawer(_currentKeysProp, _lst_DrawHeader, _lst_DrawElement, _lst_OnAdd, _lst_OnRemove);
//_lst.draggable = false;
if(this.fieldInfo != null)
{
var attrib = this.fieldInfo.GetCustomAttributes(typeof(VariantCollection.AsPropertyListAttribute), false).FirstOrDefault() as VariantCollection.AsPropertyListAttribute;
_propertyListTargetType = (attrib != null) ? attrib.TargetType : null;
if(attrib != null && attrib.TargetType != null)
{
_propertyListTargetType = attrib.TargetType;
_propertyListMembers = (from m
in DynamicUtil.GetEasilySerializedMembersFromType(_propertyListTargetType, System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property, DynamicMemberAccess.Write)
select m).ToArray();
_propertyListNames = (from m in _propertyListMembers select m.Name).ToArray();
}
}
}
示例6: GetPlugIns
public void GetPlugIns()
{
System.Type[] plugInInterfaces = new System.Type[] {
typeof(PlugInInterface1),
typeof(PlugInInterface2),
typeof(PlugInInterface3)
};
IInfo[] plugIns = Info.GetPlugIns(Assembly.GetExecutingAssembly(),
plugInInterfaces);
List<IInfo> expectedPlugIns = new List<IInfo>();
expectedPlugIns.Add(new Info("PlugIn1A",
typeof(PlugInInterface1),
typeof(PlugIn1A).AssemblyQualifiedName));
expectedPlugIns.Add(new Info("PlugIn1-Blue",
typeof(PlugInInterface1),
typeof(PlugIn1Blue).AssemblyQualifiedName));
expectedPlugIns.Add(new Info("PlugIn2A",
typeof(PlugInInterface2),
typeof(PlugIn2A).AssemblyQualifiedName));
Assert.AreEqual(expectedPlugIns.Count, plugIns.Length);
foreach (IInfo plugIn in plugIns)
AssertPlugInIsExpected(plugIn, expectedPlugIns);
}
示例7: OnTaskInspectorGUI
////////////////////////////////////////
///////////GUI AND EDITOR STUFF/////////
////////////////////////////////////////
protected override void OnTaskInspectorGUI()
{
if (!Application.isPlaying && GUILayout.Button("Select Field")){
System.Action<FieldInfo> FieldSelected = (field)=> {
targetType = field.DeclaringType;
fieldName = field.Name;
checkValue = BBParameter.CreateInstance(field.FieldType, blackboard);
comparison = CompareMethod.EqualTo;
};
if (agent != null){
EditorUtils.ShowGameObjectFieldSelectionMenu(agent.gameObject, typeof(object), FieldSelected);
} else {
var menu = new UnityEditor.GenericMenu();
foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu);
menu.ShowAsContext();
Event.current.Use();
}
}
if (agentType != null && !string.IsNullOrEmpty(fieldName)){
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", agentType.FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
GUILayout.EndVertical();
GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
GUI.enabled = true;
EditorUtils.BBParameterField("Value", checkValue);
}
}
示例8: OnTaskInspectorGUI
////////////////////////////////////////
///////////GUI AND EDITOR STUFF/////////
////////////////////////////////////////
protected override void OnTaskInspectorGUI()
{
if (!Application.isPlaying && GUILayout.Button("Select Field")){
System.Action<FieldInfo> FieldSelected = (field)=>{
targetType = field.DeclaringType;
fieldName = field.Name;
setValue.SetType(field.FieldType);
};
var menu = new UnityEditor.GenericMenu();
if (agent != null){
foreach(var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ){
menu = EditorUtils.GetFieldSelectionMenu(comp.GetType(), typeof(object), FieldSelected, menu);
}
menu.AddSeparator("/");
}
foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true)){
menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu);
}
menu.ShowAsContext();
Event.current.Use();
}
if (agentType != null && !string.IsNullOrEmpty(fieldName)){
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name);
UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
UnityEditor.EditorGUILayout.LabelField("Field Type", setValue.varType.FriendlyName() );
GUILayout.EndVertical();
EditorUtils.BBParameterField("Set Value", setValue);
}
}
示例9: GraphSerializationData
//Construct
public GraphSerializationData(Graph graph)
{
this.version = SerializationVersion;
this.type = graph.GetType();
this.name = graph.name;
this.comments = graph.graphComments;
this.translation = graph.translation;
this.zoomFactor = graph.zoomFactor;
this.nodes = graph.allNodes;
this.canvasGroups = graph.canvasGroups;
this.localBlackboard = graph.localBlackboard;
var structConnections = new List<Connection>();
for (var i = 0; i < nodes.Count; i++){
if (nodes[i] is ISerializationCallbackReceiver){
(nodes[i] as ISerializationCallbackReceiver).OnBeforeSerialize();
}
for (var j = 0; j < nodes[i].outConnections.Count; j++){
structConnections.Add(nodes[i].outConnections[j]);
}
}
this.connections = structConnections;
this.primeNode = graph.primeNode;
}
示例10: GridWithType
//---------------------------------------------------------------------
//!< Create a grid.
protected GridWithType(uint rows,
uint columns,
System.Type dataType)
: base(rows, columns)
{
this.dataType = dataType;
}
示例11: AdoColumn
/// <summary>
///
/// </summary>
/// <param name="column"></param>
public AdoColumn(DataColumn column)
{
name = column.ColumnName;
type = column.DataType;
columnSize = column.MaxLength;
isNullable = column.AllowDBNull;
}
示例12: SecondaryTableSecondPass
public SecondaryTableSecondPass(EntityBinder entityBinder, IPropertyHolder propertyHolder,
System.Type annotatedClass)
{
this.entityBinder = entityBinder;
this.propertyHolder = propertyHolder;
this.annotatedClass = annotatedClass;
}
示例13: FSMStateMachineLogic
public FSMStateMachineLogic(System.Type stateClass, FSMStateMachine ownerSM, FSMStateMachineLogic parent)
{
m_ChildrenTypes = new List<System.Type>();
m_StateClass = stateClass;
m_OwnerSM = ownerSM;
m_Parent = parent;
}
示例14: OnTaskInspectorGUI
////////////////////////////////////////
///////////GUI AND EDITOR STUFF/////////
////////////////////////////////////////
protected override void OnTaskInspectorGUI()
{
if (!Application.isPlaying && GUILayout.Button("Select Field")){
System.Action<FieldInfo> FieldSelected = (field)=> {
targetType = field.DeclaringType;
fieldName = field.Name;
saveAs.SetType(field.FieldType);
};
if (agent != null){
EditorUtils.ShowGameObjectFieldSelectionMenu(agent.gameObject, typeof(object), FieldSelected);
} else {
var menu = new UnityEditor.GenericMenu();
foreach (var t in UserTypePrefs.GetPreferedTypesList(typeof(Component), true))
menu = EditorUtils.GetFieldSelectionMenu(t, typeof(object), FieldSelected, menu);
menu.ShowAsContext();
Event.current.Use();
}
}
if (agentType != null && !string.IsNullOrEmpty(fieldName)){
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", agentType.Name);
UnityEditor.EditorGUILayout.LabelField("Field", fieldName);
UnityEditor.EditorGUILayout.LabelField("Field Type", saveAs.varType.FriendlyName() );
GUILayout.EndVertical();
EditorUtils.BBParameterField("Save As", saveAs, true);
}
}
示例15: FGConsole
static FGConsole()
{
consoleWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow");
if (consoleWindowType != null)
{
consoleWindowField = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
consoleListViewField = consoleWindowType.GetField("m_ListView", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleLVHeightField = consoleWindowType.GetField("ms_LVHeight", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleActiveTextField = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
consoleOnGUIMethod = consoleWindowType.GetMethod("OnGUI", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
}
listViewStateType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ListViewState");
if (listViewStateType != null)
{
listViewStateRowField = listViewStateType.GetField("row", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
}
editorWindowPosField = typeof(EditorWindow).GetField("m_Pos", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntriesType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntries");
if (logEntriesType != null)
{
getEntryMethod = logEntriesType.GetMethod("GetEntryInternal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
startGettingEntriesMethod = logEntriesType.GetMethod("StartGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
endGettingEntriesMethod = logEntriesType.GetMethod("EndGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
}
logEntryType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntry");
if (logEntryType != null)
{
logEntry = System.Activator.CreateInstance(logEntryType);
logEntryFileField = logEntryType.GetField("file", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntryLineField = logEntryType.GetField("line", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
logEntryInstanceIDField = logEntryType.GetField("instanceID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
}
}