Beispiel #1
0
        protected static string RepositoryFunctionsSnippet(ComputedInfo info)
        {
            return string.Format(
            @"        public static readonly Func<Common.DomRepository{2}, global::{0}.{1}[]> Compute =
            {3};

            ",
                info.Module.Name, info.Name, DomUtility.ComputationAdditionalParametersTypeTag.Evaluate(info), info.Expression);
        }
Beispiel #2
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(HierarchyInfo conceptInfo, IDslModel existingConcepts)
        {
            ComputedInfo computedDataStructure = conceptInfo.GetComputedDataStructure();
            PersistedDataStructureInfo persistedDataStructure = conceptInfo.GetPersistedDataStructure();
            var persistedLeftIndexProperty = new IntegerPropertyInfo {
                DataStructure = persistedDataStructure, Name = "LeftIndex"
            };

            var dependencies = GetDependsOnWriteableDataStructure(conceptInfo.DataStructure, existingConcepts, conceptInfo);
            var computedDataStructureDependencies = dependencies.Select(dependsOn =>
                                                                        new ChangesOnChangedItemsInfo
            {
                Computation   = computedDataStructure,
                DependsOn     = dependsOn,
                FilterType    = "FilterAll",
                FilterFormula = "changedItems => new FilterAll()"
            });

            var filterAncestorsParameter = new ParameterInfo {
                Module = conceptInfo.DataStructure.Module, Name = conceptInfo.Name + "HierarchyAncestors"
            };
            var filterDescendantsParameter = new ParameterInfo {
                Module = conceptInfo.DataStructure.Module, Name = conceptInfo.Name + "HierarchyDescendants"
            };

            return(new IConceptInfo[]
            {
                // Computing the hierarchy information:
                computedDataStructure,
                new ModuleExternalReferenceInfo {
                    Module = computedDataStructure.Module, TypeOrAssembly = @"Plugins\Rhetos.Dom.DefaultConcepts.dll"
                },
                new DataStructureExtendsInfo {
                    Extension = computedDataStructure, Base = conceptInfo.DataStructure
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "LeftIndex"
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "RightIndex"
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "Level"
                },

                // Persisting the hierarchy information:
                persistedDataStructure,
                new PersistedAllPropertiesInfo {
                    Persisted = persistedDataStructure
                },                                                                     // This will copy all properties from computedDataStructure.
                new PersistedKeepSynchronizedInfo {
                    Persisted = persistedDataStructure
                },
                persistedLeftIndexProperty,
                new SqlIndexInfo {
                    Property = persistedLeftIndexProperty
                },

                // Implement filters for finding ancestors and descendants, using indexed persisted data:
                filterAncestorsParameter,
                filterDescendantsParameter,
                new GuidPropertyInfo {
                    DataStructure = filterAncestorsParameter, Name = "ID"
                },
                new GuidPropertyInfo {
                    DataStructure = filterDescendantsParameter, Name = "ID"
                },
                new ComposableFilterByInfo {
                    Source = conceptInfo.DataStructure, Parameter = conceptInfo.Name + "HierarchyAncestors", Expression = conceptInfo.FilterAncestorsExpression()
                },
                new ComposableFilterByInfo {
                    Source = conceptInfo.DataStructure, Parameter = conceptInfo.Name + "HierarchyDescendants", Expression = conceptInfo.FilterDescendantsExpression()
                },
            }.Concat(computedDataStructureDependencies));
        }
Beispiel #3
0
 protected static string QueryFunctionBodySnippet(ComputedInfo info)
 {
     return string.Format(
         @"return Compute(_domRepository{0}).AsQueryable();",
         DomUtility.ComputationAdditionalParametersArgumentTag.Evaluate(info));
 }
 protected static string LoadFunctionBodySnippet(ComputedInfo info)
 {
     return string.Format(
         @"return Compute(_domRepository{0});",
         DataStructureUtility.ComputationAdditionalParametersArgumentTag.Evaluate(info));
 }