コード例 #1
0
ファイル: SDPYamlConverter.cs プロジェクト: jsquire/ECMA2Yaml
        private void GenerateRequiredMetadata(ItemSDPModelBase model, ReflectionItem item, List <ReflectionItem> childrenItems = null)
        {
            MergeWhiteListedMetadata(model, item);
            if (item.ItemType != ItemType.Namespace)
            {
                ApiScanGenerator.Generate(model, item);
                if (_store.UWPMode)
                {
                    model.Metadata?.Remove(ApiScanGenerator.APISCAN_APILOCATION);
                }
            }
            F1KeywordsGenerator.Generate(model, item, childrenItems);
            HelpViewerKeywordsGenerator.Generate(model, item, childrenItems);

            // Per V3 requirement, we need to put page level monikers in metadata node.
            // To make it compatible with V2 and existing template code, we choose to duplicate this meta in both root level and metadata node
            if (model is OverloadSDPModel ||
                model is TypeSDPModel ||
                model is NamespaceSDPModel ||
                model is EnumSDPModel ||
                model is DelegateSDPModel)
            {
                model.Metadata[OPSMetadata.Monikers] = model.Monikers;
            }
        }
コード例 #2
0
        public static void Generate(ItemSDPModelBase model, ReflectionItem item)
        {
            var apiNames   = GetApiNames(item).ToList();
            var assemblies = item.AssemblyInfo?.Select(asm => asm.Name).Distinct().ToList();

            if (apiNames.Count > 0)
            {
                if (!model.Metadata.ContainsKey(APISCAN_APINAME))
                {
                    model.Metadata[APISCAN_APINAME] = apiNames;
                }
                if (!model.Metadata.ContainsKey(APISCAN_APILOCATION))
                {
                    model.Metadata[APISCAN_APILOCATION] = assemblies.Select(a => a + ".dll").ToList();
                }
                if (!model.Metadata.ContainsKey(APISCAN_TOPICTYPE))
                {
                    model.Metadata[APISCAN_TOPICTYPE] = new List <string> {
                        "apiref"
                    };
                }
                if (!model.Metadata.ContainsKey(APISCAN_APITYPE))
                {
                    model.Metadata[APISCAN_APITYPE] = new List <string> {
                        "Assembly"
                    };
                }
            }
        }
コード例 #3
0
 public static void Generate(ItemSDPModelBase model, ReflectionItem item, List <ReflectionItem> childrenItems)
 {
     if (!model.Metadata.ContainsKey(OPSMetadata.F1Keywords))
     {
         var keywords = GetF1Keywords(item).ToList();
         if (childrenItems != null)
         {
             foreach (var child in childrenItems)
             {
                 keywords.AddRange(GetF1Keywords(child));
             }
         }
         model.Metadata[OPSMetadata.F1Keywords] = keywords.Distinct().ToList();
     }
 }
コード例 #4
0
 private void MergeWhiteListedMetadata(ItemSDPModelBase model, ReflectionItem item)
 {
     if (item?.Metadata != null)
     {
         foreach (var pair in item.Metadata)
         {
             if (MetadataMapping.TryGetValue(pair.Key, out string newKey))
             {
                 model.Metadata[newKey] = pair.Value;
             }
         }
     }
     if (item?.ExtendedMetadata?.Count > 0)
     {
         foreach (var pair in item.ExtendedMetadata)
         {
             model.Metadata[pair.Key] = pair.Value;
         }
     }
 }
コード例 #5
0
 public static void Generate(
     ItemSDPModelBase model,
     ReflectionItem item,
     List <ReflectionItem> childrenItems)
 {
     if (model != null && !model.Metadata.ContainsKey(OPSMetadata.HelpViewerKeywords))
     {
         var keywords = item.ItemType == ItemType.Property // skip property overload
             ? new List <string>()
             : GetHelpViewerKeywordsCore(item).ToList();
         if (childrenItems != null)
         {
             foreach (var child in childrenItems)
             {
                 keywords.AddRange(GetHelpViewerKeywordsCore(child));
             }
         }
         if (keywords.Count > 0)
         {
             model.Metadata[OPSMetadata.HelpViewerKeywords] = keywords.Distinct().ToList();
         }
     }
 }
