/// <summary>
        ///     Creates an instance reading the xml and applying the defaults where 
        ///     there are no information available
        /// </summary>
        /// <param name="xml">xml fragment to parse</param>
        /// --------------------------------------------------------------------------------------------------
        public GroupPreferences(XElement xml)
            : this()
        {
            if (xml == null)
                return;

            bool internalPurpose = !xml.Name.Namespace.Equals(ConfigReader.S2CNS);

            /* GUI */
            string colorcode = GROUP_ACCENT;
            xml.ParseNode("ColorCode", ref colorcode, internalPurpose);
            ColorCode = colorcode;
            /* END GUI */

            /* Third Parties Credentials */
            string githubLogin = string.Empty;
            xml.ParseNode("GithubLogin", ref githubLogin, internalPurpose);
            GithubLogin = githubLogin;
            /* END Third Parties Credentials */
        }
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            string name = string.Empty;
            int order = 0;
            List<string> possibleValues = new List<string>();
            List<SnippetProperty> dependsOn = new List<SnippetProperty>();

            xml.ParseNode("Name", ref name, false);
            xml.ParseNode("Order", ref order, false);

            XElement possValues = xml.GetNode("PossibleValues", false);
            if (possValues != null)
            {
                List<XElement> elems = possValues.GetNodes("Value", false);    
                foreach (XElement el in elems)
                {
                    possibleValues.Add(el.Value);
                }
            }

            XElement dependsOnElem = xml.GetNode("DependsOn", false);
            if (dependsOnElem != null)
            {
                List<XElement> elems = dependsOnElem.GetNodes("Property", false);
                foreach (XElement el in elems)
                {
                    dependsOn.Add(new SnippetProperty(el.ToString(), SerialFormat.XML));
                }
            }

            Init(name, order, possibleValues, dependsOn);

            return true;
        }
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            long commentID = 0;
            long snippetID = 0;
            int userID = 0;
            string userFullName = string.Empty;
            string text = string.Empty;
            DateTime date = DateTime.MinValue;
            long disqusPostId = -1;
            string disqusAuthorUID = string.Empty;

            xml.ParseNode("CommentID", ref commentID, false);
            xml.ParseNode("SnippetID", ref snippetID, false);
            xml.ParseNode("CommenterID", ref userID, false);
            xml.ParseNode("CommenterFullName", ref userFullName, false);
            xml.ParseNode("Content", ref text, false);
            xml.ParseNode("SnippetCommentDate", ref date, false);
            xml.ParseNode("DisqusPostId", ref disqusPostId, false);
            xml.ParseNode("DisqusAuthorUID", ref disqusAuthorUID, false);

            Init(commentID, snippetID, userID, userFullName, text, date, disqusPostId, disqusAuthorUID);

            return true;
        }
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            short id = 0;
            string name = string.Empty;
            RankingActionCategory cat = RankingActionCategory.DirectAction;
            int threshold = 0;
            short points = 0;

            xml.ParseNode("ID", ref id, false);
            xml.ParseNode("Name", ref name, false);
            xml.ParseNode<RankingActionCategory>("Category", ref cat, false);
            xml.ParseNode("Threshold", ref threshold, false);
            xml.ParseNode("Points", ref points, false);

            Init(id, name, cat, threshold, points);

            return true;
        }
Example #5
0
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            int id = 0;
            string name = string.Empty;
            GroupPolicy policy = GroupPolicy.OpenSource;
            string shortDescr = string.Empty;
            string descr = string.Empty;
            int creatorID = 0;
            int numOfSnippets = 0;

            xml.ParseNode("ID", ref id, false);
            xml.ParseNode("Name", ref name, false);
            xml.ParseNode<GroupPolicy>("Policy", ref policy, false);
            xml.ParseNode("ShortDescription", ref shortDescr, false);
            xml.ParseNode("Description", ref descr, false);
            xml.ParseNode("CreatorID", ref creatorID, false);
            xml.ParseNode("NumOfSnippets", ref numOfSnippets, false);
            xml.ParseNode("MembersCount", ref m_membersCount, false);

            GroupPreferences prefs = new GroupPreferences(xml.GetNode("pref", false));

            Init(id, name, policy, prefs, shortDescr, descr, creatorID, numOfSnippets);

            return true;
        }
