private Type ConvertToType(PropertyTreeNavigator nav, Type rootType) { QualifiedName fixedName = nav.QualifiedName; string name = fixedName.LocalName; if (char.IsLower(name[0])) { name = char.ToUpperInvariant(name[0]) + name.Substring(1); fixedName = fixedName.ChangeLocalName(name); } if (string.IsNullOrEmpty(nav.Namespace)) { // Try looking for the name in the same assembly var choices = rootType.GetTypeInfo().Assembly.GetTypesHelper() .Where(t => t.IsPublic && t.Name == name); if (choices.Any()) { return(choices.SingleOrThrow(() => PropertyTreesFailure.UnableToMatchTypeNameAmbiguous(nav.Name, choices)).AsType()); } else { throw PropertyTreesFailure.UnableToMatchTypeNameZero(name); } } else { return(App.GetTypeByQualifiedName(fixedName, true)); } }
public static TemplateMetaObject FromTemplateType(Type componentType) { // Assume Template<T> is the input var ct = componentType.GetTypeInfo(); var instType = ct.GetGenericArguments()[0]; if (instType.GetActivationConstructor() == null) { throw PropertyTreesFailure.TemplateTypeConstructorMustBeNiladic("componentType", componentType); } return(new TemplateMetaObject(null, instType)); }
public static PropertyTreeMetaObject Create(object component, Type componentType) { if (component == null && componentType == null) { throw PropertyTreesFailure.PropertyTreeMetaObjectComponentNull(); } componentType = componentType ?? component.GetType(); if (component != null && !componentType.IsInstanceOfType(component)) { throw new NotImplementedException(); } if (component is System.Collections.ICollection) { return(new CollectionMetaObject(component)); } return(new ReflectionMetaObject(component, componentType)); }
public void NoTargetProviderMatches(Type componentType, FileLocation loc) { throw PropertyTreesFailure.NoTargetProviderMatches(componentType, loc); }
public void NoAddMethodSupported(Type type, FileLocation loc) { throw PropertyTreesFailure.NoAddMethodSupported(type, loc); }
public void RequiredPropertiesMissing(IEnumerable <string> requiredMissing, OperatorDefinition op, FileLocation loc) { throw PropertyTreesFailure.RequiredPropertiesMissing(requiredMissing, op.ToString(), loc.LineNumber, loc.LinePosition); }
public void DuplicatePropertyName(IEnumerable <QualifiedName> duplicates, FileLocation loc) { throw PropertyTreesFailure.DuplicatePropertyName(duplicates, loc); }
public void CouldNotBindStreamingSource(Type componentType, FileLocation loc) { throw PropertyTreesFailure.CouldNotBindStreamingSource(componentType, loc); }
public void CouldNotBindGenericParameters(Type componentType, Exception ex, FileLocation loc) { throw PropertyTreesFailure.CouldNotBindGenericParameters(componentType, ex, loc); }
public string ConvertToString(object value, IValueSerializerContext context) { throw PropertyTreesFailure.CannotConvertToString(); }
public void BindUnmatchedProperty(QualifiedName qualifiedName, Type componentType, FileLocation loc) { throw PropertyTreesFailure.UnmatchedMembersGenericError(qualifiedName, componentType, loc); }
public void BinderConversionError(string name, Type componentType, Exception ex, FileLocation loc) { throw PropertyTreesFailure.BinderConversionError(name, componentType, ex, loc); }
public void BadAddChild(Type parentType, Exception ex, FileLocation loc) { throw PropertyTreesFailure.BadAddChild(parentType, ex, loc); }
public void BadTargetProviderDirective(Exception ex, FileLocation loc) { throw PropertyTreesFailure.BadTargetProviderDirective(ex, loc); }
public void FailedToLoadFromSource(Uri uri, Exception ex, FileLocation loc) { throw PropertyTreesFailure.FailedToLoadFromSource(uri, ex, loc); }
public void BadSourceDirective(Exception ex, FileLocation loc) { throw PropertyTreesFailure.BadSourceDirective(ex, loc); }
public object ConvertFromString(string text, Type destinationType, IValueSerializerContext context) { throw PropertyTreesFailure.CannotConvertFromString(destinationType); }