Example #1
0
        public static T GetProtocolValue <T>(object obj, SDataProtocolProperty prop)
        {
            Guard.ArgumentNotNull(obj, "obj");

            var prot = obj as ISDataProtocolObject;

            if (prot != null)
            {
                return((T)prot.Info.GetValue(prop));
            }

            var getters = _getProtocolValueCache[obj.GetType()];

            ReflectionUtils.GetDelegate getter;
            return(getters.TryGetValue(prop, out getter) ? (T)getter(obj) : default(T));
        }
Example #2
0
        public static bool SetProtocolValue(object obj, SDataProtocolProperty prop, object value)
        {
            Guard.ArgumentNotNull(obj, "obj");

            var prot = obj as ISDataProtocolObject;

            if (prot != null)
            {
                prot.Info.SetValue(prop, value);
                return(true);
            }

            var setters = _setProtocolValueCache[obj.GetType()];

            ReflectionUtils.SetDelegate setter;
            if (setters.TryGetValue(prop, out setter))
            {
                setter(obj, value);
                return(true);
            }

            return(false);
        }
Example #3
0
 public SDataProtocolPropertyAttribute(SDataProtocolProperty value)
 {
     _value = value;
 }
 public SDataProtocolPropertyAttribute(SDataProtocolProperty value)
 {
     _value = value;
 }
Example #5
0
        public void SetValue(SDataProtocolProperty prop, object value)
        {
            switch (prop)
            {
            case SDataProtocolProperty.Id:
                Id = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Title:
                Title = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Updated:
                Updated = (value as DateTimeOffset?) ?? (value != null ? Convert.ToDateTime(value) : (DateTimeOffset?)null);
                break;

            case SDataProtocolProperty.TotalResults:
                TotalResults = value != null?Convert.ToInt32(value) : (int?)null;

                break;

            case SDataProtocolProperty.StartIndex:
                StartIndex = value != null?Convert.ToInt32(value) : (int?)null;

                break;

            case SDataProtocolProperty.ItemsPerPage:
                ItemsPerPage = value != null?Convert.ToInt32(value) : (int?)null;

                break;

            case SDataProtocolProperty.Url:
                Url = (Uri)value;
                break;

            case SDataProtocolProperty.Diagnoses:
                Diagnoses = (Diagnoses)value;
                break;

            case SDataProtocolProperty.Schema:
                Schema = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Links:
                Links = (IList <SDataLink>)value;
                break;

            case SDataProtocolProperty.Key:
                Key = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Uuid:
                Uuid = (Guid?)value;
                break;

            case SDataProtocolProperty.Lookup:
                Lookup = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Descriptor:
                Descriptor = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Permissions:
                Permissions = (IList <SDataPermission>)value;
                break;

            case SDataProtocolProperty.HttpMethod:
                HttpMethod = (HttpMethod?)value;
                break;

            case SDataProtocolProperty.HttpStatus:
                HttpStatus = (HttpStatusCode?)value;
                break;

            case SDataProtocolProperty.HttpMessage:
                HttpMessage = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.Location:
                Location = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.ETag:
                ETag = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.IfMatch:
                IfMatch = value != null?Convert.ToString(value) : null;

                break;

            case SDataProtocolProperty.DeleteMissing:
                DeleteMissing = value != null?Convert.ToBoolean(value) : (bool?)null;

                break;

            case SDataProtocolProperty.IsDeleted:
                IsDeleted = value != null?Convert.ToBoolean(value) : (bool?)null;

                break;

            case SDataProtocolProperty.SyncState:
                SyncState = (SyncState)value;
                break;

            case SDataProtocolProperty.SyncMode:
                SyncMode = (SyncMode?)value;
                break;

            case SDataProtocolProperty.SyncDigest:
                SyncDigest = (Digest)value;
                break;

            default:
                throw new ArgumentOutOfRangeException("prop");
            }
        }
Example #6
0
        public object GetValue(SDataProtocolProperty prop)
        {
            switch (prop)
            {
            case SDataProtocolProperty.Id:
                return(Id);

            case SDataProtocolProperty.Title:
                return(Title);

            case SDataProtocolProperty.Updated:
                return(Updated);

            case SDataProtocolProperty.TotalResults:
                return(TotalResults);

            case SDataProtocolProperty.StartIndex:
                return(StartIndex);

            case SDataProtocolProperty.ItemsPerPage:
                return(ItemsPerPage);

            case SDataProtocolProperty.Url:
                return(Url);

            case SDataProtocolProperty.Diagnoses:
                return(Diagnoses);

            case SDataProtocolProperty.Schema:
                return(Schema);

            case SDataProtocolProperty.Links:
                return(Links);

            case SDataProtocolProperty.Key:
                return(Key);

            case SDataProtocolProperty.Uuid:
                return(Uuid);

            case SDataProtocolProperty.Lookup:
                return(Lookup);

            case SDataProtocolProperty.Descriptor:
                return(Descriptor);

            case SDataProtocolProperty.Permissions:
                return(Permissions);

            case SDataProtocolProperty.HttpMethod:
                return(HttpMethod);

            case SDataProtocolProperty.HttpStatus:
                return(HttpStatus);

            case SDataProtocolProperty.HttpMessage:
                return(HttpMessage);

            case SDataProtocolProperty.Location:
                return(Location);

            case SDataProtocolProperty.ETag:
                return(ETag);

            case SDataProtocolProperty.IfMatch:
                return(IfMatch);

            case SDataProtocolProperty.DeleteMissing:
                return(DeleteMissing);

            case SDataProtocolProperty.IsDeleted:
                return(IsDeleted);

            case SDataProtocolProperty.SyncState:
                return(SyncState);

            case SDataProtocolProperty.SyncMode:
                return(SyncMode);

            case SDataProtocolProperty.SyncDigest:
                return(SyncDigest);

            default:
                throw new ArgumentOutOfRangeException("prop");
            }
        }