Example #6
0
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            int id = 0;
            string email = string.Empty;
            string name = string.Empty;
            string lastname = string.Empty;
            string nickname = string.Empty;
            bool active = false;
            DateTime created = DateTime.MinValue;
            DateTime loginFirst = DateTime.MinValue;
            DateTime loginLast = DateTime.MinValue;
            long pictureID = 0;
            bool hasValidMail = false;
            int points = 0;
            UserRole role = UserRole.Normal;
            int personalGroupID = 0;
            int defaultGroupID = 0;

            xml.ParseNode("ID", ref id, false);
            xml.ParseNode("EMail", ref email, false);
            xml.ParseNode("Name", ref name, false);
            xml.ParseNode("LastName", ref lastname, false);
            xml.ParseNode("NickName", ref nickname, false);
            //xml.ParseNode("Active", ref active, false);
            //xml.ParseNode("AcctCreated", ref created, false);
            //xml.ParseNode("LoginFirst", ref loginFirst, false);
            //xml.ParseNode("LoginLast", ref loginLast, false);
            xml.ParseNode("PictureID", ref pictureID, false);
            //xml.ParseNode("HasValidMail", ref hasValidMail, false);
            xml.ParseNode("Points", ref points, false);
            xml.ParseNode<UserRole>("Role", ref role, false);
            xml.ParseNode("PersonalGroupID", ref personalGroupID, false);
            xml.ParseNode("DefaultGroupID", ref defaultGroupID, false);

            UserPreferences prefs = new UserPreferences(xml.GetNode("pref", false));

            Init(id, email, name, lastname, nickname, active, created, loginFirst, loginLast, prefs,
                pictureID, hasValidMail, points, role, personalGroupID, defaultGroupID);

            return true;
        }
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            List<SnippetBCK> snippets = new List<SnippetBCK>();
            int userID = -1;

            xml.ParseNode("UserID", ref userID, false);

            List<XElement> snips = xml.GetNodes("Snippet", false);         
            foreach (XElement snip in snips)
            {
                SnippetBCK s = new SnippetBCK();
                s.Parse(snip);
                snippets.Add(s);
            }

            Init(snippets, userID);

            return true;
        }
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            int groupID = 0;
            int userID = 0;
            bool isAdmin = false;
            GroupJoinStatus status = GroupJoinStatus.Unknown;

            xml.ParseNode("GroupID", ref groupID);
            xml.ParseNode("UserID", ref userID);        
            xml.ParseNode("IsAdmin", ref isAdmin);
            xml.ParseNode<GroupJoinStatus>("Status", ref status);

            Init(groupID, userID, isAdmin, status);

            return true;
        }
 private void SetAlertPeriodicity(AlertPeriod defaultPeriod, AlertType type, bool internalPurpose, XElement xmlPref)
 {
     AlertPeriod period = defaultPeriod;
     xmlPref.ParseNode<AlertPeriod>("alertPeriod_" + type, ref period, internalPurpose);
     if (AlertPeriodicity.ContainsKey(type))
         AlertPeriodicity[type] = period;
     else
         AlertPeriodicity.Add(type, period);
 }
        /// <summary>
        ///     Creates a user preference reading the xml and applying the defaults where 
        ///     there are no information available
        /// </summary>
        /// <param name="xmlPref">xml fragment to parse</param>
        /// --------------------------------------------------------------------------------------------------
        public UserPreferences(XElement xmlPref)
            : this()
        {
            if (xmlPref == null)
                return;

            bool internalPurpose = !xmlPref.Name.Namespace.Equals(ConfigReader.S2CNS);

            /* Personal Info: */
            string descr = Description;
            xmlPref.ParseNode("description", ref descr, internalPurpose);
            Description = descr;

            string location = Location;
            xmlPref.ParseNode("location", ref location, internalPurpose);
            Location = descr;

            string webSite = WebSite;
            XElement node = xmlPref.ParseNode("webSite", ref webSite, internalPurpose);
            WebSite = webSite;
            if (node != null)
            {
                if (node.Attribute("redirect") != null)
                {
                    bool redirToWS = RedirectToWebSite;
                    bool.TryParse(node.Attribute("redirect").Value, out redirToWS);
                    RedirectToWebSite = redirToWS;
                }
            }

            bool displayInComm = DisplayProfileInCommunity;
            xmlPref.ParseNode("displayProfileInCommunity", ref displayInComm, internalPurpose);
            DisplayProfileInCommunity = displayInComm;

            bool displayReputation = DisplayReputation;
            xmlPref.ParseNode("displayReputation", ref displayReputation, internalPurpose);
            DisplayReputation = displayReputation;
            /* END Personal Info. */

            /* Browsing Options: */
            int items = NItems;
            xmlPref.ParseNode("n_items", ref items, internalPurpose);
            NItems = items;

            bool displayAvgRating = DisplayAvgRating;
            xmlPref.ParseNode("displayAvgRating", ref displayAvgRating, internalPurpose);
            DisplayAvgRating = displayAvgRating;

            bool codeWrap = CodeWrap;
            xmlPref.ParseNode("codeWrap", ref codeWrap, internalPurpose);
            CodeWrap = codeWrap;

            int tagsInFilters = TagsInFilters;
            xmlPref.ParseNode("tagsInFilters", ref tagsInFilters, internalPurpose);
            TagsInFilters = tagsInFilters;
            /* END Browsing Options. */

            /* Home Page Settings: */
            bool displayQuickLink = DisplayQuickLink;
            xmlPref.ParseNode("displayQuickLink", ref displayQuickLink, internalPurpose);
            DisplayQuickLink = displayQuickLink;

            // Left Panels
            HomePageLeftPanel tmpHTLP = HomeTopLeftPanel;
            xmlPref.ParseNode<HomePageLeftPanel>("homeTopLeftPanel", ref tmpHTLP, internalPurpose);
            HomeTopLeftPanel = tmpHTLP;

            HomePageLeftPanel tmpHMLP = HomeMiddleLeftPanel;
            xmlPref.ParseNode<HomePageLeftPanel>("homeMidLeftPanel", ref tmpHMLP, internalPurpose);
            HomeMiddleLeftPanel = tmpHMLP;

            HomePageLeftPanel tmpHBLP = HomeBottomLeftPanel;
            xmlPref.ParseNode<HomePageLeftPanel>("homeBotLeftPanel", ref tmpHBLP, internalPurpose);
            HomeBottomLeftPanel = tmpHBLP;

            // Right Panels
            HomePageRightPanel tmpHTRP = HomeTopRightPanel;
            xmlPref.ParseNode<HomePageRightPanel>("homeTopRightPanel", ref tmpHTRP, internalPurpose);
            HomeTopRightPanel = tmpHTRP;

            HomePageRightPanel tmpHMRP = HomeMiddleRightPanel;
            xmlPref.ParseNode<HomePageRightPanel>("homeMiddleRightPanel", ref tmpHMRP, internalPurpose);
            HomeMiddleRightPanel = tmpHMRP;

            HomePageRightPanel tmpHBRP = HomeBottomRightPanel;
            xmlPref.ParseNode<HomePageRightPanel>("homeBotRightPanel", ref tmpHBRP, internalPurpose);
            HomeBottomRightPanel = tmpHBRP;
            /* END Home Page Settings. */

            /* Alerting System:  */
            XElement alertNode = xmlPref.GetNode("alerts", internalPurpose);
            if (alertNode != null)
            {
                bool newShareAlert = NewShareAlert;
                alertNode.ParseNode("newShareAlert", ref newShareAlert, internalPurpose);
                NewShareAlert = newShareAlert;

                bool newCommentAlert = NewCommentAlert;
                alertNode.ParseNode("newCommentAlert", ref newCommentAlert, internalPurpose);
                NewCommentAlert = newCommentAlert;

                bool formatHtml = AlertFormatHtml;
                alertNode.ParseNode("formatHtml", ref formatHtml, internalPurpose);
                AlertFormatHtml = formatHtml;

                bool alertEmail = AlertEmail;
                alertNode.ParseNode("alertEmail", ref alertEmail, internalPurpose);
                AlertEmail = alertEmail;

                //ALert Periodicity:
                if (AlertPeriodicity == null)
                    AlertPeriodicity = new Dictionary<AlertType, AlertPeriod>();

                SetAlertPeriodicity(AlertPeriod.Weekly, AlertType.ChannelsNews, internalPurpose, alertNode);
                SetAlertPeriodicity(AlertPeriod.ASAP, AlertType.CustomFromAdmin, internalPurpose, alertNode);
                SetAlertPeriodicity(AlertPeriod.Weekly, AlertType.BadgeNews, internalPurpose, alertNode);
                SetAlertPeriodicity(AlertPeriod.ASAP, AlertType.NewSnippetInGroup, internalPurpose, alertNode);

                string unsubChannels = string.Empty;
                alertNode.ParseNode("unsubChannels", ref unsubChannels, internalPurpose);
                UnsubscribedChannels = unsubChannels.ParseIntoListOfInt(',');
            }
            /* END Alerting System */

            /* Premium Services: */
            XElement premiumNode = xmlPref.GetNode("premium", internalPurpose);
            if (premiumNode != null)
            {
                int maxPublishedItems = MaxPublishedItems;
                premiumNode.ParseNode("maxPublishedItems", ref maxPublishedItems, internalPurpose);
                if (maxPublishedItems < DEF_MAXPUBITEMS)
                    maxPublishedItems = DEF_MAXPUBITEMS;
                MaxPublishedItems = maxPublishedItems;

                bool featuredUser = IsFeaturedUser;
                premiumNode.ParseNode("featuredUser", ref featuredUser, internalPurpose);
                IsFeaturedUser = featuredUser;
            }
            /* END Premium Services. */

            /* Picture: */
            int thumbUploadNum = ThumbUploadNum;
            xmlPref.ParseNode("thumbUploadNum", ref thumbUploadNum, internalPurpose);
            ThumbUploadNum = thumbUploadNum;

            string gravatarEmail = GravatarEmail;
            xmlPref.ParseNode("gravatarEmail", ref gravatarEmail, internalPurpose);
            GravatarEmail = gravatarEmail;
            /* END Picture. */

            /* Third Parties Credentials */
            bool hasValidPsw = HasValidPsw;
            xmlPref.ParseNode("hasValidPsw", ref hasValidPsw, internalPurpose);
            HasValidPsw = hasValidPsw;

            string stackoverflowAccessToken = StackoverflowAccessToken;
            xmlPref.ParseNode("stackoverflowAccessToken", ref stackoverflowAccessToken, internalPurpose);
            StackoverflowAccessToken = stackoverflowAccessToken;

            string githubAccessToken = GithubAccessToken;
            xmlPref.ParseNode("githubAccessToken", ref githubAccessToken, internalPurpose);
            GithubAccessToken = githubAccessToken;

            string githubUsername = GithubUsername;
            xmlPref.ParseNode("githubUsername", ref githubUsername, internalPurpose);
            GithubUsername = githubUsername;

            string twitterUsername = TwitterUsername;
            xmlPref.ParseNode("twitterUsername", ref twitterUsername, internalPurpose);
            TwitterUsername = twitterUsername;
            /* END Third Parties Credentials */
        }
