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));
                }
            }
Пример #2
0
        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));
        }
Пример #4
0
 public void NoTargetProviderMatches(Type componentType, FileLocation loc)
 {
     throw PropertyTreesFailure.NoTargetProviderMatches(componentType, loc);
 }
Пример #5
0
 public void NoAddMethodSupported(Type type, FileLocation loc)
 {
     throw PropertyTreesFailure.NoAddMethodSupported(type, loc);
 }
Пример #6
0
 public void RequiredPropertiesMissing(IEnumerable <string> requiredMissing, OperatorDefinition op, FileLocation loc)
 {
     throw PropertyTreesFailure.RequiredPropertiesMissing(requiredMissing, op.ToString(), loc.LineNumber, loc.LinePosition);
 }
Пример #7
0
 public void DuplicatePropertyName(IEnumerable <QualifiedName> duplicates, FileLocation loc)
 {
     throw PropertyTreesFailure.DuplicatePropertyName(duplicates, loc);
 }
Пример #8
0
 public void CouldNotBindStreamingSource(Type componentType, FileLocation loc)
 {
     throw PropertyTreesFailure.CouldNotBindStreamingSource(componentType, loc);
 }
Пример #9
0
 public void CouldNotBindGenericParameters(Type componentType, Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.CouldNotBindGenericParameters(componentType, ex, loc);
 }
Пример #10
0
 public string ConvertToString(object value, IValueSerializerContext context)
 {
     throw PropertyTreesFailure.CannotConvertToString();
 }
Пример #11
0
 public void BindUnmatchedProperty(QualifiedName qualifiedName, Type componentType, FileLocation loc)
 {
     throw PropertyTreesFailure.UnmatchedMembersGenericError(qualifiedName, componentType, loc);
 }
Пример #12
0
 public void BinderConversionError(string name, Type componentType, Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.BinderConversionError(name, componentType, ex, loc);
 }
Пример #13
0
 public void BadAddChild(Type parentType, Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.BadAddChild(parentType, ex, loc);
 }
Пример #14
0
 public void BadTargetProviderDirective(Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.BadTargetProviderDirective(ex, loc);
 }
Пример #15
0
 public void FailedToLoadFromSource(Uri uri, Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.FailedToLoadFromSource(uri, ex, loc);
 }
Пример #16
0
 public void BadSourceDirective(Exception ex, FileLocation loc)
 {
     throw PropertyTreesFailure.BadSourceDirective(ex, loc);
 }
Пример #17
0
 public object ConvertFromString(string text, Type destinationType, IValueSerializerContext context)
 {
     throw PropertyTreesFailure.CannotConvertFromString(destinationType);
 }