Ejemplo n.º 1
0
        private static object GetAccessLevel <T>(IPropertyBag properties, string actionPrefix, T defaultLevel)
        {
            MultiValuedProperty <string> actions = (MultiValuedProperty <string>)properties[OrganizationRelationshipSchema.FederationEnabledActions];
            string action       = OrganizationRelationshipHelper.GetAction(actions, actionPrefix);
            string levelElement = OrganizationRelationshipHelper.GetLevelElement(action);

            if (levelElement == null)
            {
                return(defaultLevel);
            }
            object result;

            try
            {
                result = (T)((object)Enum.Parse(typeof(T), levelElement, true));
            }
            catch (ArgumentNullException)
            {
                result = defaultLevel;
            }
            catch (ArgumentException)
            {
                result = defaultLevel;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private static void SetAccessScope <T>(ADObjectId objectId, IPropertyBag properties, string prefix, T defaultLevel)
        {
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)properties[OrganizationRelationshipSchema.FederationEnabledActions];
            string target          = (objectId != null) ? objectId.ObjectGuid.ToString() : null;
            string andRemoveAction = OrganizationRelationshipHelper.GetAndRemoveAction(multiValuedProperty, prefix);
            string text            = OrganizationRelationshipHelper.GetLevelElement(andRemoveAction);

            if (text == null)
            {
                text = defaultLevel.ToString();
            }
            multiValuedProperty.Add(OrganizationRelationshipHelper.GenerateAction(prefix, text, target));
        }