Example #11
0
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            long id = 0;
            int ownerGroupID = 0;
            int creatorID = 0;
            string name = string.Empty;
            string description = string.Empty;
            string code = string.Empty;
            DateTime created = DateTime.MinValue;
            DateTime modified = DateTime.MinValue;
            ShareOption visibility = ShareOption.Private;
            int rating = -1;
            float avgRating = 0.0F;
            int numVote = 0;
            decimal pricePerView = new decimal(0.0);
            string linkToSource = string.Empty;
            string extAuthor = string.Empty;
            int targetGroupID = -1;
            string creatorName = string.Empty;
            string ownerGroupName = string.Empty;
            int creatorImageNum = 0;
            int creatorPoints = 0;

            xml.ParseNode("ID", ref id, false);
            xml.ParseNode("OwnerGroupID", ref ownerGroupID, false);
            xml.ParseNode("CreatorID", ref creatorID, false);
            xml.ParseNode("Name", ref name, false);
            xml.ParseNode("Description", ref description, false);
            xml.ParseNode("Code", ref code, false);
            xml.ParseNode("Created", ref created, false);
            xml.ParseNode("Modified", ref modified, false);
            xml.ParseNode<ShareOption>("Visibility", ref visibility, false);
            xml.ParseNode("Rating", ref rating, false);
            xml.ParseNode("AvgRating", ref avgRating, false);
            xml.ParseNode("NumVote", ref numVote, false);
            xml.ParseNode("PricePerView", ref pricePerView, false);
            xml.ParseNode("LinkToSource", ref linkToSource, false);
            xml.ParseNode("ExtAuthor", ref extAuthor, false);
            xml.ParseNode("TargetGroupID", ref targetGroupID, false);
            xml.ParseNode("CreatorName", ref creatorName, false);
            xml.ParseNode("OwnerGroupName", ref ownerGroupName, false);
            xml.ParseNode("CreatorImageNum", ref creatorImageNum, false);
            xml.ParseNode("CreatorPoints", ref creatorPoints, false); 

            //ItemMetaInfo itemMeta = new ItemMetaInfo(xml.GetNode(ItemMetaInfo.XMLRootName.LocalName, false));

            Init(id, ownerGroupID, creatorID, name, description, code, created, modified, visibility, //itemMeta,
                rating, avgRating, numVote, false, pricePerView, linkToSource, extAuthor, targetGroupID, creatorName, 
                ownerGroupName, creatorImageNum, creatorPoints, false, (byte)SnippetRelevance.S2C, 1, 0, 0, 0);

            XElement props = xml.GetNode("Properties", false);
            ParseProperties(props);

            XElement tags = xml.GetNode("Tags", false);
            ParseTags(tags);

            return true;
        }
