private IDictionary <string, string> CreateOutputStringsCore <TLocal>(IRootGroup rootGroup, string outputRootDirectory,
                                                                              IMetadataLoader <TLocal> metadataLoader, PropertyInfo childProperty, Type childPropertyType, string attributeIdentifier, IEnumerable <TemplateMap> templateMaps)
            where TLocal : CodeFirstMetadata <TLocal>
        {
            var newDict      = new Dictionary <string, string>();
            var metadataList = GetMetadata(attributeIdentifier, metadataLoader, rootGroup.Roots);

            IEnumerable <CodeFirstMetadata> candidates;

            if (childPropertyType != null)
            {
                candidates = metadataList
                             .Where(x => x != null)
                             .SelectMany(x => (childProperty.GetValue(x) as IEnumerable <CodeFirstMetadata>)).ToList();
            }
            else
            {
                candidates = metadataList.Where(x => x.GetType().FullName == typeof(TLocal).FullName);
            }
            if (candidates.Any())
            {
                foreach (var candidate in candidates)
                {
                    var candidateMaps = templateMaps;
                    //.Where(x => x.EntryPointType == typeof(T));
                    foreach (var candidateMap in candidateMaps)
                    {
                        var firstNamespace = candidate
                                             .AncestorsAndSelf
                                             .OfType <ICodeFirstMetadataNamespace>()
                                             .FirstOrDefault();
                        var inFileName = firstNamespace == null
                                      ? null
                                      : firstNamespace.FilePath;
                        // TODO: This is wrong so I can test the rest of the system
                        var outFileName = Path.Combine(Path.GetDirectoryName(inFileName), Path.GetFileNameWithoutExtension(inFileName)) + ".g.cs";
                        var genericChildPropertyType = candidateMap.ChildProperty == null
                                                 ? null
                                                 : candidateMap.ChildProperty.PropertyType.GenericTypeArguments.FirstOrDefault();
                        var templateType = genericChildPropertyType != null
                                        ? genericChildPropertyType
                                        : candidateMap.EntryPointType;
                        var outText = ReflectionHelpers.InvokeGenericMethod(typeof(TemplateRunnerBase).GetTypeInfo(), "CreateOutputString",
                                                                            templateType, this,
                                                                            candidateMap.Template, candidate)
                                      as string;
                        newDict.Add(outFileName, outText);
                    }
                }
                //newDict = ReflectionHelpers.InvokeGenericMethod(this.GetType().GetTypeInfo(), "CreateOutputStringsGeneric",
                //                          typeof(TLocal), this,
                //                          candidates, templateMaps,metadataLoader, outputRootDirectory)
                //                       as Dictionary<string, string>;
            }
            return(newDict);
        }
 public TemplateMap(string attributeIdentifier,
                    Type entryPointType,
                    ITemplate template,
                    IMetadataLoader metadataLoader,
                    PropertyInfo childProperty = null)
 {
     AttributeIdentifier = attributeIdentifier;
     Template            = template;
     MetadataLoader      = metadataLoader;
     ChildProperty       = childProperty;
     EntryPointType      = entryPointType;
 }
 public TemplateMap(string attributeIdentifier,
           Type entryPointType,
           ITemplate template,
           IMetadataLoader metadataLoader,
           PropertyInfo childProperty = null)
 {
     AttributeIdentifier = attributeIdentifier;
      Template = template;
      MetadataLoader = metadataLoader;
      ChildProperty = childProperty;
      EntryPointType = entryPointType;
 }
Esempio n. 4
0
        public void InitBase()
        {
            _loader   = new YamlMetadataLoader();
            WebDriver = new NullDriver();

            var factory = new SimpleObjectFactory();

            TurboInitializer.RegisterBuiltInTypes(factory);
            factory.Instance(_loader);

            PageBuilder = factory.GetInstance <IPageFactory>();
        }
        public MetadataFileManager(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            _name      = name.Trim();
            _syncRoot  = new object();
            _isLoaded  = false;
            _loader    = new MetadataFileLoader();
            _metadatas = new MetadataCollection(this);
            _commands  = new CommandCollection(_metadatas);
            _entities  = new EntityCollection(_metadatas);
        }
        protected IEnumerable <T> GetMetadata <T>(
            string attributeIdentifier,
            IMetadataLoader <T> metadataLoader,
            IEnumerable <IRoot> roots)
            where T : CodeFirstMetadata <T>
        {
            var ret = new List <T>();

            foreach (var root in roots)
            {
                var metadata = metadataLoader.LoadFrom(root, attributeIdentifier);
                ret.Add(metadata);
            }
            return(ret);
        }
Esempio n. 7
0
        public MusicFileCop(IFileSystemLoader fileSystemLoader, IConfigurationLoader configurationLoader,
                            IMetadataLoader metadataLoader, IConsistencyChecker consistencyChecker,
                            IDefaultConfigurationNode defaultConfiguration, IConfigurationWriter configWriter, ITextOutputWriter outputWriter, IRuleSet ruleSet)
        {
            if (fileSystemLoader == null)
            {
                throw new ArgumentNullException(nameof(fileSystemLoader));
            }
            if (configurationLoader == null)
            {
                throw new ArgumentNullException(nameof(configurationLoader));
            }
            if (metadataLoader == null)
            {
                throw new ArgumentNullException(nameof(metadataLoader));
            }
            if (consistencyChecker == null)
            {
                throw new ArgumentNullException(nameof(consistencyChecker));
            }
            if (defaultConfiguration == null)
            {
                throw new ArgumentNullException(nameof(defaultConfiguration));
            }
            if (configWriter == null)
            {
                throw new ArgumentNullException(nameof(configWriter));
            }
            if (outputWriter == null)
            {
                throw new ArgumentNullException(nameof(outputWriter));
            }
            if (ruleSet == null)
            {
                throw new ArgumentNullException(nameof(ruleSet));
            }

            this.m_FileSystemLoader     = fileSystemLoader;
            this.m_ConfigLoader         = configurationLoader;
            this.m_MetadataLoader       = metadataLoader;
            this.m_ConsistencyChecker   = consistencyChecker;
            this.m_DefaultConfiguration = defaultConfiguration;
            m_ConfigWriter = configWriter;
            m_OutputWriter = outputWriter;
            m_RuleSet      = ruleSet;
        }
Esempio n. 8
0
 public InfoProvider(IMetadataLoader metadata)
 {
     _metadata = metadata;
 }
 public ServiceProxyGenerator(IMetadataLoader metadataLoader)
 {
     mMetadataLoader = metadataLoader;
 }