本文整理汇总了C#中IConceptInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IConceptInfo.GetType方法的具体用法?C# IConceptInfo.GetType怎么用?C# IConceptInfo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConceptInfo
的用法示例。
在下文中一共展示了IConceptInfo.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPluginMethods
private static List<MethodInfo> GetPluginMethods(IConceptMacro conceptMacro, IConceptInfo conceptInfo)
{
var methods = conceptMacro.GetType().GetInterfaces()
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IConceptMacro<>)
&& i.GetGenericArguments().Single().IsAssignableFrom(conceptInfo.GetType()))
.Select(i => i.GetMethod("CreateNewConcepts"))
.ToList();
if (methods.Count == 0)
throw new FrameworkException(string.Format(
"Plugin {0} does not implement generic interface {1} that accepts argument {2}.",
conceptMacro.GetType().FullName,
typeof(IConceptMacro<>).FullName,
conceptInfo.GetType().FullName));
return methods;
}
示例2: NewConceptApplication
public NewConceptApplication(IConceptInfo conceptInfo, IConceptDatabaseDefinition conceptImplementation)
{
Id = Guid.Empty;
ConceptInfo = conceptInfo;
ConceptInfoTypeName = conceptInfo.GetType().AssemblyQualifiedName;
ConceptInfoKey = conceptInfo.GetKey();
ConceptImplementation = conceptImplementation;
ConceptImplementationType = conceptImplementation.GetType();
ConceptImplementationTypeName = ConceptImplementationType.AssemblyQualifiedName;
ConceptImplementationVersion = GetVersionFromAttribute(ConceptImplementationType);
}
示例3: BaseConceptInfoType
private static Type BaseConceptInfoType(IConceptInfo ci)
{
Type t = ci.GetType();
while (typeof(IConceptInfo).IsAssignableFrom(t.BaseType) && t.BaseType.IsClass)
t = t.BaseType;
return t;
}
示例4: AppendMembers
private static void AppendMembers(StringBuilder text, IConceptInfo ci, SerializationOptions serializationOptions, bool exceptionOnNullMember = false, Type asBaseConceptType = null)
{
IEnumerable<ConceptMember> members = ConceptMembers.Get(asBaseConceptType ?? ci.GetType());
if (serializationOptions == SerializationOptions.KeyMembers)
members = members.Where(member => member.IsKey);
bool firstMember = true;
foreach (ConceptMember member in members)
{
string separator = member.IsKey ? "." : " ";
if (!firstMember)
text.Append(separator);
firstMember = false;
AppendMember(text, ci, member, exceptionOnNullMember);
}
}
示例5: AppendMember
private static void AppendMember(StringBuilder text, IConceptInfo ci, ConceptMember member, bool exceptionOnNullMember)
{
object memberValue = member.GetValue(ci);
if (memberValue == null)
if (exceptionOnNullMember)
throw new DslSyntaxException(ci, string.Format(
"{0}'s property {1} is null. Info: {2}.",
ci.GetType().Name, member.Name, ci.GetErrorDescription()));
else
text.Append("<null>");
else if (member.IsConceptInfo)
{
IConceptInfo value = (IConceptInfo)member.GetValue(ci);
if (member.ValueType == typeof(IConceptInfo))
text.Append(BaseConceptInfoType(value).Name).Append(":");
AppendMembers(text, value, SerializationOptions.KeyMembers, exceptionOnNullMember);
}
else if (member.ValueType == typeof(string))
text.Append(SafeDelimit(member.GetValue(ci).ToString()));
else
throw new FrameworkException(string.Format(
"IConceptInfo member {0} of type {1} in {2} is not supported.",
member.Name, member.ValueType.Name, ci.GetType().Name));
}
示例6: ParseMembers
private ValueOrError<IConceptInfo> ParseMembers(ITokenReader tokenReader, IConceptInfo lastConcept, bool readingAReference)
{
IConceptInfo conceptInfo = (IConceptInfo)Activator.CreateInstance(ConceptInfoType);
bool firstMember = true;
bool lastPropertyWasInlineParent = false;
bool lastConceptUsed = false;
var listOfMembers = readingAReference ? Members.Where(m => m.IsKey) : Members.Where(m => m.IsParsable);
foreach (ConceptMember member in listOfMembers)
{
var valueOrError = ReadMemberValue(member, tokenReader, lastConcept, firstMember, ref lastPropertyWasInlineParent, ref lastConceptUsed, readingAReference);
if (valueOrError.IsError)
return ValueOrError<IConceptInfo>.CreateError(string.Format(CultureInfo.InvariantCulture,
"Cannot read the value of {0} in {1}. {2}",
member.Name, ConceptInfoType.Name, valueOrError.Error));
member.SetMemberValue(conceptInfo, valueOrError.Value);
firstMember = false;
}
if (!lastConceptUsed && lastConcept != null)
return ValueOrError<IConceptInfo>.CreateError(string.Format(
"This concept cannot be enclosed within {0}. Trying to read {1}.",
lastConcept.GetType().Name, ConceptInfoType.Name));
return ValueOrError<IConceptInfo>.CreateValue(conceptInfo);
}
示例7: SetMemberValue
public void SetMemberValue(IConceptInfo conceptInfo, object value)
{
PropertyInfo pi;
FieldInfo fi;
if ((pi = MemberInfo as PropertyInfo) != null)
try
{
pi.SetValue(conceptInfo, value, null);
}
catch (ArgumentException ae)
{
throw new FrameworkException(
string.Format(CultureInfo.InvariantCulture,
"Unable to convert property {0} in concept {1} from type {2} to type {3}",
pi.Name,
conceptInfo.GetType().FullName,
pi.PropertyType.FullName,
value != null ? value.GetType().FullName : "unknown"),
ae);
}
else if ((fi = MemberInfo as FieldInfo) != null)
try
{
fi.SetValue(conceptInfo, value);
}
catch (ArgumentException ae)
{
throw new FrameworkException(
string.Format(CultureInfo.InvariantCulture,
"Unable to convert property {0} in concept {1} from type {2} to type {3}",
pi.Name,
conceptInfo.GetType().FullName,
pi.PropertyType.FullName,
value != null ? value.GetType().FullName : "unknown"),
ae);
}
else
throw new FrameworkException(
string.Format(CultureInfo.InvariantCulture,
"Unexpected member type {0} for member {1}.",
MemberInfo.MemberType,
MemberInfo.Name));
}
示例8: ReportErrorContext
protected string ReportErrorContext(IConceptInfo conceptInfo, int index)
{
var sb = new StringBuilder();
sb.AppendLine(_dslSource.ReportError(index));
if (conceptInfo != null)
{
sb.AppendFormat("Previous concept: {0}", conceptInfo.GetUserDescription()).AppendLine();
var properties = conceptInfo.GetType().GetProperties().ToList();
properties.ForEach(it =>
sb.AppendFormat("Property {0} ({1}) = {2}",
it.Name,
it.PropertyType.Name,
it.GetValue(conceptInfo, null) ?? "<null>")
.AppendLine());
}
return sb.ToString();
}
示例9: Get
public static ConceptMember[] Get(IConceptInfo conceptInfo)
{
return Get(conceptInfo.GetType(), new Lazy<IConceptInfo>(() => conceptInfo));
}