Example #12
0
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            int userID = 0;
            Guid token = Guid.Empty;
            OneAllProvider provider = OneAllProvider.unknown;
            string oneAllNickname = string.Empty;
            bool tokenIsValid = true;

            xml.ParseNode("UserID", ref userID);
            xml.ParseNode("Token", ref token);
            xml.ParseNode<OneAllProvider>("Provider", ref provider);
            xml.ParseNode("OneAllNickname", ref oneAllNickname);
            xml.ParseNode("TokenIsValid", ref tokenIsValid);

            Init(userID, token, provider, oneAllNickname, tokenIsValid);

            return true;
        }
Example #13
0
        public override bool Parse(XElement xml)
        {
            if (xml == null)
                return false;

            long id = 0;
            string creatorName = string.Empty;
            string ownerGroupName = string.Empty;
            string title = string.Empty;
            string description = string.Empty;
            string code = string.Empty;
            DateTime created = DateTime.MinValue;
            DateTime modified = DateTime.MinValue;
            ShareOption visib = ShareOption.Private;

            xml.ParseNode("ID", ref id, false);
            xml.ParseNode("CreatorName", ref creatorName, false);
            xml.ParseNode("OwnerGroupName", ref ownerGroupName, false);
            xml.ParseNode("Title", ref title, false);
            xml.ParseNode("Description", ref description, false);
            xml.ParseNode("Code", ref code, false);
            xml.ParseNode("Created", ref created, false);
            xml.ParseNode("Modified", ref modified, false);
            xml.ParseNode("Visibility", ref visib, false);

            Init(id, creatorName, ownerGroupName, title, description, code, created, modified, visib, null, null);

            XElement props = xml.GetNode("Properties", false);
            ParseProperties(props);

            XElement tags = xml.GetNode("Tags", false);
            ParseTags(tags);

            return true;
        }