public Policy(string filePath, XElement node, ObjectIndex references)
            : base(filePath, node, node.Attribute("PolicyId").Value, references)
        {
            if (XmlNode.Element(PolicyItem.ns + "BasePolicy")?.Element(PolicyItem.ns + "PolicyId")?.Value != null)
            {
                BasePolicy = new Reference <Policy>(this, XmlNode.Element(PolicyItem.ns + "BasePolicy")?.Element(PolicyItem.ns + "PolicyId")?.Value, references);
            }

            if (XmlNode.Element("UserJourneys") != null)
            {
                this.UserJourneys = new List <UserJourney>();
                foreach (var uj in XmlNode.Element("UserJourneys").Elements("UserJourney"))
                {
                    this.UserJourneys.Add(UserJourney.Load(this, filePath, uj, references));
                }
            }

            // RelyingParty
            this.RelyingParty = RelyingParty.Load(this, filePath, references);
            // BuildingBlocks
            this.BuildingBlocks = BuildingBlocks.Load(this, filePath, references);

            // ClaimsProviders
            if (XmlNode.Element(PolicyItem.ns + "ClaimsProviders") != null)
            {
                this.ClaimsProviders = new List <ClaimsProvider>();
                foreach (var cp in XmlNode.Element(PolicyItem.ns + "ClaimsProviders").Elements(PolicyItem.ns + "ClaimsProvider"))
                {
                    this.ClaimsProviders.Add(ClaimsProvider.Load(this, filePath, cp, references));
                }
            }
        }
Example #2
0
        internal static Localization Load(BuildingBlocks buildingBlocks, string path, ObjectIndex references)
        {
            var xmlNode = buildingBlocks.XmlNode.Element(PolicyItem.ns + "Localization");

            if (xmlNode == null)
            {
                return(null);
            }

            Localization item = new Localization(path, xmlNode, references, buildingBlocks);

            // fill data
            item.SupportedLanguage = new List <string>();
            foreach (var lang in item.XmlNode.Element(PolicyItem.ns + "SupportedLanguages").Elements(PolicyItem.ns + "SupportedLanguage"))
            {
                item.SupportedLanguage.Add(lang.Value);
            }


            item.LocalizedResources = new List <LocalizedResources>();
            foreach (var locRes in item.XmlNode.Element(PolicyItem.ns + "SupportedLanguages").Elements(PolicyItem.ns + "LocalizedResources"))
            {
                item.LocalizedResources.Add(PolicyItem.Load <LocalizedResources>(item, path, locRes, references));
            }
            return(item);
        }
        internal static BuildingBlocks Load(Policy policy, string path, ObjectIndex references)
        {
            var xmlNode = policy.XmlNode.Element(PolicyItem.ns + "BuildingBlocks");

            if (xmlNode == null)
            {
                return(null);
            }

            BuildingBlocks item = new BuildingBlocks(path, xmlNode, references, policy);

            // fill data

            // claims schema
            item.ClaimsSchema = new List <ClaimType>();
            if (xmlNode.Element(PolicyItem.ns + "ClaimsSchema") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "ClaimsSchema").Elements(PolicyItem.ns + "ClaimType"))
                {
                    item.ClaimsSchema.Add(PolicyItem.Load <ClaimType>(item, path, node, references));
                }
            }

            // Predicates
            item.Predicates = new List <Predicate>();
            if (xmlNode.Element(PolicyItem.ns + "Predicates") != null)
            {
                // Predicate
                foreach (var node in xmlNode.Element(PolicyItem.ns + "Predicates").Elements(PolicyItem.ns + "Predicate"))
                {
                    item.Predicates.Add(PolicyItem.Load <Predicate>(item, path, node, references));
                }
            }

            // PredicateValidations
            item.PredicateValidations = new List <PredicateValidation>();
            if (xmlNode.Element(PolicyItem.ns + "PredicateValidations") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "PredicateValidations").Elements(PolicyItem.ns + "PredicateValidation"))
                {
                    item.PredicateValidations.Add(PolicyItem.Load <PredicateValidation>(item, path, node, references));
                }
            }

            // ContentDefinitions
            item.ContentDefinitions = new List <ContentDefinition>();
            if (xmlNode.Element(PolicyItem.ns + "ContentDefinitions") != null)
            {
                foreach (var node in xmlNode.Element(PolicyItem.ns + "ContentDefinitions").Elements(PolicyItem.ns + "ContentDefinition"))
                {
                    item.ContentDefinitions.Add(PolicyItem.Load <ContentDefinition>(item, path, node, references));
                }
            }

            // ContentDefinitions
            item.Localization = Localization.Load(item, path, references);


            return(item);
        }
Example #4
0
 public Localization(string filePath, XElement node, ObjectIndex references, BuildingBlocks buildingBlocks) :
     base(filePath, node, null, references, buildingBlocks)
 {
 }