public static MvcContext GetOne( IMember objOwner, Type appType, int appId ) { MvcContext ctx = getContextInit(); // route Route route = new wojilu.Web.Mvc.Routes.Route(); route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项 ctx.utils.setRoute( route ); // viewer: 某些地方需要判断viewer ViewerContext viewer = new ViewerContext(); viewer.obj = new User(); ctx.utils.setViewerContext( viewer ); // owner OwnerContext owner = new OwnerContext(); owner.Id = objOwner.Id; owner.obj = objOwner; ctx.utils.setOwnerContext( owner ); // app IAppContext app = new AppContext(); app.Id = appId; app.obj = ndb.findById( appType, appId ); app.setAppType( appType ); // 如果要使用alang语言包,必须设置此项 ctx.utils.setAppContext( app ); return ctx; }
public static MvcContext GetOne( IMember objOwner ) { MvcContext ctx = getContextInit(); // route Route route = new wojilu.Web.Mvc.Routes.Route(); ctx.utils.setRoute( route ); // viewer: 某些地方需要判断viewer ViewerContext viewer = new ViewerContext(); viewer.obj = new User(); ctx.utils.setViewerContext( viewer ); // owner OwnerContext owner = new OwnerContext(); owner.Id = objOwner.Id; owner.obj = objOwner; ctx.utils.setOwnerContext( owner ); // app IAppContext app = new AppContext(); app.obj = null; ctx.utils.setAppContext( app ); return ctx; }
MemberResolveResult CreateResolveResult(IMember member) { if (member != null) { return new MemberResolveResult(null, null, member); } return null; }
public MembershipEvent(ICluster cluster, IMember member, int eventType, ICollection<IMember> members) : base(cluster) { this.member = member; this.eventType = eventType; this.members = members; }
public PaymentEntity(ISale sale, IMember member, int paymentId = 0) { this.PaymentId = paymentId; this.Sale = sale; this.Member = member; this.Date = DateTime.Now; }
void InitMemberNode(IMember member) { this.member = member; this.ContextmenuAddinTreePath = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"; declaringType = member.DeclaringType; modifiers = member.Modifiers; }
public static PostHandlerOutput[] PCNarration( IDocumentSession documentSession, IMember sender, IRoom room, string source) { documentSession.Ensure("documentSession"); sender.Ensure("sender"); room.Ensure("room"); source.Ensure("source"); source = source.Trim(); if (source.StartsWith("/", StringComparison.OrdinalIgnoreCase)) return null; if (!sender.IsRoomPlayer(room)) return null; var player = room.Players.SingleOrDefault(x => x.MemberId == sender.Id); if (player == null) return null; var text = string.Concat( player.CharacterName, ": ", source); documentSession.CreatePost(room.Id, sender.Id, null, source, "pc-narration", text); return PostHandlerOutput.Empty; }
public static String ToAppAdmin( IMember user, IMemberApp app ) { String ownerPath = LinkHelper.GetMemberPathPrefix( user ); String appName = strUtil.TrimEnd( app.AppInfo.TypeName, "App" ); String controller = appName + MvcConfig.Instance.UrlSeparator + "Admin" + MvcConfig.Instance.UrlSeparator + appName; return LinkHelper.AppendApp( app.AppOid, controller, "Index", -1, ownerPath ); }
/// <summary> /// Adds another member to this set. /// </summary> /// <param name="memberToAdd">The member to add</param> /// <param name="membershipDegree">Membership degree of the member. To create a crisp discrete set, this parameter would have to be always 1. Note: Do not add members with zero membership. Just avoid calling this method for the specific member at all.</param> public void AddMember(IMember memberToAdd, double membershipDegree) { if(memberToAdd == null) throw new NullReferenceException(String.Format("Parameter memberToAdd not specified in method AddMember in fuzzy set \"{0}\".", this.Caption)); if (membershipDegree < 0 || membershipDegree > 1) throw new MembershipOutOfRangeException( String.Format("Membership degree {0} for element \"{1}\" in fuzzy set \"{2}\" does not belong to the range of <0,1>.", membershipDegree, memberToAdd.Caption, this.Caption)); _members.Add(memberToAdd, membershipDegree); //Finds position of the specified member in the dictionary collection //int position = _members.Keys.ToList<IMember>().FindLastIndex( delegate(IMember m) { return (m == memberToAdd); } ); //...and also into the internal implemenation _intervals.AddInterval(new Interval(_intervals, memberToAdd.ToDecimal, membershipDegree)); object o = new object(); lock (o) { if (memberToAdd.ToDecimal >= ((IDiscreteDimension)_dimension).MemberCount) ((IDiscreteDimension)_dimension).MemberCount = (uint) memberToAdd.ToDecimal + 1; } if (_dimension.SignificantValues.Length < MaxMembersToDisplay) { List<decimal> significantValues = _dimension.SignificantValues.ToList<decimal>(); significantValues.Add(memberToAdd.ToDecimal); _dimension.SignificantValues = significantValues.ToArray(); } }
public static MvcContext GetOne( IMember objOwner, int appId ) { IWebContext webContext = MockWebContext.New( 1, "http://localhost/", new System.IO.StringWriter() ); MvcContext ctx = new MvcContext( webContext ); // route Route route = new wojilu.Web.Mvc.Routes.Route(); route.setAppId( appId ); // 为了让生成的link链接中有appId,必须设置此项 ctx.utils.setRoute( route ); // viewer: 某些地方需要判断viewer ViewerContext viewer = new ViewerContext(); viewer.obj = new User(); ctx.utils.setViewerContext( viewer ); // owner OwnerContext owner = new OwnerContext(); owner.Id = objOwner.Id; owner.obj = objOwner; ctx.utils.setOwnerContext( owner ); // app IAppContext app = new AppContext(); app.Id = appId; app.obj = BlogApp.findById( appId ); app.setAppType( typeof( BlogApp ) ); // 如果要使用alang语言包,必须设置此项 ctx.utils.setAppContext( app ); return ctx; }
public static bool IsSpam(IMember member, string body) { // Members with over 50 karma are trusted automatically if (member.Karma() >= 50) return false; var roles = Roles.GetRolesForUser(member.Username); var isSpam = roles.Contains("potentialspam") || roles.Contains("newaccount") || NewAndPostsALot(member) || TextContainsSpam(body) || IsSuspiciousBehavior(body); if (isSpam) { //Deduct karma var reputationTotal = member.GetValue<int>("reputationTotal"); member.SetValue("reputationTotal", reputationTotal >= 0 ? reputationTotal - 1 : 0); var reputationCurrent = member.GetValue<int>("reputationCurrent"); member.SetValue("reputationCurrent", reputationCurrent >= 0 ? reputationCurrent - 1 : 0); var memberService = ApplicationContext.Current.Services.MemberService; memberService.Save(member); memberService.AssignRole(member.Id, "potentialspam"); } return isSpam; }
private SimpleTypeResolveContext(ICompilation compilation, IAssembly currentAssembly, ITypeDefinition currentTypeDefinition, IMember currentMember) { this.compilation = compilation; this.currentAssembly = currentAssembly; this.currentTypeDefinition = currentTypeDefinition; this.currentMember = currentMember; }
private static string getLayoutCache( IMember owner ) { MvcContext ctx = MockContext.GetOne( owner ); String content = ControllerRunner.Run( ctx, new wojilu.Web.Controller.LayoutController().Layout ); return content; }
public virtual string FormatTypeMember(IMember member) { var method = member as IMethod; if (method != null) return FormatMethod(method); return FormatType(member.DeclaringType) + "." + member.Name; }
ITestFramework GetTestFramework(IMember member) { if (member != null) { return GetTestFramework(member.DeclaringType); } return null; }
public ReflectionParameter(ParameterInfo parameterInfo, IMember member) : base(parameterInfo.Name) { Type type = parameterInfo.ParameterType; this.ReturnType = ReflectionReturnType.Create(member, type, false); if (type.IsByRef && parameterInfo.IsOut) { this.Modifiers = ParameterModifiers.Out; } else if (type.IsByRef) { this.Modifiers = ParameterModifiers.Ref; } if (parameterInfo.IsOptional) { this.Modifiers |= ParameterModifiers.Optional; } if (type.IsArray && type != typeof(Array)) { foreach (CustomAttributeData data in CustomAttributeData.GetCustomAttributes(parameterInfo)) { if (data.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) { this.Modifiers |= ParameterModifiers.Params; break; } } } }
public static PostHandlerOutput[] RollCommand( IDocumentSession documentSession, IMember sender, IRoom room, string source) { documentSession.Ensure("documentSession"); sender.Ensure("sender"); room.Ensure("room"); source.Ensure("source"); var match = rollCommandRegex.Match(source); if (!match.Success) return null; var number = int.Parse(match.Groups[1].Value); var sides = int.Parse(match.Groups[2].Value); var diceRolled = string.Join( ", ", fn.RollDice(number, sides).ToArray()); var text = string.Format( CultureInfo.CurrentUICulture, "{0} rolled {1}d{2} with the result: {3}.", sender.Alias, number, sides, diceRolled); documentSession.CreatePost(room.Id, sender.Id, null, source, "roll-result", text); return PostHandlerOutput.Empty; }
private static String getLayoutCache( int appId, IMember owner ) { MvcContext ctx = MockContext.GetOne( owner, typeof( ContentApp ), appId ); String content = ControllerRunner.Run( ctx, new wojilu.Web.Controller.Content.Section.LayoutController().Layout ); return content; }
/// <summary> /// Gets all base members that have the same signature. /// </summary> /// <returns> /// List of base members with the same signature. The member from the derived-most base class is returned first. /// </returns> public static IEnumerable<IMember> GetBaseMembers(IMember member, bool includeImplementedInterfaces) { if (member == null) throw new ArgumentNullException("member"); if (member.IsExplicitInterfaceImplementation && member.ImplementedInterfaceMembers.Count == 1) { // C#-style explicit interface implementation member = member.ImplementedInterfaceMembers[0]; yield return member; } SpecializedMember specializedMember = member as SpecializedMember; member = member.MemberDefinition; IEnumerable<IType> allBaseTypes; if (includeImplementedInterfaces) { allBaseTypes = member.DeclaringTypeDefinition.GetAllBaseTypes(); } else { allBaseTypes = member.DeclaringTypeDefinition.GetNonInterfaceBaseTypes(); } foreach (IType baseType in allBaseTypes.Reverse()) { if (baseType == member.DeclaringTypeDefinition) continue; foreach (IMember baseMember in baseType.GetMembers(m => m.Name == member.Name, GetMemberOptions.IgnoreInheritedMembers)) { if (SignatureComparer.Ordinal.Equals(member, baseMember)) { if (specializedMember != null) yield return SpecializedMember.Create(baseMember, specializedMember.Substitution); else yield return baseMember; } } } }
public PaymentEntity(ITeam team, IMember member, int paymentId = 0) { this.PaymentId = paymentId; this.Team = team; this.Member = member; this.Date = DateTime.Now; }
public MemberResolveResult(ResolveResult targetResult, IMember member, IType returnType) : base(returnType) { if (member == null) throw new ArgumentNullException("member"); this.targetResult = targetResult; this.member = member; }
static IClass GetClass(IMember member, Object owner) { if (member != null) { return member.DeclaringType; } return TestableCondition.GetClass(owner); }
MemberResolveResult CreateMemberResolveResult(IMember member) { if (member == null) return null; else return new MemberResolveResult(resolver.CallingClass, resolver.CallingMember, member); }
public static String ToAppAdmin( IMember user, IMemberApp app ) { String ownerPath = Link.GetMemberPathPrefix( user ); String appName = strUtil.TrimEnd( app.AppInfo.TypeName, "App" ); String controller = appName + "/Admin/" + appName; return Link.AppendApp( app.AppOid, controller, "Index", -1, ownerPath ); }
public bool IsTestMethod(IMember member) { if (member != null) { return member.Name.StartsWith("test"); } return false; }
public PaymentEntity(IEvent thisEvent, IMember member, int paymentId = 0) { this.PaymentId = paymentId; this.Event = thisEvent; this.Member = member; this.Date = DateTime.Now; }
public MemberFigure(Gdk.Pixbuf icon, IMember memberInfo, bool hidden) : base() { this.icon = new ImageFigure (icon); if (memberInfo.ReturnType != null) retval = new TextFigure (memberInfo.ReturnType.Name); else retval = new TextFigure (String.Empty); name = new TextFigure (memberInfo.Name); MemberInfo = memberInfo; Visible = !hidden; name.Padding = 1.0; name.FontSize = 10; retval.Padding = 0; retval.FontSize = 10; retval.FontColor = new Cairo.Color(0, 0, 1.0); AllowFormatting = true; Alignment = HStackAlignment.Bottom; SetAttribute (FigureAttribute.Selectable, true); Add (this.icon); Add (retval); Add (name); }
private static string getHomeCache( int appId, IMember owner ) { MvcContext ctx = MockContext.GetOne( owner, appId ); String content = ControllerRunner.Run( new wojilu.Web.Controller.Content.ContentController().Index, ctx ); return content; }
private static string getIndexCache( IMember owner, int appId, int boardId, int pageId ) { MvcContext ctx = MockContext.GetOne( owner, typeof( ForumApp ), appId ); ctx.route.setPage( pageId ); String content = ControllerRunner.Run( ctx, new wojilu.Web.Controller.Forum.BoardController().Show, boardId ); return content; }
static bool IsAccessible(IMember sourceMember, IMember targetMember) { if (sourceMember.IsStatic != targetMember.IsStatic) return false; var sourceType = sourceMember.DeclaringType; var targetType = targetMember.DeclaringType; switch (targetMember.Accessibility) { case Accessibility.None: return false; case Accessibility.Private: // check for members of outer classes (private members of outer classes can be accessed) var targetTypeDefinition = targetType.GetDefinition(); for (var t = sourceType.GetDefinition(); t != null; t = t.DeclaringTypeDefinition) { if (t.Equals(targetTypeDefinition)) return true; } return false; case Accessibility.Public: return true; case Accessibility.Protected: return IsProtectedAccessible(sourceType, targetType); case Accessibility.Internal: return IsInternalAccessible(sourceMember.ParentAssembly, targetMember.ParentAssembly); case Accessibility.ProtectedOrInternal: return IsInternalAccessible(sourceMember.ParentAssembly, targetMember.ParentAssembly) || IsProtectedAccessible(sourceType, targetType); case Accessibility.ProtectedAndInternal: return IsInternalAccessible(sourceMember.ParentAssembly, targetMember.ParentAssembly) && IsProtectedAccessible(sourceType, targetType); default: throw new Exception("Invalid value for Accessibility"); } }
public IStory CreateStory(string title, string description, Priority priority, Size size, StoryStatus status, IMember assignee) { return(new Story(title, description, priority, size, status, assignee)); }
public List <IMenu> GetMenus(IMember owner) { GroupMenuService menuService = new GroupMenuService(); return(menuService.GetList(owner)); }
bool IMember.Equals(IMember obj, TypeVisitor typeNormalization) { return(Equals(obj)); }
public IMember GetInterfaceImplementation(IMember interfaceMember) { return(GetInterfaceImplementation(new[] { interfaceMember })[0]); }
public AmbiguousMemberResolveResult(ResolveResult targetResult, IMember member) : base(targetResult, member) { }
public void Create() { int appInfoId = cvt.ToInt(ctx.Post("appInfoId")); AppInstaller info = getAppInfo(appInfoId); if (info.IsClose(ctx.owner.obj.GetType())) { echo("app closed"); return; } if (!checkInstall(info)) { return; } String name = ctx.Post("Name"); //AccessStatus accs = AccessStatusUtil.GetPostValue( ctx.PostInt( "AccessStatus" ) ); AccessStatus accs = AccessStatus.Public; Type appType = ObjectContext.Instance.TypeList[info.TypeFullName]; if (rft.IsInterface(appType, typeof(IAppInstaller))) { IAppInstaller customInstaller = ObjectContext.CreateObject(appType) as IAppInstaller; IMemberApp capp = customInstaller.Install(ctx, ctx.owner.obj, name, accs); intiAppPermission(capp); echoToParentPart(lang("opok"), to(Index), 1); return; } IMember owner = ctx.owner.obj; User creator = (User)ctx.viewer.obj; // 1、添加一条 IMemberApp IMemberApp app = userAppService.Add(creator, owner, name, info.Id, accs); if (app != null) { // 2、添加菜单 String appUrl = UrlConverter.clearUrl(app, ctx); menuService.AddMenuByApp(app, name, "", appUrl); // 3、初始化权限 intiAppPermission(app); log(SiteLogString.InsertApp(), app); echoToParentPart(lang("opok"), to(Index), 1); } else { errors.Add(lang("exop")); run(NewApp, info.Id); } }
public static void SetValue(this ITypeAccessor typeAccessor, object obj, IMember member, object value) { typeAccessor.SetValue(obj, member.Name, value); }
/// <summary> /// Returns the value for the member. /// </summary> /// <param name="typeAccessor"></param> /// <param name="obj"></param> /// <param name="member"></param> /// <returns></returns> public static object GetValue(this ITypeAccessor typeAccessor, object obj, IMember member) { return(typeAccessor.GetValue(obj, member.Name)); }
public ResolveResult(IClass callingClass, IMember callingMember, IReturnType resolvedType) { _callingClass = callingClass; _callingMember = callingMember; _resolvedType = resolvedType; }
bool IsAppropriateCallTarget(ExpectedTargetDetails expectedTargetDetails, IMember expectedTarget, IMember actualTarget) { if (expectedTarget.Equals(actualTarget, NormalizeTypeVisitor.TypeErasure)) { return(true); } if (expectedTargetDetails.CallOpCode == OpCode.CallVirt && actualTarget.IsOverride) { if (expectedTargetDetails.NeedsBoxingConversion && actualTarget.DeclaringType.IsReferenceType != true) { return(false); } foreach (var possibleTarget in InheritanceHelper.GetBaseMembers(actualTarget, false)) { if (expectedTarget.Equals(possibleTarget, NormalizeTypeVisitor.TypeErasure)) { return(true); } if (!possibleTarget.IsOverride) { break; } } } return(false); }
private static void InitMember(JsDocComment comment, IMember member, IEmitter emitter, object value) { if (member != null) { var method = member as IMethod; if (method != null) { comment.This = XmlToJsDoc.ToJavascriptName(member.DeclaringType, emitter); if (method.IsConstructor) { comment.Constructs = comment.This; } if (method.TypeParameters != null && method.TypeParameters.Count > 0) { foreach (var param in method.TypeParameters) { var jsParam = new JsDocParam(); jsParam.Name = param.Name; jsParam.Type = "Function"; comment.Parameters.Add(jsParam); } } } comment.Override = member.IsOverride; if (member is IParameterizedMember) { var parameters = ((IParameterizedMember)member).Parameters; if (parameters != null && parameters.Count > 0) { foreach (var param in parameters) { var jsParam = new JsDocParam(); jsParam.Name = param.Name; jsParam.Type = XmlToJsDoc.ToJavascriptName(param.Type, emitter); comment.Parameters.Add(jsParam); } } } var variable = member as IVariable; if (variable != null) { comment.MemberType = XmlToJsDoc.ToJavascriptName(variable.Type, emitter); } else { comment.Returns.Add(new JsDocParam { Type = XmlToJsDoc.ToJavascriptName(member.ReturnType, emitter) }); } var field = member as DefaultResolvedField; if (field != null) { comment.ReadOnly = field.IsReadOnly; comment.Const = field.IsConst; comment.Default = value ?? field.ConstantValue; } var ev = member as IEvent; if (ev != null) { comment.Event = XmlToJsDoc.ToJavascriptName(member.DeclaringType, emitter) + "#" + member.Name; } comment.MemberOf = XmlToJsDoc.ToJavascriptName(member.DeclaringType, emitter); comment.IsPublic = member.IsPublic; comment.IsPrivate = member.IsPrivate; comment.IsProtected = member.IsProtected; var entity = member as ICSharpCode.NRefactory.TypeSystem.Implementation.AbstractResolvedEntity; if (entity != null) { comment.IsAbstract = entity.IsAbstract; comment.IsStatic = entity.IsStatic; } } }
public IBug CreateBug(string title, string description, List <string> stepsToReproduce, Priority priority, Severity severity, BugStatus status, IMember assignee) { return(new Bug(title, description, stepsToReproduce, priority, severity, status, assignee)); }
public void AddMember(IMember member) { this.Members.Add(member); }
bool IsUnambiguousAccess(ExpectedTargetDetails expectedTargetDetails, ResolveResult target, IMethod method, out IMember foundMember) { foundMember = null; MemberResolveResult result; if (target == null) { result = resolver.ResolveSimpleName(method.AccessorOwner.Name, EmptyList <IType> .Instance, isInvocationTarget: false) as MemberResolveResult; } else { var lookup = new MemberLookup(resolver.CurrentTypeDefinition, resolver.CurrentTypeDefinition.ParentAssembly); if (method.AccessorOwner.SymbolKind == SymbolKind.Indexer) { // TODO: use OR here, etc. result = null; foreach (var methodList in lookup.LookupIndexers(target)) { foreach (var indexer in methodList) { if (IsAppropriateCallTarget(expectedTargetDetails, method.AccessorOwner, indexer)) { foundMember = indexer; return(true); } } } } else { result = lookup.Lookup(target, method.AccessorOwner.Name, EmptyList <IType> .Instance, isInvocation: false) as MemberResolveResult; } } foundMember = result?.Member; return(!(result == null || result.IsError || !IsAppropriateCallTarget(expectedTargetDetails, method.AccessorOwner, result.Member))); }
public static T CombineAs <T>(IMember x, IMember y) => As <T>(Combine(x, y));
private IList <MemberJobAdView> GetSuggestedJobs(IMember member, JobAdSearchResults results) { return(results.TotalMatches > 0 ? _memberJobAdViewsQuery.GetMemberJobAdViews(member, results.JobAdIds) : new List <MemberJobAdView>()); }
public Mono.Cecil.MemberReference GetCecil(IMember member) { return(context.GetCecil(member)); }
public BehaviorImportedTestMember(IClass testClass, IMember behaviorMember) : base(testClass, behaviorMember, behaviorMember.Name) { }
public AccountController(IMember repo) { memberRepo = repo; }
public Task(string title, string description, PriorityType priorityType, IMember assignee) : base(title, description) { this.PriorityType = priorityType; this.Assignee = assignee; }
private static JObject GetCommonMemberInfoProperties(IMember m, IEmitter emitter, bool includeDeclaringType, bool isGenericSpecialization, SyntaxTree tree) { var result = new JObject(); var attr = MetadataUtils.GetScriptableAttributes(m.Attributes, emitter, tree).ToList(); if (attr.Count > 0) { JArray attrArr = new JArray(); foreach (var a in attr) { attrArr.Add(MetadataUtils.ConstructAttribute(a, m.DeclaringTypeDefinition, emitter)); } result.Add("at", attrArr); } if (includeDeclaringType) { result.Add("td", new JRaw(MetadataUtils.GetTypeName(m.DeclaringType, emitter, isGenericSpecialization))); } if (m.IsOverride) { result.Add("ov", true); } if (m.IsVirtual) { result.Add("v", true); } if (m.IsAbstract) { result.Add("ab", true); } if (m.Accessibility != Accessibility.None) { if (m.Attributes.Any(a => a.AttributeType.FullName == "Bridge.PrivateProtectedAttribute")) { result.Add("a", (int)Accessibility.ProtectedAndInternal); } else { result.Add("a", (int)m.Accessibility); } } if (m.IsSealed) { result.Add("sl", true); } if (m.IsSynthetic) { result.Add("isSynthetic", true); } result.Add("n", m.Name); return(result); }
public AccountController() { memberRepo = new MemberRepository(); }
private static bool IsMemberReflectable(IMember member, MemberAccessibility[] memberReflectability) { if (member.IsExplicitInterfaceImplementation) { return(false); } foreach (var memberAccessibility in memberReflectability) { if (memberAccessibility == MemberAccessibility.All) { return(true); } if (memberAccessibility == MemberAccessibility.None) { return(false); } var accesibiliy = new List <string>(); if (memberAccessibility.HasFlag(MemberAccessibility.Public)) { accesibiliy.Add("Public"); } if (memberAccessibility.HasFlag(MemberAccessibility.Private)) { accesibiliy.Add("Private"); } if (memberAccessibility.HasFlag(MemberAccessibility.Internal)) { accesibiliy.Add("Internal"); } if (memberAccessibility.HasFlag(MemberAccessibility.Protected)) { accesibiliy.Add("Protected"); } if (accesibiliy.Count > 0) { if (member.Accessibility == Accessibility.ProtectedOrInternal) { if (!(accesibiliy.Contains("Protected") || accesibiliy.Contains("Internal"))) { continue; } } else if (!accesibiliy.Contains(member.Accessibility.ToString())) { continue; } } if (memberAccessibility.HasFlag(MemberAccessibility.Instance) && member.IsStatic) { continue; } if (memberAccessibility.HasFlag(MemberAccessibility.Static) && !member.IsStatic) { continue; } var kind = new List <string>(); if (memberAccessibility.HasFlag(MemberAccessibility.Constructor)) { kind.Add("Constructor"); } if (memberAccessibility.HasFlag(MemberAccessibility.Field)) { kind.Add("Field"); } if (memberAccessibility.HasFlag(MemberAccessibility.Event)) { kind.Add("Event"); } if (memberAccessibility.HasFlag(MemberAccessibility.Method)) { kind.Add("Method"); } if (memberAccessibility.HasFlag(MemberAccessibility.Property)) { kind.Add("Property"); } if (kind.Count > 0 && !kind.Contains(member.SymbolKind.ToString())) { continue; } return(true); } return(false); }
public static JObject ConstructMemberInfo(IMember m, IEmitter emitter, bool includeDeclaringType, bool isGenericSpecialization, SyntaxTree tree) { if (m is IMethod && ((IMethod)m).IsConstructor) { return(MetadataUtils.ConstructConstructorInfo((IMethod)m, emitter, includeDeclaringType, isGenericSpecialization, tree)); } var properties = MetadataUtils.GetCommonMemberInfoProperties(m, emitter, includeDeclaringType, isGenericSpecialization, tree); if (m.IsStatic) { properties.Add("is", true); } if (m is IMethod) { var method = (IMethod)m; var inline = emitter.GetInline(method); if (string.IsNullOrEmpty(inline) && method.Attributes.Any(a => a.AttributeType.FullName == "Bridge.ExpandParamsAttribute")) { properties.Add("exp", true); } properties.Add("t", (int)MemberTypes.Method); var parametersInfo = method.Parameters.Select(p => MetadataUtils.ConstructParameterInfo(p, emitter, false, false, tree)).ToList(); if (parametersInfo.Count > 0) { properties.Add("pi", new JArray(parametersInfo)); } if (!string.IsNullOrEmpty(inline)) { var isSelf = inline.StartsWith("<self>"); if (isSelf) { inline = inline.Substring(6); } if (!method.IsStatic && !isSelf && !inline.Contains("{this}")) { inline = "this." + inline; } var block = new InlineArgumentsBlock(emitter, new ArgumentsInfo(emitter, method), inline, method); var oldWriter = block.SaveWriter(); block.NewWriter(); block.EmitFunctionReference(true); var str = emitter.Output.ToString(); block.RestoreWriter(oldWriter); properties.Add("tpc", method.TypeParameters.Count); properties.Add("def", new JRaw(str)); } else { if (MetadataUtils.IsJsGeneric(method, emitter)) { properties.Add("tpc", method.TypeParameters.Count); properties.Add("tprm", new JArray(method.TypeParameters.Select(tp => tp.Name).ToArray())); } string sname; if (method.IsAccessor) { if (method.AccessorOwner is IProperty) { sname = Helpers.GetPropertyRef(method.AccessorOwner, emitter, ((IProperty)method.AccessorOwner).Setter == method); } else if (method.AccessorOwner is IEvent) { sname = Helpers.GetEventRef(method.AccessorOwner, emitter, ((IEvent)method.AccessorOwner).RemoveAccessor == method); } else { sname = OverloadsCollection.Create(emitter, method).GetOverloadName(); } } else { sname = OverloadsCollection.Create(emitter, method).GetOverloadName(); } if (sname.Contains("\"")) { properties.Add("sn", new JRaw(sname)); } else { properties.Add("sn", sname); } } properties.Add("rt", new JRaw(MetadataUtils.GetTypeName(method.ReturnType, emitter, isGenericSpecialization))); var attr = MetadataUtils.GetScriptableAttributes(method.ReturnTypeAttributes, emitter, tree).ToList(); if (attr.Count > 0) { JArray attrArr = new JArray(); foreach (var a in attr) { attrArr.Add(MetadataUtils.ConstructAttribute(a, null, emitter)); } properties.Add("rta", attrArr); } if (method.Parameters.Count > 0) { properties.Add("p", new JArray(method.Parameters.Select(p => new JRaw(MetadataUtils.GetTypeName(p.Type, emitter, isGenericSpecialization))))); } MetadataUtils.AddBox(m, emitter, properties); } else if (m is IField) { var field = (IField)m; properties.Add("t", (int)MemberTypes.Field); properties.Add("rt", new JRaw(MetadataUtils.GetTypeName(field.ReturnType, emitter, isGenericSpecialization))); properties.Add("sn", OverloadsCollection.Create(emitter, field).GetOverloadName()); if (field.IsReadOnly) { properties.Add("ro", field.IsReadOnly); } MetadataUtils.AddBox(m, emitter, properties); } else if (m is IProperty) { var typeDef = m.DeclaringTypeDefinition; var monoProp = typeDef != null?emitter.BridgeTypes.Get(typeDef).TypeDefinition.Properties.FirstOrDefault(p => p.Name == m.Name) : null; var prop = (IProperty)m; var canGet = prop.CanGet && prop.Getter != null; var canSet = prop.CanSet && prop.Setter != null; if (monoProp != null) { if (canGet) { canGet = monoProp.GetMethod != null; } if (canSet) { canSet = monoProp.SetMethod != null; } } properties.Add("t", (int)MemberTypes.Property); properties.Add("rt", new JRaw(MetadataUtils.GetTypeName(prop.ReturnType, emitter, isGenericSpecialization))); if (prop.Parameters.Count > 0) { properties.Add("p", new JArray(prop.Parameters.Select(p => new JRaw(MetadataUtils.GetTypeName(p.Type, emitter, isGenericSpecialization))))); } if (prop.IsIndexer) { properties.Add("i", true); } if (prop.IsIndexer) { if (prop.Getter != null) { var parametersInfo = prop.Getter.Parameters.Select(p => MetadataUtils.ConstructParameterInfo(p, emitter, false, false, tree)).ToList(); if (parametersInfo.Count > 0) { properties.Add("ipi", new JArray(parametersInfo)); } } else if (prop.Setter != null) { var parametersInfo = prop.Setter.Parameters.Take(prop.Setter.Parameters.Count - 1).Select(p => MetadataUtils.ConstructParameterInfo(p, emitter, false, false, tree)).ToList(); if (parametersInfo.Count > 0) { properties.Add("ipi", new JArray(parametersInfo)); } } } var inlineGetter = canGet && prop.Getter != null && (emitter.GetInline(prop.Getter) != null || Helpers.IsScript(prop.Getter)); var inlineSetter = canSet && prop.Setter != null && (emitter.GetInline(prop.Setter) != null || Helpers.IsScript(prop.Setter)); if (inlineGetter || inlineSetter || prop.IsIndexer) { if (canGet) { properties.Add("g", MetadataUtils.ConstructMemberInfo(prop.Getter, emitter, includeDeclaringType, isGenericSpecialization, tree)); } if (canSet) { properties.Add("s", MetadataUtils.ConstructMemberInfo(prop.Setter, emitter, includeDeclaringType, isGenericSpecialization, tree)); } } else { var fieldName = OverloadsCollection.Create(emitter, prop).GetOverloadName(); if (canGet) { properties.Add("g", MetadataUtils.ConstructFieldPropertyAccessor(prop.Getter, emitter, fieldName, true, includeDeclaringType, isGenericSpecialization, tree)); } if (canSet) { properties.Add("s", MetadataUtils.ConstructFieldPropertyAccessor(prop.Setter, emitter, fieldName, false, includeDeclaringType, isGenericSpecialization, tree)); } properties.Add("fn", fieldName); } } else if (m is IEvent) { var evt = (IEvent)m; properties.Add("t", (int)MemberTypes.Event); properties.Add("ad", MetadataUtils.ConstructMemberInfo(evt.AddAccessor, emitter, includeDeclaringType, isGenericSpecialization, tree)); properties.Add("r", MetadataUtils.ConstructMemberInfo(evt.RemoveAccessor, emitter, includeDeclaringType, isGenericSpecialization, tree)); } else { throw new ArgumentException("Invalid member " + m); } return(properties); }
public InitializerPath(IMember target) : this((object)target) { }
private static bool?ReflectableValue(IList <IAttribute> attributes, IMember member, IEmitter emitter) { var attr = attributes.FirstOrDefault(a => a.AttributeType.FullName == "Bridge.ReflectableAttribute"); if (attr == null) { attr = Helpers.GetInheritedAttribute(member, "Bridge.ReflectableAttribute"); if (attr != null) { if (attr.NamedArguments.Count > 0 && attr.NamedArguments.Any(arg => arg.Key.Name == "Inherits")) { var inherits = attr.NamedArguments.First(arg => arg.Key.Name == "Inherits"); if (!(bool)inherits.Value.ConstantValue) { attr = null; } } else { attr = null; } } } if (attr != null) { if (attr.PositionalArguments.Count == 0) { return(true); } if (attr.PositionalArguments.Count > 1) { var list = new List <MemberAccessibility>(); for (int i = 0; i < attr.PositionalArguments.Count; i++) { object v = attr.PositionalArguments[i].ConstantValue; list.Add((MemberAccessibility)(int)v); } return(MetadataUtils.IsMemberReflectable(member, list.ToArray())); } else { var rr = attr.PositionalArguments.First(); var value = rr.ConstantValue; if (rr is ArrayCreateResolveResult) { return(MetadataUtils.IsMemberReflectable(member, ((ArrayCreateResolveResult)rr).InitializerElements.Select(ie => (int)ie.ConstantValue).Cast <MemberAccessibility>().ToArray())); } if (value is bool) { return((bool)attr.PositionalArguments.First().ConstantValue); } if (value is int) { return(MetadataUtils.IsMemberReflectable(member, new[] { (MemberAccessibility)(int)value })); } if (value is int[]) { return(MetadataUtils.IsMemberReflectable(member, ((int[])value).Cast <MemberAccessibility>().ToArray())); } } } return(null); }
public TypeResolveResult(IClass callingClass, IMember callingMember, IReturnType resolvedType, IClass resolvedClass) : base(callingClass, callingMember, resolvedType) { _resolvedClass = resolvedClass; }
public TypeResolveResult(IClass callingClass, IMember callingMember, IReturnType resolvedType) : base(callingClass, callingMember, resolvedType) { _resolvedClass = resolvedType.GetUnderlyingClass(); }
IList <Guid> IJobAdFlagListsQuery.GetFlaggedJobAdIds(IMember member, IEnumerable <Guid> jobAdIds) { return(member == null ? new List <Guid>() : _jobAdListsQuery.GetListedJobAdIds(member.Id, ListTypes, NotIfInListTypes, jobAdIds)); }
public IntegerLiteralResolveResult(IClass callingClass, IMember callingMember, IReturnType systemInt32) : base(callingClass, callingMember, systemInt32) { }