protected UnturnedBuildable(IBuildableAsset asset, IWorldTransform transform, IBuildableState state, IOwnership ownership, string buildableInstanceId) { Asset = asset; Transform = transform; State = state; Ownership = ownership; BuildableInstanceId = buildableInstanceId; }
/*----< demonstrate requirements have been met >---------------*/ static void Main(string[] args) { TestUtilities.title("Starting Repository", '='); ClientEnvironment.verbose = true; // if true, display test results PluggableRepo repo = new PluggableRepo(); if (!repo.loadAndActivateComponents()) { Console.Write("\n Couldn't find Repository components.\n\n"); return; } // if activation succeeded, then do self test on each IVersion version = repo.getVersion(); IStorage storage = repo.getStorage(); ICheckin checkin = repo.getCheckin(); ICheckout checkout = repo.getCheckout(); IBrowse browse = repo.getBrowse(); IOwnership ownership = repo.getOwnership(); storage.analyzeDependencies(); if ( Util.checkNull(version) || Util.checkNull(storage) || Util.checkNull(checkin) || Util.checkNull(checkout) || Util.checkNull(browse) || Util.checkNull(ownership) ) { Console.Write("\n failed to load one or more required components"); } else { Util.checkResult(version.testComponent(), version.componentType); TestUtilities.putLine(); Util.checkResult(storage.testComponent(), storage.componentType); TestUtilities.putLine(); Util.checkResult(checkin.testComponent(), checkin.componentType); TestUtilities.putLine(); Util.checkResult(checkout.testComponent(), checkout.componentType); TestUtilities.putLine(); Util.checkResult(browse.testComponent(), browse.componentType); TestUtilities.putLine(); Util.checkResult(ownership.testComponent(), ownership.componentType); TestUtilities.putLine(); Console.Write("\n finished testing all loaded components"); } Console.Write("\n\n"); }
public static bool IsWritableByUser(this IOwnership thiz, User user) => user != null && (user.role == UserRole.SuperAdmin || user.id == thiz.owner);
public static bool IsVisibleToUser(this IOwnership thiz, User user) => thiz.visibility == Visibility.Public || IsWritableByUser(thiz, user);
/*----< activate pluggable component libraries >---------------*/ /* * Loads each of the libraries from the ComponentLibraries path. * Each component is activated and bound to a RepoEnvironment * reference. */ public bool loadAndActivateComponents() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromComponentLibFolder); // get names of component dlls if (!Directory.Exists(RepoEnvironment.componentsPath)) { Console.Write("\n can't find path to components"); return(false); } string[] libraries = Directory.GetFiles(RepoEnvironment.componentsPath, "*.dll"); // load libraries and, for each component, activate if (libraries.Length > 0) { foreach (string libName in libraries) { // load library string fileName = Path.GetFileName(libName); Console.Write("\n loading library: {0}", fileName); string fullLibName = Path.GetFullPath(libName); //Assembly asm = Assembly.LoadFile(fullLibName); Assembly asm = Assembly.LoadFrom(fullLibName); if (fileName.Contains("IPluggaleComponent.dll")) { continue; } // if library contains one of the Pluggable Components then activate Type[] types = asm.GetExportedTypes(); foreach (Type t in types) { if (t.IsClass && typeof(IStorage).IsAssignableFrom(t)) { storage = (IStorage)Activator.CreateInstance(t); RepoEnvironment.storage = storage; Console.Write("\n creating {0} component", storage.componentType); continue; } if (t.IsClass && typeof(IVersion).IsAssignableFrom(t)) { version = (IVersion)Activator.CreateInstance(t); RepoEnvironment.version = version; Console.Write("\n creating {0} component", version.componentType); continue; } if (t.IsClass && typeof(ICheckin).IsAssignableFrom(t)) { checkin = (ICheckin)Activator.CreateInstance(t); RepoEnvironment.checkin = checkin; Console.Write("\n creating {0} component", checkin.componentType); continue; } if (t.IsClass && typeof(ICheckout).IsAssignableFrom(t)) { checkout = (ICheckout)Activator.CreateInstance(t); RepoEnvironment.checkout = checkout; Console.Write("\n creating {0} component", checkout.componentType); continue; } if (t.IsClass && typeof(IBrowse).IsAssignableFrom(t)) { browse = (IBrowse)Activator.CreateInstance(t); RepoEnvironment.browse = browse; Console.Write("\n creating {0} component", browse.componentType); continue; } if (t.IsClass && typeof(IOwnership).IsAssignableFrom(t)) { ownership = (IOwnership)Activator.CreateInstance(t); RepoEnvironment.ownership = ownership; Console.Write("\n creating {0} component", ownership.componentType); continue; } } } } Console.Write("\n"); return(libraries.Length > 0); }