コード例 #6
0
ファイル: SDPYamlConverter.cs プロジェクト: jsquire/ECMA2Yaml
        private void GenerateUWPRequirements(ItemSDPModelBase model, ReflectionItem item)
        {
            UWPRequirements uwpRequirements = new UWPRequirements();

            if (item.Metadata.TryGetValue(UWPMetadata.DeviceFamilyNames, out object deviceFamilies))
            {
                String[]            familyNames = (String[])deviceFamilies;
                List <DeviceFamily> families    = new List <DeviceFamily>();
                if (familyNames.Length > 0 && item.Metadata.TryGetValue(UWPMetadata.DeviceFamilyVersions, out object deviceFamilyVersions))
                {
                    String[] familyVersions = (String[])deviceFamilyVersions;

                    if (familyVersions.Length > 0)
                    {
                        int minNameVersionPairs = Math.Min(familyNames.Length, familyVersions.Length);

                        for (int i = 0; i < minNameVersionPairs; i++)
                        {
                            DeviceFamily df = new DeviceFamily {
                                Name = familyNames[i], Version = familyVersions[i]
                            };
                            families.Add(df);
                        }
                    }
                }

                if (families.Count > 0)
                {
                    uwpRequirements.DeviceFamilies = families;
                }
            }
            if (item.Metadata.TryGetValue(UWPMetadata.ApiContractNames, out object apiContracts))
            {
                String[]           apicNames = (String[])apiContracts;
                List <APIContract> contracts = new List <APIContract>();
                if (apicNames.Length > 0 && item.Metadata.TryGetValue(UWPMetadata.ApiContractVersions, out object apicVersions))
                {
                    String[] contractVersions = (String[])apicVersions;

                    if (contractVersions.Length > 0)
                    {
                        int minNameVersionPairs = Math.Min(apicNames.Length, contractVersions.Length);

                        for (int i = 0; i < minNameVersionPairs; i++)
                        {
                            APIContract apic = new APIContract {
                                Name = apicNames[i], Version = contractVersions[i]
                            };
                            contracts.Add(apic);
                        }
                    }
                }

                if (contracts.Count > 0)
                {
                    uwpRequirements.APIContracts = contracts;
                }
            }
            if (item.Metadata.TryGetValue(UWPMetadata.SDKRequirementsName, out object sdkReqName))
            {
                SDKRequirements sdkRequirements = new SDKRequirements {
                    Name = (string)sdkReqName
                };
                if (item.Metadata.TryGetValue(UWPMetadata.SDKRequirementsUrl, out object sdkReqUrl))
                {
                    sdkRequirements.Url = (string)sdkReqUrl;
                }
                model.SDKRequirements = sdkRequirements;
            }
            if (item.Metadata.TryGetValue(UWPMetadata.OSRequirementsName, out object osReqName))
            {
                OSRequirements osRequirements = new OSRequirements {
                    Name = (string)osReqName
                };
                if (item.Metadata.TryGetValue(UWPMetadata.OSRequirementsMinVersion, out object osReqMinVer))
                {
                    osRequirements.MinVer = (string)osReqMinVer;
                }
                model.OSRequirements = osRequirements;
            }
            if (item.Metadata.TryGetValue(UWPMetadata.Capabilities, out object capabilities))
            {
                model.Capabilities = (IEnumerable <string>)capabilities;
            }
            if (item.Metadata.TryGetValue(UWPMetadata.XamlMemberSyntax, out object xamlMemberSyntax))
            {
                model.XamlMemberSyntax = (string)xamlMemberSyntax;
            }
            if (item.Metadata.TryGetValue(UWPMetadata.XamlSyntax, out object xamlSyntax))
            {
                model.XamlSyntax = (string)xamlSyntax;
            }

            if (uwpRequirements.DeviceFamilies != null ||
                uwpRequirements.APIContracts != null)
            {
                model.UWPRequirements = uwpRequirements;
            }
        }