本文整理汇总了C#中System.Type类的典型用法代码示例。如果您正苦于以下问题:C# Type类的具体用法?C# Type怎么用?C# Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于System命名空间,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanConvertTo
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
if (context == null)
return false;
var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
return p != null && destinationType == typeof (string);
}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs
示例2: ConvertTo
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (context == null)
return null;
var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
return p != null ? p.GetName (value) : null;
}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs
示例3: Convert
public object Convert(object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture)
{
if (values == null ||
values.Length != 2)
{
return Visibility.Collapsed;
}
if (values[0] is IEnumerable<string>)
{
var a = (IEnumerable<string>)values[0];
var b = values[1];
if (a.Contains(b) == true)
{
return Visibility.Collapsed;
}
}
else if (values[0] is ItemCollection)
{
var a = (ItemCollection)values[0];
var b = values[1];
if (a.Contains(b) == true)
{
return Visibility.Collapsed;
}
}
return Visibility.Visible;
}
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:34,代码来源:ContainsToVisiblityConverter.cs
示例4: ConvertBack
public object[] ConvertBack(object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:7,代码来源:ContainsToVisiblityConverter.cs
示例5: GetModule
private IEnumerable<PluginWrapper> GetModule(string pFileName, Type pTypeInterface)
{
var plugins = new List<PluginWrapper>();
try
{
var assembly = Assembly.LoadFrom(pFileName);
foreach(var type in assembly.GetTypes())
{
try
{
if(!type.IsPublic || type.IsAbstract)
continue;
var typeInterface = type.GetInterface(pTypeInterface.ToString(), true);
if(typeInterface == null)
continue;
var instance = Activator.CreateInstance(type) as IPlugin;
if(instance != null)
plugins.Add(new PluginWrapper(pFileName, instance));
}
catch(Exception ex)
{
Logger.WriteLine("Error Loading " + pFileName + ":\n" + ex, "PluginManager");
}
}
}
catch(Exception ex)
{
Logger.WriteLine("Error Loading " + pFileName + ":\n" + ex, "PluginManager");
}
return plugins;
}
开发者ID:rudzu,项目名称:Hearthstone-Deck-Tracker,代码行数:31,代码来源:PluginManager.cs
示例6: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be boolean.");
return !(bool)value;
}
开发者ID:peterschen,项目名称:SMAStudio,代码行数:7,代码来源:InverseBoolConverter.cs
示例7: ClassInfo
public ClassInfo(bool isAbstract, Type superClass, Db4objects.Db4o.Reflect.Self.FieldInfo
[] fieldInfo)
{
_isAbstract = isAbstract;
_superClass = superClass;
_fieldInfo = fieldInfo;
}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:7,代码来源:ClassInfo.cs
示例8: GetLoadableTypes
public IEnumerable<Type> GetLoadableTypes(Assembly assembly, Type ofBaseType)
{
var types = GetLoadableTypes(assembly);
return types != null
? types.Where(ofBaseType.IsAssignableFrom)
: null;
}
开发者ID:juancarlospalomo,项目名称:tantumcms,代码行数:7,代码来源:DefaultAssemblyLoader.cs
示例9: CreateInOutParamTypes
protected override Type[] CreateInOutParamTypes(Uiml.Param[] parameters, out Hashtable outputPlaceholder)
{
outputPlaceholder = null;
Type[] tparamTypes = new Type[parameters.Length];
int i=0;
try
{
for(i=0; i<parameters.Length; i++)
{
tparamTypes[i] = Type.GetType(parameters[i].Type);
int j = 0;
while(tparamTypes[i] == null)
tparamTypes[i] = ((Assembly)ExternalLibraries.Instance.Assemblies[j++]).GetType(parameters[i].Type);
//also prepare a placeholder when this is an output parameter
if(parameters[i].IsOut)
{
if(outputPlaceholder == null)
outputPlaceholder = new Hashtable();
outputPlaceholder.Add(parameters[i].Identifier, null);
}
}
return tparamTypes;
}
catch(ArgumentOutOfRangeException aore)
{
Console.WriteLine("Can not resolve type {0} of parameter {1} while calling method {2}",parameters[i].Type ,i , Call.Name);
Console.WriteLine("Trying to continue without executing {0}...", Call.Name);
throw aore;
}
}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:30,代码来源:LocalCaller.cs
示例10: TestRoute
public void TestRoute(string url, string verb, Type type, string actionName)
{
//Arrange
url = url.Replace("{apiVersionNumber}", this.ApiVersionNumber);
url = Host + url;
//Act
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(verb), url);
IHttpControllerSelector controller = this.GetControllerSelector();
IHttpActionSelector action = this.GetActionSelector();
IHttpRouteData route = this.Config.Routes.GetRouteData(request);
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = route;
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = this.Config;
HttpControllerDescriptor controllerDescriptor = controller.SelectController(request);
HttpControllerContext context = new HttpControllerContext(this.Config, route, request)
{
ControllerDescriptor = controllerDescriptor
};
var actionDescriptor = action.SelectAction(context);
//Assert
Assert.NotNull(controllerDescriptor);
Assert.NotNull(actionDescriptor);
Assert.Equal(type, controllerDescriptor.ControllerType);
Assert.Equal(actionName, actionDescriptor.ActionName);
}
开发者ID:abinabrahamanchery,项目名称:mixerp,代码行数:31,代码来源:GetPartyTypeIdByPartyCodeRouteTests.cs
示例11: InternalGetAjaxMethods
private static Dictionary<string, AsyncMethodInfo> InternalGetAjaxMethods(Type type)
{
var ret = new Dictionary<string, AsyncMethodInfo>();
var mis = CoreHelper.GetMethodsFromType(type);
foreach (MethodInfo mi in mis)
{
string methodName = mi.Name;
var method = CoreHelper.GetMemberAttribute<AjaxMethodAttribute>(mi);
if (method != null)
{
if (!string.IsNullOrEmpty(method.Name))
{
methodName = method.Name;
}
if (!ret.ContainsKey(methodName))
{
AsyncMethodInfo asyncMethod = new AsyncMethodInfo();
asyncMethod.Method = mi;
asyncMethod.Async = method.Async;
ret[methodName] = asyncMethod;
}
}
}
return ret;
}
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:27,代码来源:AjaxMethodHelper.cs
示例12: DeleteById
public void DeleteById(Type type, string key, string value)
{
string sql = "delete from " + type.Name;
sql += " where " + key + "=" + value;
DBExtBase.ExeNonQueryBySqlText(this.dataCtx, sql);
}
开发者ID:zitjubiz,项目名称:terryCBM,代码行数:7,代码来源:BaseService.cs
示例13: Help
/// <summary>
/// Displays help for the specified command.
/// <param name="Command">Command type.</param>
/// </summary>
public static void Help(Type Command)
{
string Description;
List<string> Params;
GetTypeHelp(Command, out Description, out Params);
LogHelp(Command, Description, Params);
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:11,代码来源:HelpUtils.cs
示例14: GetSchema
public override List<ExplorerItem> GetSchema(IConnectionInfo connectionInfo, Type customType)
{
var indexDirectory = connectionInfo.DriverData.FromXElement<LuceneDriverData>().IndexDirectory;
//TODO: Fields with configured delimiters should show up as a tree
//TODO: Show Numeric and String fields with their types
//TODO: If the directory selected contains sub-directories, maybe we should show them all...
using (var directory = FSDirectory.Open(new DirectoryInfo(indexDirectory)))
using (var indexReader = IndexReader.Open(directory, true))
{
return indexReader
.GetFieldNames(IndexReader.FieldOption.ALL)
.Select(fieldName =>
{
//var field = //TODO: Get the first document with this field and get its types.
return new ExplorerItem(fieldName, ExplorerItemKind.QueryableObject, ExplorerIcon.Column)
{
IsEnumerable = false, //TODO: Should be true when its a multi-field
ToolTipText = "Cool tip"
};
})
.ToList();
}
}
开发者ID:ChristopherHaws,项目名称:LinqPad-Lucene-Driver,代码行数:25,代码来源:LuceneIndexDriver.cs
示例15: Deserialize
// public methods
/// <summary>
/// Deserializes an object from a BsonReader.
/// </summary>
/// <param name="bsonReader">The BsonReader.</param>
/// <param name="nominalType">The nominal type of the object.</param>
/// <param name="actualType">The actual type of the object.</param>
/// <param name="options">The serialization options.</param>
/// <returns>An object.</returns>
public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(double));
var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
{
case BsonType.Double:
return bsonReader.ReadDouble();
case BsonType.Int32:
return representationSerializationOptions.ToDouble(bsonReader.ReadInt32());
case BsonType.Int64:
return representationSerializationOptions.ToDouble(bsonReader.ReadInt64());
case BsonType.String:
return XmlConvert.ToDouble(bsonReader.ReadString());
default:
var message = string.Format("Cannot deserialize Double from BsonType {0}.", bsonType);
throw new FileFormatException(message);
}
}
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:34,代码来源:DoubleSerializer.cs
示例16: IsValidFixtureType
private bool IsValidFixtureType(Type type, ref string reason)
{
if (type.IsAbstract)
{
reason = string.Format("{0} is an abstract class", type.FullName);
return false;
}
if (Reflect.GetConstructor(type) == null)
{
reason = string.Format("{0} does not have a valid constructor", type.FullName);
return false;
}
if (!NUnitFramework.CheckSetUpTearDownMethods(type, NUnitFramework.SetUpAttribute, ref reason) ||
!NUnitFramework.CheckSetUpTearDownMethods(type, NUnitFramework.TearDownAttribute, ref reason) )
return false;
if ( Reflect.HasMethodWithAttribute(type, NUnitFramework.FixtureSetUpAttribute, true) )
{
reason = "TestFixtureSetUp method not allowed on a SetUpFixture";
return false;
}
if ( Reflect.HasMethodWithAttribute(type, NUnitFramework.FixtureTearDownAttribute, true) )
{
reason = "TestFixtureTearDown method not allowed on a SetUpFixture";
return false;
}
return true;
}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:32,代码来源:SetUpFixtureBuilder.cs
示例17: CreateMessage
static string CreateMessage(Type modelType, Type propertyType)
{
return string.Format(
"Model type '{0}' has invalid DebuggerDisplay return type '{1}'. Expected 'string'.",
modelType.FullName,
propertyType.Name);
}
开发者ID:natsihit2,项目名称:octokit.net,代码行数:7,代码来源:InvalidDebuggerDisplayReturnType.cs
示例18: CanConvert
public override bool CanConvert(Type objectType)
{
#if !DNX
useInternal = base.CanConvert(objectType);
#endif
return useInternal || objectType == typeof(byte[]);
}
开发者ID:gitter-badger,项目名称:RethinkDb.Driver,代码行数:7,代码来源:ReqlBinaryConverter.cs
示例19: JsonDynamicContract
/// <summary>
/// Initializes a new instance of the <see cref="JsonDynamicContract"/> class.
/// </summary>
/// <param name="underlyingType">The underlying type for the contract.</param>
public JsonDynamicContract(Type underlyingType)
: base(underlyingType)
{
ContractType = JsonContractType.Dynamic;
Properties = new JsonPropertyCollection(UnderlyingType);
}
开发者ID:modulexcite,项目名称:Transformalize,代码行数:11,代码来源:JsonDynamicContract.cs
示例20: Convert
public object Convert(object value, Type targetType, object parameter, string language)
{
var parameterValue = parameter as String;
bool toLower = false;
bool toUpper = false;
if (parameterValue != null)
{
toLower = parameterValue.ToLower().Equals("lower");
toUpper = parameterValue.ToLower().Equals("upper");
}
var inputValue = value as String;
String returnValue = inputValue;
if (!String.IsNullOrWhiteSpace(inputValue))
{
if (toLower)
{
returnValue = inputValue.ToLower();
}
else if (toUpper)
{
returnValue = inputValue.ToUpper();
}
}
return returnValue;
}
开发者ID:Blisse,项目名称:Windows8MASA,代码行数:28,代码来源:StringCaseConverter.cs
注:本文中的System.Type类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论