static void ValidateAndAddKeyProperties(DataFieldNameCollection keyProperties, Type interfaceType, IList <Type> superInterfacesType)
        {
            foreach (string propertyName in DataAttributeFacade.GetKeyPropertyNames(interfaceType))
            {
                PropertyInfo property = interfaceType.GetProperty(propertyName);
                if (property == null)
                {
                    foreach (Type superInterface in superInterfacesType)
                    {
                        property = superInterface.GetProperty(propertyName);
                        if (property != null)
                        {
                            break;
                        }
                    }
                }

                Verify.IsNotNull(property, "Missing property '{0}' on type '{1}' or one of its interfaces".FormatWith(propertyName, interfaceType));

                if (DynamicTypeReflectionFacade.IsKeyField(property))
                {
                    keyProperties.Add(propertyName, false);
                }
            }
        }
Beispiel #2
0
        private void InitializeDynamicTypeFunctions()
        {
            _standardDynamicTypeFunctions = new List <IFunction>();

            // pages
            _standardDynamicTypeFunctions.Add(new Pages.SitemapXmlFunction(_entityTokenFactory));
            _standardDynamicTypeFunctions.Add(new Pages.SitemapFunction(_entityTokenFactory));
            _standardDynamicTypeFunctions.Add(new Pages.GetPageIdFunction(_entityTokenFactory));
            _standardDynamicTypeFunctions.Add(new Pages.GetForeignPageInfoFunction(_entityTokenFactory));

            // data.filter
            List <Type> dataInterfaces = DataFacade.GetAllKnownInterfaces(UserType.Developer);

            object[] args = new object[] { _entityTokenFactory };

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                where DataAssociationRegistry.IsAssociationType(t)
                select(IFunction) Activator.CreateInstance(typeof(ActivePageReferenceFilter <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(FieldPredicatesFilter <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(CompoundFilter <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(DataReferenceFilter <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(GetXml <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                where DataAttributeFacade.GetKeyPropertyNames(t).Count == 1
                select(IFunction) Activator.CreateInstance(typeof(GetDataReference <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                where DataAttributeFacade.GetKeyPropertyNames(t).Count == 1
                select(IFunction) Activator.CreateInstance(typeof(GetNullableDataReference <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(AddDataInstance <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(UpdateDataInstance <>).MakeGenericType(t), args));

            _standardDynamicTypeFunctions.AddRange(
                from t in dataInterfaces
                select(IFunction) Activator.CreateInstance(typeof(DeleteDataInstance <>).MakeGenericType(t), args));
        }