예제 #1
0
파일: Group.cs 프로젝트: chcg/snip2codeNET
        /// <summary>
        /// This is the init/copy method for this class.
        /// It should be used by the children classes in the constructor in order to correctly fill the properties of the object.
        /// </summary>
        /// <param name="objToCopy"></param>
        protected bool Init(Group objToCopy)
        {
            if (objToCopy == null)
            {
                return(false);
            }

            //save the values of the properties with private setters:
            ID               = objToCopy.ID;
            Name             = objToCopy.Name;
            Policy           = objToCopy.Policy;
            Preferences      = objToCopy.Preferences;
            ShortDescription = objToCopy.ShortDescription;
            Description      = objToCopy.Description;
            CreatorID        = objToCopy.CreatorID;
            NumOfSnippets    = objToCopy.NumOfSnippets;

            //if the object to copy comes from a JSON deserialization, take the arguments from the helper class:
            if (objToCopy is GroupComm)
            {
                GroupComm jsonObj = (GroupComm)objToCopy;
                ID             = (objToCopy.ID > 0) ? objToCopy.ID : jsonObj.CommID;
                Preferences    = (objToCopy.Preferences == null) ? objToCopy.Preferences : jsonObj.CommPreferences;
                CreatorID      = (objToCopy.CreatorID > 0) ? objToCopy.CreatorID : jsonObj.CommCreatorID;
                m_membersCount = (objToCopy.MembersCount > 0) ? objToCopy.MembersCount : jsonObj.CommMembersCount;
            }

            return(true);
        }
예제 #2
0
파일: Group.cs 프로젝트: chcg/snip2codeNET
        public override BaseEntity ToJSONEntity()
        {
            //set the values for properties with private setters using the helper class:
            GroupComm json = new GroupComm();

            json.CommID           = ID;
            json.CommPreferences  = Preferences;
            json.CommCreatorID    = CreatorID;
            json.CommMembersCount = MembersCount;
            json.Init(this);

            return(json);
        }