private void Traverse(CodeElements members) { foreach (CodeEnum codeEnum in members.OfType <CodeEnum>()) { WithCodeEnum(codeEnum); } foreach (CodeClass codeClass in members.OfType <CodeClass>()) { WithCodeClass(codeClass); } }
private void Traverse(CodeElements members) { foreach (var property in members.OfType <CodeProperty>()) { WithProperty(property); } }
internal static IEnumerable<IEnumValueMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { var value = -1; foreach (var codeVariable in codeElements.OfType<CodeVariable2>()) { if (codeVariable.InitExpression == null) value++; else { string initExpression = codeVariable.InitExpression.ToString(); if (int.TryParse(initExpression, out value) == false) { // Handle init expressions from char constants e.g. 'A' = 65 if (initExpression.Length == 3 && initExpression.StartsWith("'") && initExpression.EndsWith("'")) { value = initExpression[1]; } else if (initExpression.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { var convertedValue = _converter.ConvertFromString(initExpression); value = (int?)convertedValue ?? -1; } else { value = -1; } } } yield return new CodeDomEnumValueMetadata(codeVariable, file, value); } }
internal static IEnumerable <IEnumValueMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { var value = -1; foreach (var codeVariable in codeElements.OfType <CodeVariable2>()) { if (codeVariable.InitExpression == null) { value++; } else { string initExpression = codeVariable.InitExpression.ToString(); if (int.TryParse(initExpression, out value) == false) { // Handle init expressions from char constants e.g. 'A' = 65 if (initExpression.Length == 3 && initExpression.StartsWith("'") && initExpression.EndsWith("'")) { value = initExpression[1]; } else { value = -1; } } } yield return(new CodeDomEnumValueMetadata(codeVariable, file, value)); } }
public static IEnumerable <CodeElement> GetCodeElements(this CodeElements codeElements, vsCMElement kind, params vsCMElement[] containers) { return(codeElements .OfType <CodeElement>() .Flatten(p => containers.Contains(p.Kind) ? p.Children.OfType <CodeElement>() : null) .Where(p => p.Kind == kind)); }
private void Traverse(CodeElements members) { foreach (var codeClass in members.OfType <CodeClass>()) { Traverse(codeClass); } }
private void Traverse(ProjectItems items) { foreach (ProjectItem pi in items) { if (pi.FileCodeModel != null) { if (CodeTraverser.Settings.ProjectNamesToProcess == null || CodeTraverser.Settings.ProjectNamesToProcess.Contains(pi.ContainingProject.Name)) { CodeElements codeElements = pi.FileCodeModel.CodeElements; foreach (CodeNamespace ns in codeElements.OfType <CodeNamespace>()) { WithNamespace(ns); } } } if (pi.ProjectItems != null) { Traverse(pi.ProjectItems); } /* LionSoft: Process projects in solution folders */ else if (pi.SubProject != null && pi.SubProject.ProjectItems != null) { Traverse(pi.SubProject.ProjectItems); } /* --- */ } }
private void Traverse(CodeElements members) { var index = 0; foreach (var property in members.OfType<CodeVariable>()) { WithVariable(property, index); if (property.InitExpression != null) index = Int32.Parse(property.InitExpression.ToString()); index++; } }
private static IEnumerable <IntellisenseProperty> GetProperties(ProjectItem projectItem, DefinitionMapData definitionMapData, CodeElements props, HashSet <string> traversedTypes, HashSet <string> references = null) { return(from p in props.OfType <CodeProperty>() where !p.Attributes.Cast <CodeAttribute>().Any(HasIgnoreAttribute) where vsCMAccess.vsCMAccessPublic == p.Access && p.Getter != null && !p.Getter.IsShared && IsPublic(p.Getter) select new IntellisenseProperty { Name = GetName(p), Type = GetType(projectItem, definitionMapData, p.Parent, p.Type, traversedTypes, references), Summary = GetSummary(p) }); }
private static IEnumerable <IntellisenseProperty> GetProperties(CodeElements props, HashSet <string> traversedTypes, HashSet <string> references = null) { return(from p in props.OfType <CodeProperty>() where !p.Attributes.Cast <CodeAttribute>().Any(a => a.Name == "IgnoreDataMember") where p.Getter != null && !p.Getter.IsShared && p.Getter.Access == vsCMAccess.vsCMAccessPublic select new IntellisenseProperty { Name = GetName(p), Type = GetType(p.Parent, p.Type, traversedTypes, references), Summary = GetSummary(p) }); }
internal static IEnumerable<IEnumValueMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { var value = -1; foreach (var codeVariable in codeElements.OfType<CodeVariable2>()) { if (codeVariable.InitExpression == null) value++; else value = Convert.ToInt32(codeVariable.InitExpression); yield return new CodeDomEnumValueMetadata(codeVariable, file, value); } }
private void Traverse(CodeElements members) { int index = 0; foreach (CodeVariable property in members.OfType <CodeVariable>()) { WithVariable(property, index); if (property.InitExpression != null) { index = Int32.Parse(property.InitExpression.ToString()); } index++; } }
/// <summary> /// Retrieves code items from each specified code element into the specified code items set. /// </summary> /// <param name="codeItems">The code items set for accumulation.</param> /// <param name="codeElements">The CodeElements to walk.</param> private static void RetrieveCodeItemsFromElements(SetCodeItems codeItems, CodeElements codeElements) { if (Settings.Default.General_Multithread) { Parallel.ForEach(codeElements.OfType <CodeElement>(), child => RetrieveCodeItemsRecursively(codeItems, child)); } else { foreach (CodeElement child in codeElements) { RetrieveCodeItemsRecursively(codeItems, child); } } }
internal static IEnumerable <IEnumValueMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { long value = -1; foreach (var codeVariable in codeElements.OfType <CodeVariable2>()) { if (codeVariable.InitExpression == null) { value++; } else { string initExpression = codeVariable.InitExpression.ToString(); if (long.TryParse(initExpression, out value) == false) { // Handle init expressions from char constants e.g. 'A' = 65 if (initExpression.Length == 3 && initExpression.StartsWith("'") && initExpression.EndsWith("'")) { value = initExpression[1]; } else if (initExpression.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) { var convertedValue = _converter.ConvertFromString(initExpression); value = (long?)convertedValue ?? -1; } else { value = -1; } } } yield return(new CodeDomEnumValueMetadata(codeVariable, file, value)); } }
public Guid GetHash([NotNull] CodeElements attributes, [NotNull] string defaultName) { Assert.ArgumentNotNull(attributes, nameof(attributes)); Assert.ArgumentNotNull(defaultName, nameof(defaultName)); foreach (var attribute in attributes.OfType <CodeAttribute2>()) { if (attribute.Name == "SitecoreClass" || attribute.Name == "SitecoreClassAttribute") { var templateId = attribute.Arguments.OfType <CodeAttributeArgument>().FirstOrDefault(a => a.Name == "TemplateId"); if (templateId != null) { Guid guid; if (Guid.TryParse(templateId.Value, out guid)) { return(guid); } } } if (attribute.Name == "Guid" || attribute.Name == "GuidAttribute") { var templateId = attribute.Arguments.OfType <CodeAttributeArgument>().FirstOrDefault(); if (templateId != null) { Guid guid; if (Guid.TryParse(templateId.Value, out guid)) { return(guid); } } } } return(GuidExtensions.Hash(defaultName)); }
internal static IEnumerable<IDelegateMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeDelegate2>().Where(d => d.Access == vsCMAccess.vsCMAccessPublic).Select(d => FromCodeDelegate(d, file)); }
internal new static IEnumerable <IConstantMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeVariable2>().Where(v => v.IsConstant && v.Access == vsCMAccess.vsCMAccessPublic) .Select(v => new CodeDomConstantMetadata(v, file))); }
private static IEnumerable<IntellisenseProperty> GetProperties(CodeElements props, HashSet<string> traversedTypes, HashSet<string> references = null) { return from p in props.OfType<CodeProperty>() where !p.Attributes.Cast<CodeAttribute>().Any(a => a.Name == "IgnoreDataMember") where p.Getter != null && !p.Getter.IsShared && p.Getter.Access == vsCMAccess.vsCMAccessPublic select new IntellisenseProperty { Name = GetName(p), Type = GetType(p.Parent, p.Type, traversedTypes, references), Summary = GetSummary(p) }; }
internal static IEnumerable <IDelegateMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeDelegate2>().Where(d => d.Access == vsCMAccess.vsCMAccessPublic).Select(d => FromCodeDelegate(d, file))); }
internal static IEnumerable <IClassMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeClass2>().Where(c => c.Access == vsCMAccess.vsCMAccessPublic && c.FullName != "System.Object").Select(c => new CodeDomClassMetadata(c, file))); }
internal static IEnumerable <IPropertyMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeProperty2>().Where(p => p.Access == vsCMAccess.vsCMAccessPublic && p.IsShared == false).Select(p => new CodeDomPropertyMetadata(p, file))); }
internal static IEnumerable<IEnumMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeEnum>().Where(e => e.Access == vsCMAccess.vsCMAccessPublic).Select(e => new CodeDomEnumMetadata(e, file)); }
private void Traverse(CodeElements members) { foreach (var codeClass in members.OfType<CodeClass>()) WithCodeClass(codeClass); }
internal static IEnumerable<IEventMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeEvent>().Where(f => f.Access == vsCMAccess.vsCMAccessPublic && f.IsShared == false).Select(f => new CodeDomEventMetadata(f, file)); }
/// <summary> /// Retrieves code items from each specified code element into the specified code items set. /// </summary> /// <param name="codeItems">The code items set for accumulation.</param> /// <param name="codeElements">The CodeElements to walk.</param> private static void RetrieveCodeItemsFromElements(SetCodeItems codeItems, CodeElements codeElements) { if (Settings.Default.General_Multithread) { Parallel.ForEach(codeElements.OfType<CodeElement>(), child => RetrieveCodeItemsRecursively(codeItems, child)); } else { foreach (CodeElement child in codeElements) { RetrieveCodeItemsRecursively(codeItems, child); } } }
internal static IEnumerable<IMethodMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeFunction2>().Where(f => f.Access == vsCMAccess.vsCMAccessPublic && f.FunctionKind != vsCMFunction.vsCMFunctionConstructor && f.IsShared == false).Select(f => new CodeDomMethodMetadata(f, file)); }
internal static IEnumerable<IParameterMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeParameter2>().Select(p => new CodeDomParameterMetadata(p, file)); }
private void Traverse(CodeElements members) { foreach (var property in members.OfType<CodeProperty>()) WithProperty(property); }
internal static IEnumerable<IAttributeMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeAttribute2>().Select(a => new CodeDomAttributeMetadata(a, file)); }
internal static IEnumerable <IInterfaceMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeInterface2>().Where(i => i.Access == vsCMAccess.vsCMAccessPublic).Select(i => new CodeDomInterfaceMetadata(i, file))); }
public string Value => value; // Todo! internal static IEnumerable <IAttributeMetadata> FromCodeElements(CodeElements codeElements) { return(codeElements.OfType <CodeAttribute2>().Select(a => new CodeDomAttributeMetadata(a))); }
internal static IEnumerable<IPropertyMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeProperty2>().Where(p => p.Access == vsCMAccess.vsCMAccessPublic && p.IsShared == false).Select(p => new CodeDomPropertyMetadata(p, file)); }
internal static IEnumerable <IEventMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeEvent>().Where(f => f.Access == vsCMAccess.vsCMAccessPublic && f.IsShared == false).Select(f => new CodeDomEventMetadata(f, file))); }
internal static IEnumerable<IFieldMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeVariable2>().Where(v => v.Access == vsCMAccess.vsCMAccessPublic && v.IsConstant == false && v.IsShared == false).Select(v => new CodeDomFieldMetadata(v, file)); }
internal static IEnumerable<IClassMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeClass2>().Where(c => c.Access == vsCMAccess.vsCMAccessPublic && c.FullName != "System.Object").Select(c => new CodeDomClassMetadata(c, file)); }
internal static IEnumerable<IInterfaceMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return codeElements.OfType<CodeInterface2>().Where(i => i.Access == vsCMAccess.vsCMAccessPublic).Select(i => new CodeDomInterfaceMetadata(i, file)); }
internal static IEnumerable <IMethodMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeFunction2>().Where(f => f.Access == vsCMAccess.vsCMAccessPublic && f.FunctionKind != vsCMFunction.vsCMFunctionConstructor && f.IsShared == false).Select(f => new CodeDomMethodMetadata(f, file))); }
internal static IEnumerable <IParameterMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeParameter2>().Select(p => new CodeDomParameterMetadata(p, file))); }
internal static IEnumerable <IEnumMetadata> FromCodeElements(CodeElements codeElements, CodeDomFileMetadata file) { return(codeElements.OfType <CodeEnum>().Where(e => e.Access == vsCMAccess.vsCMAccessPublic).Select(e => new CodeDomEnumMetadata(e, file))); }