Beispiel #1
0
        private static string GetValue(NamedProperty property)
        {
            switch (property.Metadata.TypeId)
            {
            case PropertyTypeId.String:
                return(property.GetValue <string>());

            case PropertyTypeId.Double:
                return(property.GetValue <double>().ToString());

            case PropertyTypeId.Guid:
                return(property.GetValue <Guid>().ToString());

            case PropertyTypeId.Int64:
                return(property.GetValue <Int64>().ToString());

            case PropertyTypeId.Binary:
                return("binary " + property.Metadata.ValueSize + " bytes");

            case PropertyTypeId.Invalid:
            default:
                return("invalid");
            }
        }
 public T GetValue <T>()
 {
     return(namedProperty.GetValue <T>());
 }
        public static object GetNamedPropertyValue(NamedProperty property)
        {
            ThrowIf.Null(property, "property");
            object propertyValue = null;

            // Special case GetValue calls (See Bug: 860194 for details)...
            FabricErrorCode errorCode = (FabricErrorCode)FabricClientState.HandleException(() => propertyValue = property.GetValue <object>());

            if (errorCode != 0 && errorCode != FabricErrorCode.PropertyValueEmpty)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "GetProperty failed with an unexpected error code {0}", errorCode));
            }

            return(propertyValue);
        }