void AddControllers(IDList list, Guid parentId, IDList existingList) { foreach (var controller in ControllerType.GetAllControllers().Values.Where(c => c.ParentId == parentId && !existingList.Contains(new ID(c.Id)))) { list.Add(new ID(controller.Id)); } }
private bool EnsureSqlVersion(ItemDefinition itemDefinition, DataProvider sqlProvider, CallContext context) { var sqlVersion = GetSqlVersion(itemDefinition.ID, context, sqlProvider); if (sqlVersion != null) { return(true); } if (itemDefinition.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerType.GetAllControllers().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerAction.GetControllerAction(itemDefinition.ID) != null) { var parentId = GetParentID(itemDefinition, context) ?? sqlProvider.GetParentID(itemDefinition, context); var itemdef = GetItemDefinition(parentId, context) ?? sqlProvider.GetItemDefinition(parentId, context); if (!sqlProvider.CreateItem(itemDefinition.ID, itemDefinition.Name, itemDefinition.TemplateID, itemdef, context)) { return(false); } var item = Database.GetItem(itemDefinition.ID); var existingFields = new ItemChanges(item); foreach (Field field in item.Fields) { existingFields.SetFieldValue(field, item[field.ID]); } sqlProvider.SaveItem(itemDefinition, existingFields, context); return(true); } return(false); }
private static IDictionary <Guid, ISet <ControllerAction> > GetAllActions() { if (_allActions.Any()) { return(_allActions); } lock (_allActionsLock) { if (_allActions.Any()) { return(_allActions); } var controllers = ControllerType.GetAllControllers().Values; foreach (var controllerType in controllers) { var controllerId = ControllerType.ToUniqueId(controllerType.Type.AssemblyQualifiedName); if (!_allActions.ContainsKey(controllerId)) { _allActions[controllerId] = new SortedSet <ControllerAction>(); } MethodInfo[] allMethods = controllerType.Type.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public); MethodInfo[] actionMethods = Array.FindAll(allMethods, IsValidActionMethod); var aliasedMethods = Array.FindAll(actionMethods, info => info.IsDefined(typeof(ActionNameAttribute), true /* inherit */)); var nonAliasedMethods = actionMethods.Except(aliasedMethods); foreach (var aliasedMethod in aliasedMethods) { var name = aliasedMethod.GetCustomAttributes(typeof(ActionNameAttribute), true).OfType <ActionNameAttribute>().FirstOrDefault(); if (name != null) { _allActions[controllerId].Add(new ControllerAction { ActionName = name.Name, ControllerType = controllerType, MethodInfo = aliasedMethod }); } } foreach (var method in nonAliasedMethods) { _allActions[controllerId].Add(new ControllerAction { ActionName = method.Name, ControllerType = controllerType, MethodInfo = method }); } } } return(_allActions); }
void AddControllers(IDList list, Guid parentId, CallContext context) { var sqlProvider = GetSqlProvider(Database); foreach (var controller in ControllerType.GetAllControllers().Values.Where(c => { if (c.ParentId != parentId) { return(false); } return(GetSqlVersion(new ID(c.Id), context, sqlProvider) == null); })) { list.Add(new ID(controller.Id)); } }
public override VersionUriList GetItemVersions(ItemDefinition itemDefinition, CallContext context) { Assert.ArgumentNotNull(itemDefinition, "itemDefinition"); Assert.ArgumentNotNull(context, "context"); if (context.CurrentResult != null) { return(null); } if (itemDefinition.ID == FolderId || ControllerType.GetAllNamespaces().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerType.GetAllControllers().ContainsKey(itemDefinition.ID.ToGuid()) || ControllerAction.GetControllerAction(itemDefinition.ID) != null) { VersionUriList versionUriList = new VersionUriList(); foreach (Language language in LanguageManager.GetLanguages(Database)) { versionUriList.Add(language, Version.First); } return(versionUriList); } return(null); }