Beispiel #1
0
 /// <summary>
 /// Gets a list of role names from the .cscfg file
 /// </summary>
 public List <string> GetRoleNameList()
 {
     return(OriginalVersion.Descendants(Namespaces.NsServiceManagement + "Role")
            .Attributes("name")
            .Select(attribute => attribute.Value)
            .ToList());
 }
        static public Version <T> Deserialize <T>(XmlReader reader)
            where T : class
        {
            OriginalVersion <T> version = new OriginalVersion <T>();

            version.ReadXml(reader);
            return(version);
        }
Beispiel #3
0
        /// <summary>
        /// Checks to see whether a particular setting exists in the roleset
        /// </summary>
        /// <param name="settingName">The name of the setting being checked</param>
        /// <returns>A bool as to whether the setting is present or not</returns>
        private XElement GetSetting(string settingName)
        {
            var setting = OriginalVersion.Descendants(name: Namespaces.NsServiceManagement + "Role").FirstOrDefault()
                          .Descendants(Namespaces.NsServiceManagement + "Setting").FirstOrDefault(
                b => (string)b.Attribute("name") == settingName);

            return(setting);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the instance count for the role
        /// </summary>
        /// <param name="roleName">The name of the role</param>
        /// <returns>An XElement instance of the instance count element</returns>
        private XElement GetInstanceCountElementForRole(string roleName)
        {
            XElement role = OriginalVersion.Descendants(Namespaces.NsServiceManagement + "Role")
                            .FirstOrDefault(a => (string)a.Attribute("name") == roleName);

            // updates the instance count number here
            return(role.Elements(Namespaces.NsServiceManagement + "Instances")
                   .FirstOrDefault());
        }
Beispiel #5
0
        protected void Add(OriginalVersion <T> version)
        {
            Check.Require(version != null, "version must not be null");
            Check.Require(version.OwnerId.Value == this.Uid.Value, "version ownerID must be equal to uid");

            if (this.versions == null)
            {
                this.versions = new List <OriginalVersion <T> >();
            }

            this.versions.Add(version);
        }
Beispiel #6
0
        public void ReadXml <T>(XmlReader reader, XVersionedObject <T> versionedObject) where T : class
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            // <xs:element name="uid" type="HIER_OBJECT_ID"/>
            versionedObject.Uid = new HierObjectId();
            ((System.Xml.Serialization.IXmlSerializable)versionedObject.Uid).ReadXml(reader);

            //<xs:element name="owner_id" type="OBJECT_REF"/>
            versionedObject.OwnerId = new ObjectRef();
            ((System.Xml.Serialization.IXmlSerializable)versionedObject.OwnerId).ReadXml(reader);

            // <xs:element name="time_created" type="DV_DATE_TIME"/>
            versionedObject.TimeCreated = new DvDateTime();
            ((System.Xml.Serialization.IXmlSerializable)versionedObject.TimeCreated).ReadXml(reader);

            //<xs:element name="total_version_count" type="xs:int"/>
            versionedObject.TotalVersionCount
                = reader.ReadElementContentAsInt("total_version_count", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            //<xs:element name="extract_version_count" type="xs:int"/>
            int extractCount
                = reader.ReadElementContentAsInt("extract_version_count", RmXmlSerializer.OpenEhrNamespace);

            reader.MoveToContent();

            // TODO: <xs:element name="revision_history" type="REVISION_HISTORY" minOccurs="0"/>

            //<xs:element name="versions" type="ORIGINAL_VERSION" minOccurs="0" maxOccurs="unbounded"/>
            if (reader.LocalName == "versions")
            {
                versionedObject.Versions = new AssumedTypes.List <OriginalVersion <T> >();

                while (reader.LocalName == "versions")
                {
                    OriginalVersion <T> version = new OriginalVersion <T>();
                    ((System.Xml.Serialization.IXmlSerializable)version).ReadXml(reader);
                    versionedObject.Versions.Add(version);
                }
            }

            reader.ReadEndElement();
            reader.MoveToContent();
        }
Beispiel #7
0
        /// <summary>
        /// Lyrics for this song, either from the song entry itself, or its original version.
        /// </summary>
        /// <param name="specialTags">Special tags. Can be null, which will cause no lyrics to be inherited.</param>
        /// <param name="allowInstrumental">
        /// Whether to allow inheriting lyrics for instrumental songs.
        /// This is mostly the case when the instrumental version is in the middle, for example original -> instrumental -> cover (with lyrics)
        /// </param>
        /// <param name="levels">Current level of traversing the parent chain.</param>
        private IList <LyricsForSong> GetLyricsFromParents(ISpecialTags specialTags, bool allowInstrumental, int levels)
        {
            int maxLevels = 10;

            if (specialTags != null &&
                (allowInstrumental || SongType != SongType.Instrumental) &&
                HasOriginalVersion &&
                !OriginalVersion.Deleted &&
                !Lyrics.Any() &&
                !Tags.HasTag(specialTags.ChangedLyrics) &&
                (allowInstrumental || !Tags.HasTag(specialTags.Instrumental)) &&
                levels < maxLevels)
            {
                return(OriginalVersion.GetLyricsFromParents(specialTags, true, levels + 1));
            }

            return(Lyrics);
        }
 /// <summary>
 /// Used to return the Xml representation for the current configuration file
 /// </summary>
 public override string ToString()
 {
     return(OriginalVersion.ToStringFullXmlDeclaration());
 }
Beispiel #9
0
 /// <summary>
 /// Gets a setting value for a role given a rolename and settings name
 /// </summary>
 public string GetSettingForRole(string settingName, string roleName)
 {
     return(OriginalVersion.Descendants(name: Namespaces.NsServiceManagement + "Role").FirstOrDefault(a => ((string)a.Attribute("name")).ToLower() == roleName.ToLower())
            .Descendants(Namespaces.NsServiceManagement + "Setting").FirstOrDefault(b => (string)b.Attribute("name") == settingName)
            .Attribute("value").Value);
 }
Beispiel #10
0
 public void CanonicalFormShouldThrowException()
 {
     var version = new OriginalVersion <string>();
     var result  = version.GetCanonicalForm();
 }
Beispiel #11
0
        public void IsBranchShouldThrowException()
        {
            var version = new OriginalVersion <string>();

            Assert.IsFalse(version.IsBranch);
        }
Beispiel #12
0
 public void GetOwnerIdShouldThrowException()
 {
     var version = new OriginalVersion <string>();
     var result  = version.GetOwnerId();
 }
Beispiel #13
0
 public void IsMergedShouldThrowException()
 {
     var version = new OriginalVersion <string>();
     var result  = version.IsMerged();
 }