本文整理汇总了C#中IProperty.GetDeclaringTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IProperty.GetDeclaringTypeDefinition方法的具体用法?C# IProperty.GetDeclaringTypeDefinition怎么用?C# IProperty.GetDeclaringTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProperty
的用法示例。
在下文中一共展示了IProperty.GetDeclaringTypeDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _Visit
public override JsNode _Visit(IProperty pe)
{
if (Sk.IsNativeField(pe))
{
if (Sk.InlineFields(pe.GetDeclaringTypeDefinition()))
{
var fe = GenerateFakeField(pe);
var value = AstNodeConverter.Visit(GetCreateInitializer(fe));
return Js.JsonNameValue(pe.Name, (JsExpression)value);
}
throw new Exception();
}
else
{
var list2 = new JsNodeList { Nodes = new List<JsNode>() };
var node2 = ExportPropertyInfo(pe);
if (node2 != null)
list2.Nodes.Add(node2);
var list = GetAccessorsToExport(pe);
if (list.Count > 0)
{
foreach (var accessor in list)
{
var pair = (JsJsonNameValue)ExportMethod(accessor);
list2.Nodes.Add(pair);
}
}
//else if (pe.IsAutomaticProperty())
//{
// throw new NotImplementedException();
// //var def = CurrentType.GetDefinition(pe.IsStatic);
// var getter = Js.Code(String.Format("function(){{return this._{0};}}", pe.Name)); ;
// var setter = Js.Code(String.Format("function(value){{this._{0} = value;}}", pe.Name));
// list2.Nodes.Add(new JsJsonNameValue { Name = new JsJsonMember { Name = SkJs.GetEntityJsName(pe.Getter) }, Value = getter });
// list2.Nodes.Add(new JsJsonNameValue { Name = new JsJsonMember { Name = SkJs.GetEntityJsName(pe.Setter) }, Value = setter });
//}
return list2;
}
}
示例2: _Visit
public override JsNode _Visit(IProperty pe)
{
var list = GetAccessorsToExport(pe);
if (Sk.IsNativeProperty(pe))
{
var statements = new List<JsStatement>();
statements.AddRange(list.Select(ExportMethod).Cast<JsStatement>());
var json = new JsJsonObjectExpression();
foreach (var accessor in list)
{
if (accessor == pe.Getter)
json.Add("get", ExportTypePrefix(pe.Getter.GetDeclaringTypeDefinition(), pe.IsStatic).Member("get_" + pe.Name));
if (accessor == pe.Setter)
json.Add("set", ExportTypePrefix(pe.Setter.GetDeclaringTypeDefinition(), pe.IsStatic).Member("set_" + pe.Name));
}
if (Sk.IsNativePropertyEnumerable(pe))
json.Add("enumerable", Js.True());
var defineStatement = Js.Member("Object").Member("defineProperty").Invoke(
ExportTypePrefix(pe.GetDeclaringTypeDefinition(), pe.IsStatic),
Js.String(pe.Name),
json).Statement();
statements.Add(defineStatement);
return new JsUnit() { Statements = statements };
}
else
{
var list2 = list.Select(ExportMethod).Cast<JsStatement>().ToList();
return new JsUnit { Statements = list2 };
}
}