本文整理汇总了C#中BaseEntity.AdjustAvailability方法的典型用法代码示例。如果您正苦于以下问题:C# BaseEntity.AdjustAvailability方法的具体用法?C# BaseEntity.AdjustAvailability怎么用?C# BaseEntity.AdjustAvailability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseEntity
的用法示例。
在下文中一共展示了BaseEntity.AdjustAvailability方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses the specified entity.
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
EnumerationEntity enumerationEntity = (EnumerationEntity)entity;
if (enumerationEntity == null) {
throw new ArgumentException ("EnumerationEntity expected", "entity");
}
IParser parser = ParserFactory.CreateParser (SupportedLanguage.CSharp, reader);
parser.Parse ();
// Extract the special nodes (comment, etc)
List<ISpecial> specials = parser.Lexer.SpecialTracker.RetrieveSpecials ();
this.CodeDomSpecialParser = new CodeDomSpecialParser (specials);
// Parse the compilation unit
CompilationUnit cu = parser.CompilationUnit;
foreach (INode child1 in cu.Children) {
NamespaceDeclaration namespaceDeclaration = child1 as NamespaceDeclaration;
if (namespaceDeclaration == null) {
continue;
}
foreach (INode child2 in child1.Children) {
TypeDeclaration declaration = child2 as TypeDeclaration;
if (declaration == null) {
continue;
}
if (declaration.Type != ClassType.Enum) {
continue;
}
// Extract basic informations
enumerationEntity.BaseType = declaration.BaseTypes.Count > 0 ? declaration.BaseTypes [0].Type : "int";
// Extract attributes
Attribute attribute = FindAttribute (declaration, "Flags");
enumerationEntity.Flags = (attribute != null);
IEnumerable<Comment> comments = this.GetDocumentationCommentsBefore (declaration);
AppendComment (entity, comments);
// Append each values
foreach (INode child3 in declaration.Children) {
FieldDeclaration fieldDeclaration = child3 as FieldDeclaration;
if (fieldDeclaration == null) {
continue;
}
EnumerationValueEntity valueEntity = new EnumerationValueEntity ();
valueEntity.Name = fieldDeclaration.Fields [0].Name;
Expression expression = fieldDeclaration.Fields [0].Initializer;
if (expression != null) {
CodeDomExpressionPrinter printer = new CodeDomExpressionPrinter ();
expression.AcceptVisitor (printer, null);
valueEntity.Value = printer.ToString ();
}
comments = this.GetDocumentationCommentsBefore (fieldDeclaration);
AppendComment (valueEntity, comments);
enumerationEntity.Values.Add (valueEntity);
}
}
}
// Ensure that availability is set on entity.
entity.AdjustAvailability ();
}
示例2: Parse
/// <summary>
/// Parses the specified entity.
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
TypedEntity typedEntity = (TypedEntity) entity;
if (typedEntity == null)
{
throw new ArgumentException("FunctionEntity expected", "entity");
}
using (XmlTextReader xmlTextReader = new XmlTextReader(reader))
{
XElement root = XElement.Load(xmlTextReader);
// Get the spec box
XElement specElement = (from el in root.Descendants("div")
where (String) el.Attribute("class") == "spec_sheet_info_box"
select el).FirstOrDefault();
if (specElement != null)
{
// Inherits
XElement inheritElement = (from el in specElement.Descendants("td")
let prev = el.ElementsBeforeSelf("td").FirstOrDefault()
where prev != null && prev.Value.TrimAll() == "Derived from"
select el).FirstOrDefault();
if (inheritElement != null)
{
string hierarchy = inheritElement.TrimAll();
string[] parents = hierarchy.Split(new[] {':'}, StringSplitOptions.RemoveEmptyEntries);
String parent = parents[0].Trim();
if (parent.EndsWith("Ref")) {
parent = parent.Substring(0, parent.Length - "Ref".Length);
}
typedEntity.BaseType = parent;
}
}
// Constants
this.ExtractConstants(typedEntity, root);
// Notifications
this.ExtractNotifications(typedEntity, root);
// Functions
this.ExtractFunctions(typedEntity, root);
}
// Make sure availability is ok
entity.AdjustAvailability();
}
示例3: Parse
/// <summary>
/// Parses the specified entity.
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
ClassEntity classEntity = entity as ClassEntity;
if (classEntity == null) {
throw new ArgumentException ("ClassEntity expected", "entity");
}
IParser parser = ParserFactory.CreateParser (SupportedLanguage.CSharp, reader);
parser.Parse ();
// Extract the special nodes (comment, etc)
List<ISpecial> specials = parser.Lexer.SpecialTracker.RetrieveSpecials ();
this.CodeDomSpecialParser = new CodeDomSpecialParser (specials);
// Parse the compilation unit
CompilationUnit cu = parser.CompilationUnit;
foreach (INode child1 in cu.Children) {
NamespaceDeclaration namespaceDeclaration = child1 as NamespaceDeclaration;
if (namespaceDeclaration == null) {
continue;
}
foreach (INode child2 in child1.Children) {
TypeDeclaration declaration = child2 as TypeDeclaration;
if (declaration == null) {
continue;
}
if (declaration.Type != this.ClassType) {
continue;
}
// Extract super-class
if (declaration.BaseTypes.Count > 0) {
classEntity.BaseType = declaration.BaseTypes [0].Type;
}
// Extract comments
IEnumerable<Comment> comments = this.GetDocumentationCommentsBefore (declaration);
AppendComment (entity, comments);
// Append each values
foreach (INode child3 in declaration.Children) {
MethodDeclaration methodDeclaration = child3 as MethodDeclaration;
if (methodDeclaration != null) {
MethodEntity methodEntity = this.ExtractMethod (methodDeclaration);
classEntity.Methods.Add (methodEntity);
}
PropertyDeclaration propertyDeclaration = child3 as PropertyDeclaration;
if (propertyDeclaration != null) {
PropertyEntity propertyEntity = this.ExtractProperty (propertyDeclaration);
classEntity.Properties.Add (propertyEntity);
}
FieldDeclaration fieldDeclaration = child3 as FieldDeclaration;
if (fieldDeclaration != null) {
if ((fieldDeclaration.Modifier & Modifiers.Static) != Modifiers.Static) {
continue;
}
if (fieldDeclaration.TypeReference.Type == "Class") {
continue;
}
ConstantEntity constantEntity = this.ExtractConstant (fieldDeclaration);
classEntity.Constants.Add (constantEntity);
}
}
}
}
// Ensure that availability is set on entity.
entity.AdjustAvailability ();
}
示例4: Parse
//.........这里部分代码省略.........
let prev = el.ElementsBeforeSelf ("td").FirstOrDefault ()
where prev != null && prev.Value.TrimAll () == "Availability"
select el).FirstOrDefault ();
if (availabilityElement != null) {
entity.MinAvailability = CommentHelper.ExtractAvailability (availabilityElement.TrimAll ());
}
// Inherits
XElement inheritElement = (from el in specElement.Descendants ("td")
let prev = el.ElementsBeforeSelf ("td").FirstOrDefault ()
where prev != null && prev.Value.TrimAll () == "Inherits from"
select el).FirstOrDefault ();
if (inheritElement != null) {
string hierarchy = inheritElement.TrimAll ();
string[] parents = hierarchy.Split (new[] {':'}, StringSplitOptions.RemoveEmptyEntries);
classEntity.BaseType = parents [0].Trim ();
}
// Conforms To
XElement conformsElements = (from el in specElement.Descendants ("td")
let prev = el.ElementsBeforeSelf ("td").FirstOrDefault ()
where prev != null && prev.Value.TrimAll () == "Conforms to"
select el).FirstOrDefault ();
if (conformsElements != null) {
List<String> protocols = new List<string> ();
foreach (XElement conformsElement in conformsElements.Descendants("span")) {
String protocol = conformsElement.TrimAll ();
if (protocol.Contains ("(NSObject)") || protocol.Contains ("(NSProxy)")) {
continue;
}
int pos = protocol.IndexOf ('(');
if (pos != -1) {
protocol = protocol.Substring (0, pos).Trim ();
}
protocols.Add (protocol);
}
classEntity.ConformsTo = String.Join (",", protocols.Distinct ().ToArray ());
}
}
// Class Methods
this.ExtractClassMethods (classEntity, root);
// Instance Methods
this.ExtractInstanceMethods (classEntity, root);
// Delegate Methods
this.ExtractDelegateMethods (classEntity, root);
// Properties
this.ExtractProperties (classEntity, root);
// Constants
this.ExtractConstants (classEntity, root);
// Notifications
this.ExtractNotifications (classEntity, root);
// Functions
this.ExtractFunctions (classEntity, root);
}
// Extract getter and search for setter
List<String> notGetterMethods = this.Settings ["NotGetterMethods"].Split (new []{','}, StringSplitOptions.RemoveEmptyEntries).ToList ();
List<MethodEntity> methodModels = new List<MethodEntity> (classEntity.Methods);
foreach (MethodEntity methodModel in methodModels) {
if (notGetterMethods.Contains (methodModel.Name) || !methodModel.IsGetter) {
continue;
}
classEntity.Methods.Remove (methodModel);
MethodEntity getter = methodModel;
// TODO: Refactor to use the IsSetterFor with an optional parameter to strip the prefix
MethodEntity setter = classEntity.Methods.Find (m => String.Equals ("Set" + getter.Name, m.Name) &&
String.Equals (m.ReturnType, "void") &&
m.Parameters.Count == 1 &&
m.Static == getter.Static);
if (setter == null) {
setter = classEntity.Methods.Find (m => m.IsSetterFor (getter));
}
if (setter != null) {
classEntity.Methods.Remove (setter);
}
PropertyEntity property = new PropertyEntity ();
property.Name = getter.Name;
property.Type = getter.ReturnType;
property.Summary = getter.Summary;
property.MinAvailability = getter.MinAvailability;
property.Static = getter.Static;
property.Getter = getter;
property.Setter = setter;
classEntity.Properties.Add (property);
}
// Ensure that availability is set on entity.
entity.AdjustAvailability ();
}
示例5: Parse
/// <summary>
/// Parses the specified entity.
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
ClassEntity classEntity = (ClassEntity)entity;
if (classEntity == null) {
throw new ArgumentException ("ClassEntity expected", "entity");
}
using (XmlTextReader xmlTextReader = new XmlTextReader(reader)) {
XElement root = XElement.Load (xmlTextReader);
// Extract inheritance
IEnumerable<String> conformsElements = (from el in root.Descendants ("basecompoundref")
select el.TrimAll ());
List<String> protocols = new List<string> ();
foreach (string conformsElement in conformsElements) {
if (conformsElement.StartsWith ("<")) {
String protocol = conformsElement.Trim ('<', '>');
if (protocol.EndsWith ("-p")) {
protocol = protocol.Replace ("-p", String.Empty);
}
protocols.Add (protocol);
} else {
classEntity.BaseType = conformsElement.Trim ();
}
}
if (!(classEntity is ProtocolEntity) && String.IsNullOrEmpty (classEntity.BaseType)) {
classEntity.BaseType = "NSObject";
}
classEntity.ConformsTo = String.Join (",", protocols.Distinct ().ToArray ());
// Functions
this.ExtractFunctions (classEntity, root);
// Methods
this.ExtractMethods (classEntity, root);
// Properties
this.ExtractProperties (classEntity, root);
// Constants
this.ExtractConstants (classEntity, root);
// Enumerations
this.ExtractEnumerations (classEntity, root);
}
// Extract getter and search for setter
List<String> notGetterMethods = this.Settings ["NotGetterMethods"].Split (new []{','}, StringSplitOptions.RemoveEmptyEntries).ToList ();
List<MethodEntity> methodModels = new List<MethodEntity> (classEntity.Methods);
foreach (MethodEntity methodModel in methodModels) {
if (notGetterMethods.Contains (methodModel.Name) || !methodModel.IsGetter) {
continue;
}
classEntity.Methods.Remove (methodModel);
MethodEntity getter = methodModel;
MethodEntity setter = classEntity.Methods.Find (m => String.Equals ("Set" + getter.Name, m.Name) && String.Equals (m.ReturnType, "void"));
if (setter == null) {
setter = classEntity.Methods.Find (m => m.IsSetterFor (getter));
}
if (setter != null) {
classEntity.Methods.Remove (setter);
}
this.Logger.WriteLine ("Converting " + getter.Name + " to property");
PropertyEntity property = new PropertyEntity ();
property.Name = getter.Name;
property.Type = getter.ReturnType;
property.Summary = getter.Summary;
property.MinAvailability = getter.MinAvailability;
property.Static = getter.Static;
property.Getter = getter;
property.Setter = setter;
classEntity.Properties.Add (property);
}
// Ensure that availability is set on entity.
entity.AdjustAvailability ();
}
示例6: Parse
/// <summary>
/// Parses the specified entity.
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
TypedEntity typedEntity = (TypedEntity) entity;
if (typedEntity == null)
{
throw new ArgumentException("FunctionEntity expected", "entity");
}
using (XmlTextReader xmlTextReader = new XmlTextReader(reader))
{
XElement root = XElement.Load(xmlTextReader);
// Functions
this.ExtractFunctions(typedEntity, root);
// Constants
this.ExtractConstants(typedEntity, root);
// Enumerations
this.ExtractEnumerations(typedEntity, root);
}
// Make sure availability is ok
entity.AdjustAvailability();
}
示例7: Parse
//.........这里部分代码省略.........
/// </summary>
/// <param name = "entity">The entity.</param>
/// <param name = "reader">The reader.</param>
public override void Parse(BaseEntity entity, TextReader reader)
{
ClassEntity classEntity = (ClassEntity)entity;
if (classEntity == null) {
throw new ArgumentException ("ClassEntity expected", "entity");
}
using (XmlTextReader xmlTextReader = new XmlTextReader(reader)) {
XElement root = XElement.Load (xmlTextReader);
// Get the spec box
XElement specElement = (from el in root.Descendants ("div")
where (String)el.Attribute ("class") == "spec_sheet_info_box"
select el).FirstOrDefault ();
if (specElement != null) {
// Inherits
XElement inheritElement = (from el in specElement.Descendants ("td")
let prev = el.ElementsBeforeSelf ("td").FirstOrDefault ()
where prev != null &&
(prev.Value.TrimAll () == "Inherits from:" ||
prev.Value.TrimAll () == "Inherits from:")
select el).FirstOrDefault ();
if (inheritElement != null) {
string hierarchy = inheritElement.TrimAll ();
string[] parents = hierarchy.Split (new[] {':'}, StringSplitOptions.RemoveEmptyEntries);
classEntity.BaseType = parents [0].Trim ();
}
// Conforms To
XElement conformsElements = (from el in specElement.Descendants ("td")
let prev = el.ElementsBeforeSelf ("td").FirstOrDefault ()
where prev != null &&
(prev.Value.TrimAll () == "Conforms to:" ||
prev.Value.TrimAll () == "Conforms to:")
select el).FirstOrDefault ();
if (conformsElements != null) {
List<String> protocols = new List<string> ();
foreach (String protocol in conformsElements.TrimAll().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)) {
if (protocol.Contains ("NSObject") || protocol.Contains ("NSProxy")) {
continue;
}
protocols.Add (protocol.Trim ());
}
classEntity.ConformsTo = String.Join (",", protocols.Distinct ().ToArray ());
}
}
// Functions
this.ExtractFunctions (classEntity, root);
// Methods
this.ExtractMethods (classEntity, root);
// Properties
this.ExtractProperties (classEntity, root);
// Constants
this.ExtractConstants (classEntity, root);
// Enumerations
this.ExtractEnumerations (classEntity, root);
}
// Extract getter and search for setter
List<String> notGetterMethods = this.Settings ["NotGetterMethods"].Split (new []{','}, StringSplitOptions.RemoveEmptyEntries).ToList ();
List<MethodEntity> methodModels = new List<MethodEntity> (classEntity.Methods);
foreach (MethodEntity methodModel in methodModels) {
if (notGetterMethods.Contains (methodModel.Name) || !methodModel.IsGetter) {
continue;
}
classEntity.Methods.Remove (methodModel);
MethodEntity getter = methodModel;
MethodEntity setter = classEntity.Methods.Find (m => String.Equals ("Set" + getter.Name, m.Name) && String.Equals (m.ReturnType, "void"));
if (setter == null) {
setter = classEntity.Methods.Find (m => m.IsSetterFor (getter));
}
if (setter != null) {
classEntity.Methods.Remove (setter);
}
PropertyEntity property = new PropertyEntity ();
property.Name = getter.Name;
property.Type = getter.ReturnType;
property.Summary = getter.Summary;
property.MinAvailability = getter.MinAvailability;
property.Static = getter.Static;
property.Getter = getter;
property.Setter = setter;
classEntity.Properties.Add (property);
}
// Ensure that availability is set on entity.
entity.AdjustAvailability ();
}