public void TestConstructors() { string actualName = typeof(MyClass).ToString(); Console.WriteLine("About to instantiate a :" + actualName); //convert type name as a string into a legit Type var type = Type.GetType(actualName, true, false); //ensure that the Type implements IAttacher if (!typeof(IAttacher).IsAssignableFrom(type)) { throw new TypeLoadException("Type " + type + " does not implement IAttacher"); } //find the blank constructor ConstructorInfo constructorInfo = type.GetConstructor(new Type[] {}); //if it doesnt have one if (constructorInfo == null) { throw new TypeLoadException("Type " + type + " does not have a blank constructor"); } //call the blank constructor and return the reuslts IAttacher bob = (IAttacher)constructorInfo.Invoke(new Type[] {}); }
public void Attach(IAttacher toAttachTo) { isBeeingDragged = false; isAttached = true; defaultParent = transform.parent; transform.parent = toAttachTo.GetTransform(); if (toAttachTo.ResetPositionOnAttach()) { transform.localPosition = toAttachTo.GetAttachOffset(); } else { transform.localPosition += toAttachTo.GetAttachOffset(); } if (toAttachTo.ResetOrientationOnAttach()) { transform.localRotation = Quaternion.identity; } SetMouseRaycastable(true); Game.EffectHandler.Play(attachEffect, gameObject); Game.EffectHandler.StopOnAllPotentialAttachables(attachment); }
public void Dispose() { if (attacher != null) { attacher.Dispose(); } attacher = null; executor = null; }
public static void RemoveMember(this IRepository<Securable> repository, IAttacher<Securable> attacher, int userId, int securableId) { var securable = repository.GetBy(s => s.Id == securableId, s=>s.Members); attacher.EnsureAttached(securable); var toRemove = securable.Members.Where(m => m.Id == userId).ToList(); foreach (var user in toRemove) { securable.Members.Remove(user); } repository.Update(securable); }
public CommandInfo AttachTo(CheckEdit check) { if (executor == null) { var e = new InvalidOperationException("command executor is not specified"); log.Error(e.Message); throw e; } attacher = new CheckEditAttacher(executor, check); return(this); }
public CommandInfo AttachTo(SimpleButton button) { if (executor == null) { var e = new InvalidOperationException("command executor is not specified"); log.Error(e.Message); throw e; } attacher = new SimpleButtonAttacher(executor, button, RefreshControlsState); return(this); }
public HacksController( IRepository<Data.User> userRepo, IRepository<Data.Post> postRepo, IRepository<Data.Blog> blogRepo, IRepository<Data.Securable> securableRepo, IAttacher<Data.Blog> blogAttacher) { _userRepo = userRepo; _postRepo = postRepo; _blogRepo = blogRepo; _securableRepo = securableRepo; _blogAttacher = blogAttacher; }
public HacksController( IRepository <Data.User> userRepo, IRepository <Data.Post> postRepo, IRepository <Data.Blog> blogRepo, IRepository <Data.Securable> securableRepo, IAttacher <Data.Blog> blogAttacher) { _userRepo = userRepo; _postRepo = postRepo; _blogRepo = blogRepo; _securableRepo = securableRepo; _blogAttacher = blogAttacher; }
public static void RemoveMember(this IRepository <Securable> repository, IAttacher <Securable> attacher, int userId, int securableId) { var securable = repository.GetBy(s => s.Id == securableId, s => s.Members); attacher.EnsureAttached(securable); var toRemove = securable.Members.Where(m => m.Id == userId).ToList(); foreach (var user in toRemove) { securable.Members.Remove(user); } repository.Update(securable); }
public AccountController( OpenIdMembershipService membershipService, IRepository<User> userRepository, IRepository<Data.Blog> blogRepo, IRepository<Invitation> invitationRepository, IAttacher<User> userAttacher, IAttacher<Securable> securableAttacher, ISecurityHelper securityHelper, IHttpContextService httpContext) : base(blogRepo, httpContext) { _openIdMembership = membershipService; _userRepository = userRepository; _securityHelper = securityHelper; _invitationRepository = invitationRepository; _userAttacher = userAttacher; _securableAttacher = securableAttacher; }
public AccountController( OpenIdMembershipService membershipService, IRepository <User> userRepository, IRepository <Data.Blog> blogRepo, IRepository <Invitation> invitationRepository, IAttacher <User> userAttacher, IAttacher <Securable> securableAttacher, ISecurityHelper securityHelper, IHttpContextService httpContext) : base(blogRepo, httpContext) { _openIdMembership = membershipService; _userRepository = userRepository; _securityHelper = securityHelper; _invitationRepository = invitationRepository; _userAttacher = userAttacher; _securableAttacher = securableAttacher; }
public PermissionsEditorController( IRepository <User> userRepo, IRepository <Data.Blog> blogRepo, IRepository <Securable> securableRepo, IRepository <Invitation> invitationRepo, ISecurityHelper securityHelper, IInvitationService invitationService, IAttacher <Securable> securableAttacher, IAttacher <Data.Blog> blogAttacher) { _userRepo = userRepo; _blogRepo = blogRepo; _securableRepo = securableRepo; _invitationRepo = invitationRepo; _securityHelper = securityHelper; _invitationService = invitationService; _blogAttacher = blogAttacher; _securableAttacher = securableAttacher; }
public PermissionsEditorController( IRepository<User> userRepo, IRepository<Data.Blog> blogRepo, IRepository<Securable> securableRepo, IRepository<Invitation> invitationRepo, ISecurityHelper securityHelper, IInvitationService invitationService, IAttacher<Securable> securableAttacher, IAttacher<Data.Blog> blogAttacher) { _userRepo = userRepo; _blogRepo = blogRepo; _securableRepo = securableRepo; _invitationRepo = invitationRepo; _securityHelper = securityHelper; _invitationService = invitationService; _blogAttacher = blogAttacher; _securableAttacher = securableAttacher; }
public CommandInfo AttachTo(IAttacher attacher) { this.attacher = attacher; attacher.Attach(); return(this); }